detect_threshold#
- photutils.segmentation.detect_threshold(data, n_sigma, *, background=None, error=None, mask=None, sigma_clip=<default: SigmaClip(sigma=3.0, maxiters=10)>)[source]#
Calculate a pixel-wise threshold image that can be used to detect sources.
This is a simple convenience function that uses sigma-clipped statistics to compute a scalar background and noise estimate. In general, one should perform more sophisticated estimates, e.g., using
Background2D.- Parameters:
- data2D
ndarray The 2D array of the image.
- n_sigmafloat
The number of standard deviations per pixel above the
backgroundfor which to consider a pixel as possibly being part of a source.- backgroundfloat or 2D
ndarray, optional The background value(s) of the input
data.backgroundmay either be a scalar value or a 2D array with the same shape as the inputdata. If the inputdatahas been background-subtracted, then setbackgroundto0.0(this should be typical). IfNone, then a scalar background value will be estimated as the sigma-clipped image mean.- errorfloat or 2D
ndarray, optional The Gaussian 1-sigma standard deviation of the background noise in
data.errorshould include all sources of “background” error, but exclude the Poisson error of the sources. Iferroris a 2D image, then it should represent the 1-sigma background error in each pixel ofdata. IfNone, then a scalar background rms value will be estimated as the sigma-clipped image standard deviation.- mask2D bool
ndarray, optional A boolean mask with the same shape as
data, where aTruevalue indicates the corresponding element ofdatais masked. Masked pixels are ignored when computing the image background statistics.- sigma_clip
astropy.stats.SigmaCliporNone, optional A
SigmaClipobject that defines the sigma clipping parameters. IfNonethen no sigma clipping will be performed.
- data2D
- Returns:
- threshold2D
ndarray A 2D image with the same shape (and units) as
datacontaining the pixel-wise threshold values.
- threshold2D
See also
Notes
The
maskandsigma_clipinputs are used only if it is necessary to estimatebackgroundorerrorusing sigma-clipped background statistics. Ifbackgroundanderrorare both input, thenmaskandsigma_clipare ignored.