|
| __init__ (self, schema=None, **kwds) |
|
| run (self, table, exposure, doSmooth=True, sigma=None, clearMask=True, expId=None, background=None) |
|
| display (self, exposure, results, convolvedImage=None) |
|
| applyTempLocalBackground (self, exposure, middle, results) |
|
| clearMask (self, mask) |
|
| calculateKernelSize (self, sigma) |
|
| getPsf (self, exposure, sigma=None) |
|
| convolveImage (self, maskedImage, psf, doSmooth=True) |
|
| applyThreshold (self, middle, bbox, factor=1.0, factorNeg=None) |
|
| finalizeFootprints (self, mask, results, sigma, factor=1.0, factorNeg=None) |
|
| reEstimateBackground (self, maskedImage, backgrounds) |
|
| clearUnwantedResults (self, mask, results) |
|
| detectFootprints (self, exposure, doSmooth=True, sigma=None, clearMask=True, expId=None, background=None) |
|
| removeBadPixels (self, middle) |
|
| setPeakSignificance (self, exposure, footprints, threshold, negative=False) |
|
| makeThreshold (self, image, thresholdParity, factor=1.0) |
|
| updatePeaks (self, fpSet, image, threshold) |
|
| tempWideBackgroundContext (self, exposure) |
|
Detect peaks and footprints of sources in an image.
This task convolves the image with a Gaussian approximation to the PSF,
matched to the sigma of the input exposure, because this is separable and
fast. The PSF would have to be very non-Gaussian or non-circular for this
approximation to have a significant impact on the signal-to-noise of the
detected sources.
Parameters
----------
schema : `lsst.afw.table.Schema`
Schema object used to create the output `lsst.afw.table.SourceCatalog`
**kwds
Keyword arguments passed to `lsst.pipe.base.Task.__init__`
If schema is not None and configured for 'both' detections,
a 'flags.negative' field will be added to label detections made with a
negative threshold.
Notes
-----
This task can add fields to the schema, so any code calling this task must
ensure that these columns are indeed present in the input match list.
Definition at line 167 of file detection.py.
lsst.meas.algorithms.detection.SourceDetectionTask.applyThreshold |
( |
| self, |
|
|
| middle, |
|
|
| bbox, |
|
|
| factor = 1.0, |
|
|
| factorNeg = None ) |
Apply thresholds to the convolved image
Identifies `~lsst.afw.detection.Footprint`\s, both positive and negative.
The threshold can be modified by the provided multiplication
``factor``.
Parameters
----------
middle : `lsst.afw.image.MaskedImage`
Convolved image to threshold.
bbox : `lsst.geom.Box2I`
Bounding box of unconvolved image.
factor : `float`
Multiplier for the configured threshold.
factorNeg : `float` or `None`
Multiplier for the configured threshold for negative detection polarity.
If `None`, will be set equal to ``factor`` (i.e. equal to the factor used
for positive detection polarity).
Returns
-------
results : `lsst.pipe.base.Struct`
The `~lsst.pipe.base.Struct` contains:
``positive``
Positive detection footprints, if configured.
(`lsst.afw.detection.FootprintSet` or `None`)
``negative``
Negative detection footprints, if configured.
(`lsst.afw.detection.FootprintSet` or `None`)
``factor``
Multiplier for the configured threshold.
(`float`)
``factorNeg``
Multiplier for the configured threshold for negative detection polarity.
(`float`)
Definition at line 520 of file detection.py.
lsst.meas.algorithms.detection.SourceDetectionTask.convolveImage |
( |
| self, |
|
|
| maskedImage, |
|
|
| psf, |
|
|
| doSmooth = True ) |
Convolve the image with the PSF.
We convolve the image with a Gaussian approximation to the PSF,
because this is separable and therefore fast. It's technically a
correlation rather than a convolution, but since we use a symmetric
Gaussian there's no difference.
The convolution can be disabled with ``doSmooth=False``. If we do
convolve, we mask the edges as ``EDGE`` and return the convolved image
with the edges removed. This is because we can't convolve the edges
because the kernel would extend off the image.
Parameters
----------
maskedImage : `lsst.afw.image.MaskedImage`
Image to convolve.
psf : `lsst.afw.detection.Psf`
PSF to convolve with (actually with a Gaussian approximation
to it).
doSmooth : `bool`
Actually do the convolution? Set to False when running on
e.g. a pre-convolved image, or a mask plane.
Returns
-------
results : `lsst.pipe.base.Struct`
The `~lsst.pipe.base.Struct` contains:
``middle``
Convolved image, without the edges. (`lsst.afw.image.MaskedImage`)
``sigma``
Gaussian sigma used for the convolution. (`float`)
Definition at line 458 of file detection.py.
lsst.meas.algorithms.detection.SourceDetectionTask.detectFootprints |
( |
| self, |
|
|
| exposure, |
|
|
| doSmooth = True, |
|
|
| sigma = None, |
|
|
| clearMask = True, |
|
|
| expId = None, |
|
|
| background = None ) |
Detect footprints on an exposure.
Parameters
----------
exposure : `lsst.afw.image.Exposure`
Exposure to process; DETECTED{,_NEGATIVE} mask plane will be
set in-place.
doSmooth : `bool`, optional
If True, smooth the image before detection using a Gaussian
of width ``sigma``, or the measured PSF width of ``exposure``.
Set to False when running on e.g. a pre-convolved image, or a mask
plane.
sigma : `float`, optional
Gaussian Sigma of PSF (pixels); used for smoothing and to grow
detections; if `None` then measure the sigma of the PSF of the
``exposure``.
clearMask : `bool`, optional
Clear both DETECTED and DETECTED_NEGATIVE planes before running
detection.
expId : `dict`, optional
Exposure identifier; unused by this implementation, but used for
RNG seed by subclasses.
background : `lsst.afw.math.BackgroundList`, optional
Background that was already subtracted from the exposure; will be
modified in-place if ``reEstimateBackground=True``.
Returns
-------
results : `lsst.pipe.base.Struct`
A `~lsst.pipe.base.Struct` containing:
``positive``
Positive polarity footprints.
(`lsst.afw.detection.FootprintSet` or `None`)
``negative``
Negative polarity footprints.
(`lsst.afw.detection.FootprintSet` or `None`)
``numPos``
Number of footprints in positive or 0 if detection polarity was
negative. (`int`)
``numNeg``
Number of footprints in negative or 0 if detection polarity was
positive. (`int`)
``background``
Re-estimated background. `None` or the input ``background``
if ``reEstimateBackground==False``.
(`lsst.afw.math.BackgroundList`)
``factor``
Multiplication factor applied to the configured detection
threshold. (`float`)
Reimplemented in lsst.meas.algorithms.dynamicDetection.DynamicDetectionTask.
Definition at line 709 of file detection.py.
lsst.meas.algorithms.detection.SourceDetectionTask.display |
( |
| self, |
|
|
| exposure, |
|
|
| results, |
|
|
| convolvedImage = None ) |
Display detections if so configured
Displays the ``exposure`` in frame 0, overlays the detection peaks.
Requires that ``lsstDebug`` has been set up correctly, so that
``lsstDebug.Info("lsst.meas.algorithms.detection")`` evaluates `True`.
If the ``convolvedImage`` is non-`None` and
``lsstDebug.Info("lsst.meas.algorithms.detection") > 1``, the
``convolvedImage`` will be displayed in frame 1.
Parameters
----------
exposure : `lsst.afw.image.Exposure`
Exposure to display, on which will be plotted the detections.
results : `lsst.pipe.base.Struct`
Results of the 'detectFootprints' method, containing positive and
negative footprints (which contain the peak positions that we will
plot). This is a `Struct` with ``positive`` and ``negative``
elements that are of type `lsst.afw.detection.FootprintSet`.
convolvedImage : `lsst.afw.image.Image`, optional
Convolved image used for thresholding.
Definition at line 298 of file detection.py.
lsst.meas.algorithms.detection.SourceDetectionTask.finalizeFootprints |
( |
| self, |
|
|
| mask, |
|
|
| results, |
|
|
| sigma, |
|
|
| factor = 1.0, |
|
|
| factorNeg = None ) |
Finalize the detected footprints.
Grow the footprints, set the ``DETECTED`` and ``DETECTED_NEGATIVE``
mask planes, and log the results.
``numPos`` (number of positive footprints), ``numPosPeaks`` (number
of positive peaks), ``numNeg`` (number of negative footprints),
``numNegPeaks`` (number of negative peaks) entries are added to the
``results`` struct.
Parameters
----------
mask : `lsst.afw.image.Mask`
Mask image on which to flag detected pixels.
results : `lsst.pipe.base.Struct`
Struct of detection results, including ``positive`` and
``negative`` entries; modified.
sigma : `float`
Gaussian sigma of PSF.
factor : `float`
Multiplier for the configured threshold. Note that this is only
used here for logging purposes.
factorNeg : `float` or `None`
Multiplier used for the negative detection polarity threshold.
If `None`, a factor equal to ``factor`` (i.e. equal to the one used
for positive detection polarity) is assumed. Note that this is only
used here for logging purposes.
Definition at line 586 of file detection.py.
lsst.meas.algorithms.detection.SourceDetectionTask.getPsf |
( |
| self, |
|
|
| exposure, |
|
|
| sigma = None ) |
Create a single Gaussian PSF for an exposure.
If ``sigma`` is provided, we make a `~lsst.afw.detection.GaussianPsf`
with that, otherwise use the sigma from the psf of the ``exposure`` to
make the `~lsst.afw.detection.GaussianPsf`.
Parameters
----------
exposure : `lsst.afw.image.Exposure`
Exposure from which to retrieve the PSF.
sigma : `float`, optional
Gaussian sigma to use if provided.
Returns
-------
psf : `lsst.afw.detection.GaussianPsf`
PSF to use for detection.
Raises
------
RuntimeError
Raised if ``sigma`` is not provided and ``exposure`` does not
contain a ``Psf`` object.
Definition at line 424 of file detection.py.
lsst.meas.algorithms.detection.SourceDetectionTask.run |
( |
| self, |
|
|
| table, |
|
|
| exposure, |
|
|
| doSmooth = True, |
|
|
| sigma = None, |
|
|
| clearMask = True, |
|
|
| expId = None, |
|
|
| background = None ) |
Detect sources and return catalog(s) of detections.
Parameters
----------
table : `lsst.afw.table.SourceTable`
Table object that will be used to create the SourceCatalog.
exposure : `lsst.afw.image.Exposure`
Exposure to process; DETECTED mask plane will be set in-place.
doSmooth : `bool`, optional
If True, smooth the image before detection using a Gaussian of width
``sigma``, or the measured PSF width. Set to False when running on
e.g. a pre-convolved image, or a mask plane.
sigma : `float`, optional
Sigma of PSF (pixels); used for smoothing and to grow detections;
if None then measure the sigma of the PSF of the exposure
clearMask : `bool`, optional
Clear DETECTED{,_NEGATIVE} planes before running detection.
expId : `int`, optional
Exposure identifier; unused by this implementation, but used for
RNG seed by subclasses.
background : `lsst.afw.math.BackgroundList`, optional
Background that was already subtracted from the exposure; will be
modified in-place if ``reEstimateBackground=True``.
Returns
-------
result : `lsst.pipe.base.Struct`
The `~lsst.pipe.base.Struct` contains:
``sources``
Detected sources on the exposure.
(`lsst.afw.table.SourceCatalog`)
``positive``
Positive polarity footprints.
(`lsst.afw.detection.FootprintSet` or `None`)
``negative``
Negative polarity footprints.
(`lsst.afw.detection.FootprintSet` or `None`)
``numPos``
Number of footprints in positive or 0 if detection polarity was
negative. (`int`)
``numNeg``
Number of footprints in negative or 0 if detection polarity was
positive. (`int`)
``background``
Re-estimated background. `None` if
``reEstimateBackground==False``.
(`lsst.afw.math.BackgroundList`)
``factor``
Multiplication factor applied to the configured detection
threshold. (`float`)
Raises
------
ValueError
Raised if flags.negative is needed, but isn't in table's schema.
lsst.pipe.base.TaskError
Raised if sigma=None, doSmooth=True and the exposure has no PSF.
Notes
-----
If you want to avoid dealing with Sources and Tables, you can use
`detectFootprints()` to just get the
`~lsst.afw.detection.FootprintSet`\s.
Definition at line 215 of file detection.py.
lsst.meas.algorithms.detection.SourceDetectionTask.setPeakSignificance |
( |
| self, |
|
|
| exposure, |
|
|
| footprints, |
|
|
| threshold, |
|
|
| negative = False ) |
Set the significance of each detected peak to the pixel value divided
by the appropriate standard-deviation for ``config.thresholdType``.
Only sets significance for "stdev" and "pixel_stdev" thresholdTypes;
we leave it undefined for "value" and "variance" as it does not have a
well-defined meaning in those cases.
Parameters
----------
exposure : `lsst.afw.image.Exposure`
Exposure that footprints were detected on, likely the convolved,
local background-subtracted image.
footprints : `lsst.afw.detection.FootprintSet`
Footprints detected on the image.
threshold : `lsst.afw.detection.Threshold`
Threshold used to find footprints.
negative : `bool`, optional
Are we calculating for negative sources?
Definition at line 810 of file detection.py.