detect_threshold#
- photutils.segmentation.detect_threshold(data, nsigma, *, background=None, error=None, mask=None, sigma_clip=SigmaClip(sigma=3.0, sigma_lower=3.0, sigma_upper=3.0, maxiters=10, cenfunc='median', stdfunc='std', grow=False))[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.
- nsigmafloat
The number of standard deviations per pixel above the
background
for 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
.background
may either be a scalar value or a 2D array with the same shape as the inputdata
. If the inputdata
has been background-subtracted, then setbackground
to0.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
.error
should include all sources of “background” error, but exclude the Poisson error of the sources. Iferror
is 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 aTrue
value indicates the corresponding element ofdata
is masked. Masked pixels are ignored when computing the image background statistics.- sigma_clip
astropy.stats.SigmaClip
instance, optional A
SigmaClip
object that defines the sigma clipping parameters.
- data2D
- Returns:
- threshold2D
ndarray
A 2D image with the same shape (and units) as
data
containing the pixel-wise threshold values.
- threshold2D
See also
Notes
The
mask
andsigma_clip
inputs are used only if it is necessary to estimatebackground
orerror
using sigma-clipped background statistics. Ifbackground
anderror
are both input, thenmask
andsigma_clip
are ignored.