|
def | __init__ (self, schema=None, **kwds) |
|
def | run (self, table, exposure, doSmooth=True, sigma=None, clearMask=True, expId=None) |
|
def | display (self, exposure, results, convolvedImage=None) |
|
def | applyTempLocalBackground (self, exposure, middle, results) |
|
def | clearMask (self, mask) |
|
def | calculateKernelSize (self, sigma) |
|
def | getPsf (self, exposure, sigma=None) |
|
def | convolveImage (self, maskedImage, psf, doSmooth=True) |
|
def | applyThreshold (self, middle, bbox, factor=1.0) |
|
def | finalizeFootprints (self, mask, results, sigma, factor=1.0) |
|
def | reEstimateBackground (self, maskedImage, backgrounds) |
|
def | clearUnwantedResults (self, mask, results) |
|
def | detectFootprints (self, exposure, doSmooth=True, sigma=None, clearMask=True, expId=None) |
|
def | setPeakSignificance (self, exposure, footprints, threshold, negative=False) |
|
def | makeThreshold (self, image, thresholdParity, factor=1.0) |
|
def | updatePeaks (self, fpSet, image, threshold) |
|
def | tempWideBackgroundContext (self, exposure) |
|
Create the detection task. Most arguments are simply passed onto pipe.base.Task.
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.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 162 of file detection.py.
def lsst.meas.algorithms.detection.SourceDetectionTask.applyThreshold |
( |
|
self, |
|
|
|
middle, |
|
|
|
bbox, |
|
|
|
factor = 1.0 |
|
) |
| |
Apply thresholds to the convolved image
Identifies ``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.
Return Struct contents
----------------------
positive : `lsst.afw.detection.FootprintSet` or `None`
Positive detection footprints, if configured.
negative : `lsst.afw.detection.FootprintSet` or `None`
Negative detection footprints, if configured.
factor : `float`
Multiplier for the configured threshold.
Definition at line 479 of file detection.py.
def 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.
Return Struct contents
----------------------
middle : `lsst.afw.image.MaskedImage`
Convolved image, without the edges.
sigma : `float`
Gaussian sigma used for the convolution.
Definition at line 418 of file detection.py.
def lsst.meas.algorithms.detection.SourceDetectionTask.detectFootprints |
( |
|
self, |
|
|
|
exposure, |
|
|
|
doSmooth = True , |
|
|
|
sigma = None , |
|
|
|
clearMask = True , |
|
|
|
expId = 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.
Return Struct contents
----------------------
positive : `lsst.afw.detection.FootprintSet`
Positive polarity footprints (may be `None`)
negative : `lsst.afw.detection.FootprintSet`
Negative polarity footprints (may be `None`)
numPos : `int`
Number of footprints in positive or 0 if detection polarity was
negative.
numNeg : `int`
Number of footprints in negative or 0 if detection polarity was
positive.
background : `lsst.afw.math.BackgroundList`
Re-estimated background. `None` if
``reEstimateBackground==False``.
factor : `float`
Multiplication factor applied to the configured detection
threshold.
Reimplemented in lsst.meas.algorithms.dynamicDetection.DynamicDetectionTask.
Definition at line 644 of file detection.py.
def 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 265 of file detection.py.
def lsst.meas.algorithms.detection.SourceDetectionTask.finalizeFootprints |
( |
|
self, |
|
|
|
mask, |
|
|
|
results, |
|
|
|
sigma, |
|
|
|
factor = 1.0 |
|
) |
| |
Finalize the detected footprints
Grows the footprints, sets the ``DETECTED`` and ``DETECTED_NEGATIVE``
mask planes, and logs 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
detection results.
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.
Definition at line 529 of file detection.py.
def lsst.meas.algorithms.detection.SourceDetectionTask.run |
( |
|
self, |
|
|
|
table, |
|
|
|
exposure, |
|
|
|
doSmooth = True , |
|
|
|
sigma = None , |
|
|
|
clearMask = True , |
|
|
|
expId = None |
|
) |
| |
Run source detection and create a SourceCatalog 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`
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`
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`
Clear DETECTED{,_NEGATIVE} planes before running detection.
expId : `int`
Exposure identifier; unused by this implementation, but used for
RNG seed by subclasses.
Returns
-------
result : `lsst.pipe.base.Struct`
``sources``
The detected sources (`lsst.afw.table.SourceCatalog`)
``fpSets``
The result resturned by `detectFootprints`
(`lsst.pipe.base.Struct`).
Raises
------
ValueError
If flags.negative is needed, but isn't in table's schema.
lsst.pipe.base.TaskError
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 205 of file detection.py.
def 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 720 of file detection.py.