robust_sigma_clip_mask¶
- sofia_redux.scan.utilities.utils.robust_sigma_clip_mask(values, weights=None, mask=None, sigma=5.0, verbose=False, max_iterations=5)[source]¶
Return a masking array indicating sigma clipped elements of an input array.
Iteratively identifies outliers in a given input array based on the number of standard deviations (
sigma
) of each datum from the median value of the givenvalues
.On each iteration, values that are more than
sigma
* std(values
) away from the median are ignored on subsequent iterations in which new medians and standard deviations are calculated.Note that while any multi-dimensional arrays may be provided, the calculated median and standard deviation on each iteration will apply to the entirety of the data set.
The iterations will desist once
max_iterations
iterations have occurred, no additional elements are identified as outliers on an iteration, or all elements have been masked.- Parameters:
- valuesunits.Quantity or numpy.ndarray (float)
The values for which to calculated the sigma clipping masked array. NaN values will be ignored in all calculations and appear as
False
in the output mask array.- weightsunits.Quantity or numpy.ndarray (float), optional
Optional weighting for the values. These should typically represent the inverse variance of the provided data. If provided, the calculated median will be weighted accordingly using
numba_functions.smart_median()
, as will the derived standard deviation.- masknumpy.ndarray (bool), optional
An optional starting mask where
False
indicates an invalid or clipped value. Will not be updated in-place.- sigmafloat, optional
The number of standard deviations away from the median that will result in a datum being clipped.
- verbosebool, optional
If
True
, will output log messages indicating the total number of clipped values, the median, and the standard deviation on each iteration.- max_iterationsint, optional
The maximum number of iterations that will be used to derive the masking array.
- Returns: