docs: def _sigmaclip_withaxis(self, data, axis=None, masked=True,
                              return_bounds=False, copy=True):
          """
          Sigma clip the data when ``axis`` is specified.
  
          In this case, we replace clipped values with NaNs as placeholder
          values.
          """
  
          # float array type is needed to insert nans into the array
          filtered_data = data.astype(float)    # also makes a copy
  
          # remove invalid values
          bad_mask = ~np.isfinite(filtered_data)
          if np.any(bad_mask):
              filtered_data[bad_mask] = np.nan
              warnings.warn('Input data contains invalid values (NaNs or '
                            'infs), which were automatically clipped.',
                            AstropyUserWarning)
  
          # remove masked values and convert to plain ndarray
          if isinstance(filtered_data, np.ma.MaskedArray):
              filtered_data = np.ma.masked_invalid(filtered_data).astype(float)
              filtered_data = filtered_data.filled(np.nan)
  
          # convert negative axis/axes
          if not isiterable(axis):
              axis = (axis,)
          axis = tuple(filtered_data.ndim + n if n < 0 else n for n in axis)
  
          # define the shape of min/max arrays so that they can be broadcast
          # with the data
          mshape = tuple(1 if dim in axis else size
                         for dim, size in enumerate(filtered_data.shape))
  
          nchanged = 1
          iteration = 0
          while nchanged != 0 and (iteration < self.maxiters):
              iteration += 1
              n_nan = np.count_nonzero(np.isnan(filtered_data))
  
              self._compute_bounds(filtered_data, axis=axis)
              if not np.isscalar(self._min_value):
                  self._min_value = self._min_value.reshape(mshape)
                  self._max_value = self._max_value.reshape(mshape)
  
              with np.errstate(invalid='ignore'):
                  filtered_data[(filtered_data < self._min_value) |
                                (filtered_data > self._max_value)] = np.nan
  
              nchanged = n_nan - np.count_nonzero(np.isnan(filtered_data))
  
          self._niterations = iteration
  
          if masked:
              # create an output masked array
              if copy:
                  filtered_data = np.ma.masked_invalid(filtered_data)
              else:
                  # ignore RuntimeWarnings for comparisons with NaN data values
                  with np.errstate(invalid='ignore'):
                      out = np.ma.masked_invalid(data, copy=False)
  
                      filtered_data = np.ma.masked_where(np.logical_or(
                          out < self._min_value, out > self._max_value),
                          out, copy=False)
  
          if return_bounds:
              return filtered_data, self._min_value, self._max_value
          else:
              return filtered_data