ModeEstimatorBackground

class photutils.background.ModeEstimatorBackground(median_factor=3.0, mean_factor=2.0, **kwargs)[source]

Bases: BackgroundBase

Class to calculate the background in an array using a mode estimator of the form (median_factor * median) - (mean_factor * mean).

Parameters:
median_factorfloat, optional

The multiplicative factor for the data median. Defaults to 3.

mean_factorfloat, optional

The multiplicative factor for the data mean. Defaults to 2.

sigma_clipastropy.stats.SigmaClip object, optional

A SigmaClip object that defines the sigma clipping parameters. If None then no sigma clipping will be performed. The default is to perform sigma clipping with sigma=3.0 and maxiters=5.

Examples

>>> from astropy.stats import SigmaClip
>>> from photutils.background import ModeEstimatorBackground
>>> data = np.arange(100)
>>> sigma_clip = SigmaClip(sigma=3.0)
>>> bkg = ModeEstimatorBackground(median_factor=3.0, mean_factor=2.0,
...                               sigma_clip=sigma_clip)

The background value can be calculated by using the calc_background method, 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)[source]

Calculate the background value.

Parameters:
dataarray_like or MaskedArray

The array for which to calculate the background value.

axisint 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 a MaskedArray is returned. If False, then a ndarray is returned, where masked values have a value of NaN. The default is False.

Returns:
resultfloat, ndarray, or MaskedArray

The calculated background value. If masked is False, then a ndarray is returned, otherwise a MaskedArray is returned. A scalar result is always returned as a float.