NDDataStats¶
- class astroimtools.stats.NDDataStats(nddata, sigma_clip=None, lower_bound=None, upper_bound=None, mask_value=None, mask_invalid=True)[source]¶
Bases:
objectClass to calculate (sigma-clipped) image statistics on NDData objects.
Set the
sigma_clipkeyword to perform sigma clipping.- Parameters:
- nddata
NDData NDData object containing the data array (and an optional mask) on which to calculate statistics. Masked pixels are excluded when computing the image statistics.
- sigma_clip
astropy.stats.SigmaClipinstance, optional A
SigmaClipobject that defines the sigma clipping parameters. IfNonethen no sigma clipping will be performed (default).- lower_boundfloat, optional
The minimum data value to include in the statistics. All pixel values less than
lower_boundwill be ignored.Nonemeans that no lower bound is applied (default).- upper_boundfloat, optional
The maximum data value to include in the statistics. All pixel values greater than
upper_boundwill be ignored.Nonemeans that no upper bound is applied (default).- mask_valuefloat, optional
A data value (e.g.,
0.0) to be masked.mask_valuewill be masked in addition to any inputmask.- mask_invalidbool, optional
If
True(the default), then any unmasked invalid values (e.g. NaN, inf) will be masked.
- nddata
Examples
>>> import numpy as np >>> from astropy.nddata import NDData >>> from astroimtools import NDDataStats >>> data = np.arange(10) >>> data[0] = 100. >>> nddata = NDData(data) >>> stats = NDDataStats(nddata) >>> stats.mean 14.5 >>> stats.std 28.605069480775605 >>> stats.mad_std 3.706505546264005 >>> from astropy.stats import SigmaClip >>> sigclip = SigmaClip(sigma=2.5) >>> stats = NDDataStats(nddata, sigma_clip=sigclip) >>> stats.mean 5.0 >>> stats.std 2.581988897471611 >>> stats.mad_std 2.965204437011204
Attributes Summary
The biweight location of the pixel values.
The biweight midvariance of the pixel values.
The kurtosis of the pixel values.
A robust standard deviation using the median absolute deviation (MAD).
The maximum pixel value.
The mean of pixel values.
The median of the pixel values.
The minimum pixel value.
The mode of the pixel values.
The number of good (unmasked/unclipped) pixels.
The number of rejected (masked/clipped) pixels.
The skew of the pixel values.
The standard deviation of the pixel values.
Attributes Documentation
- biweight_location¶
The biweight location of the pixel values.
- biweight_midvariance¶
The biweight midvariance of the pixel values.
- kurtosis¶
The kurtosis of the pixel values.
- mad_std¶
A robust standard deviation using the median absolute deviation (MAD). The MAD is defined as
median(abs(a - median(a))).The standard deviation estimator is given by:
\[\sigma \approx \frac{\textrm{MAD}}{\Phi^{-1}(3/4)} \approx 1.4826 \ \textrm{MAD}\]where \(\Phi^{-1}(P)\) is the normal inverse cumulative distribution function evaluated at probability \(P = 3/4\).
- max¶
The maximum pixel value.
- mean¶
The mean of pixel values.
- median¶
The median of the pixel values.
- min¶
The minimum pixel value.
- mode¶
The mode of the pixel values.
The mode is estimated simply as
(3 * median) - (2 * mean).
- npixels¶
The number of good (unmasked/unclipped) pixels.
- nrejected¶
The number of rejected (masked/clipped) pixels.
- skew¶
The skew of the pixel values.
- std¶
The standard deviation of the pixel values.