Perform sigma-clipping on the provided data.
This performs the sigma clipping algorithm - i.e. the data will be iterated over, each time rejecting points that are more than a specified number of standard deviations discrepant.
Note
scipy.stats.sigmaclip provides a subset of the functionality in this function.
Parameters : | data : array-like
sig : float
iters : int or None
cenfunc : callable
varfunc : callable
maout : bool or ‘copy’
|
---|---|
Returns : | filtereddata : numpy.ndarray or numpy.masked.MaskedArray
mask : boolean array
|
Examples
This will generate random variates from a Gaussian distribution and return only the points that are within 2 sample standard deviation from the median:
>>> from astropy.tools.alg import sigma_clip
>>> from numpy.random import randn
>>> randvar = randn(10000)
>>> data,mask = sigma_clip(randvar, 2, 1)
This will clipping on a similar distribution, but for 3 sigma relative to the sample mean, will clip until converged, and produces a numpy.masked.MaskedArray:
>>> from astropy.tools.alg import sigma_clip
>>> from numpy.random import randn
>>> from numpy import mean
>>> randvar = randn(10000)
>>> maskedarr = sigma_clip(randvar, 3, None, mean, maout=True)