MMMBackground#
- class photutils.background.MMMBackground(sigma_clip=<default: SigmaClip(sigma=3.0, maxiters=10)>)[source]#
Bases:
ModeEstimatorBackgroundClass to calculate the background in an array using the DAOPHOT MMM algorithm.
The background is calculated using a mode estimator of the form
(3 * median) - (2 * mean).- Parameters:
Examples
>>> import numpy as np >>> from astropy.stats import SigmaClip >>> from photutils.background import MMMBackground >>> data = np.arange(100.0) >>> sigma_clip = SigmaClip(sigma=3.0) >>> bkg = MMMBackground(sigma_clip=sigma_clip)
The background value can be calculated by using the
calc_backgroundmethod, e.g.:>>> bkg_value = bkg.calc_background(data) >>> print(bkg_value) 49.5
Alternatively, the background value can be calculated by calling the class instance as a function, e.g.:
>>> bkg_value = bkg(data) >>> print(bkg_value) 49.5
Methods Summary
__call__(data[, axis, masked])Call self as a function.
calc_background(data[, axis, masked])Calculate the background value.
Methods Documentation
- __call__(data, axis=None, masked=False)#
Call self as a function.
- calc_background(data, axis=None, masked=False)#
Calculate the background value.
- Parameters:
- data
ndarrayorMaskedArray The array for which to calculate the background value.
- axisint, tuple of int, or
None, optional The array axis along which the background is calculated. If
None, then the entire array is used.- maskedbool, optional
If
True, then aMaskedArrayis returned. IfFalse, then andarrayis returned, where masked values have a value of NaN. The default isFalse.
- data
- Returns:
- resultfloat,
ndarray, orMaskedArray The calculated background value. If
maskedisFalse, then andarrayis returned, otherwise aMaskedArrayis returned. A scalar result is always returned as a NumPy floating-point scalar. The result isfloat32orfloat64, depending on the dtype of the input data and on the sigma clipping. For example, sigma-clipped integer data give afloat32result.
- resultfloat,