lsst.meas.algorithms g10988951d7+eadaf988e0
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Static Protected Attributes | List of all members
lsst.meas.algorithms.dynamicDetection.DynamicDetectionTask Class Reference
Inheritance diagram for lsst.meas.algorithms.dynamicDetection.DynamicDetectionTask:
lsst.meas.algorithms.detection.SourceDetectionTask

Public Member Functions

 __init__ (self, *args, **kwargs)
 
 calculateThreshold (self, exposure, seed, sigma=None, minFractionSourcesFactor=1.0, isBgTweak=False)
 
 detectFootprints (self, exposure, doSmooth=True, sigma=None, clearMask=True, expId=None, background=None)
 
 tweakBackground (self, exposure, bgLevel, bgList=None)
 

Public Attributes

 skySchema
 
 skyMeasurement
 

Static Public Attributes

 ConfigClass = DynamicDetectionConfig
 

Protected Member Functions

 _computeBrightDetectionMask (self, maskedImage, convolveResults)
 

Static Protected Attributes

str _DefaultName = "dynamicDetection"
 

Detailed Description

Detection of sources on an image with a dynamic threshold

We first detect sources using a lower threshold than normal (see config
parameter ``prelimThresholdFactor``) in order to identify good sky regions
(configurable ``skyObjects``). Then we perform forced PSF photometry on
those sky regions. Using those PSF flux measurements and estimated errors,
we set the threshold so that the stdev of the measurements matches the
median estimated error.

Besides the usual initialisation of configurables, we also set up
the forced measurement which is deliberately not represented in
this Task's configuration parameters because we're using it as
part of the algorithm and we don't want to allow it to be modified.

Definition at line 72 of file dynamicDetection.py.

Constructor & Destructor Documentation

◆ __init__()

lsst.meas.algorithms.dynamicDetection.DynamicDetectionTask.__init__ ( self,
* args,
** kwargs )

Reimplemented from lsst.meas.algorithms.detection.SourceDetectionTask.

Definition at line 90 of file dynamicDetection.py.

Member Function Documentation

◆ _computeBrightDetectionMask()

lsst.meas.algorithms.dynamicDetection.DynamicDetectionTask._computeBrightDetectionMask ( self,
maskedImage,
convolveResults )
protected
Perform an initial bright source detection pass.

Perform an initial bright object detection pass using a high detection
threshold. The footprints in this pass are grown significantly more
than is typical to account for wings around bright sources.  The
negative polarity detections in this pass help in masking severely
over-subtracted regions.

A maximum fraction of masked pixel from this pass is ensured via
the config ``brightMaskFractionMax``.  If the masked pixel fraction is
above this value, the detection thresholds here are increased by
``bisectFactor`` in a while loop until the detected masked fraction
falls below this value.

Parameters
----------
maskedImage : `lsst.afw.image.MaskedImage`
    Masked image on which to run the detection.
convolveResults :  `lsst.pipe.base.Struct`
    The results of the self.convolveImage function with attributes:

    ``middle``
        Convolved image, without the edges
       (`lsst.afw.image.MaskedImage`).
    ``sigma``
        Gaussian sigma used for the convolution (`float`).

Returns
-------
brightDetectedMask : `numpy.ndarray`
    Boolean array representing the union of the bright detection pass
    DETECTED and DETECTED_NEGATIVE masks.

Definition at line 411 of file dynamicDetection.py.

◆ calculateThreshold()

lsst.meas.algorithms.dynamicDetection.DynamicDetectionTask.calculateThreshold ( self,
exposure,
seed,
sigma = None,
minFractionSourcesFactor = 1.0,
isBgTweak = False )
Calculate new threshold

This is the main functional addition to the vanilla
`SourceDetectionTask`.

We identify sky objects and perform forced PSF photometry on
them. Using those PSF flux measurements and estimated errors,
we set the threshold so that the stdev of the measurements
matches the median estimated error.

Parameters
----------
exposure : `lsst.afw.image.Exposure`
    Exposure on which we're detecting sources.
seed : `int`
    RNG seed to use for finding sky objects.
sigma : `float`, optional
    Gaussian sigma of smoothing kernel; if not provided,
    will be deduced from the exposure's PSF.
minFractionSourcesFactor : `float`
    Change the fraction of required sky sources from that set in
    ``self.config.minFractionSources`` by this factor.  NOTE: this
    is intended for use in the background tweak pass (the detection
    threshold is much lower there, so many more pixels end up marked
    as DETECTED or DETECTED_NEGATIVE, leaving less room for sky
    object placement).
isBgTweak : `bool`
   Set to ``True`` for the background tweak pass (for more helpful
   log messages).

Returns
-------
result : `lsst.pipe.base.Struct`
    Result struct with components:

    ``multiplicative``
        Multiplicative factor to be applied to the
        configured detection threshold (`float`).
    ``additive``
        Additive factor to be applied to the background
        level (`float`).

Raises
------
NoWorkFound
    Raised if the number of good sky sources found is less than the
    minimum fraction
    (``self.config.minFractionSources``*``minFractionSourcesFactor``)
    of the number requested (``self.skyObjects.config.nSources``).

Definition at line 106 of file dynamicDetection.py.

◆ detectFootprints()

lsst.meas.algorithms.dynamicDetection.DynamicDetectionTask.detectFootprints ( self,
exposure,
doSmooth = True,
sigma = None,
clearMask = True,
expId = None,
background = None )
Detect footprints with a dynamic threshold

This varies from the vanilla ``detectFootprints`` method because we
do detection three times: first with a high threshold to detect
"bright" (both positive and negative, the latter to identify very
over-subtracted regions) sources for which we grow the DETECTED and
DETECTED_NEGATIVE masks significantly to account for wings.  Second,
with a low threshold to mask all non-empty regions of the image. These
two masks are combined and used to identify regions of sky
uncontaminated by objects.  A final round of detection is then done
with the new calculated threshold.

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``.
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 : `int`, optional
    Exposure identifier, used as a seed for the random number
    generator. If absent, the seed will be the sum of the image.
background : `lsst.afw.math.BackgroundList`, optional
    Background that was already subtracted from the exposure; will be
    modified in-place if ``reEstimateBackground=True``.

Returns
-------
resutls : `lsst.pipe.base.Struct`
    The results `~lsst.pipe.base.Struct` contains:

    ``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`)
    ``prelim``
        Results from preliminary detection pass.
        (`lsst.pipe.base.Struct`)

Reimplemented from lsst.meas.algorithms.detection.SourceDetectionTask.

Definition at line 230 of file dynamicDetection.py.

◆ tweakBackground()

lsst.meas.algorithms.dynamicDetection.DynamicDetectionTask.tweakBackground ( self,
exposure,
bgLevel,
bgList = None )
Modify the background by a constant value

Parameters
----------
exposure : `lsst.afw.image.Exposure`
    Exposure for which to tweak background.
bgLevel : `float`
    Background level to remove
bgList : `lsst.afw.math.BackgroundList`, optional
    List of backgrounds to append to.

Returns
-------
bg : `lsst.afw.math.BackgroundMI`
    Constant background model.

Definition at line 383 of file dynamicDetection.py.

Member Data Documentation

◆ _DefaultName

str lsst.meas.algorithms.dynamicDetection.DynamicDetectionTask._DefaultName = "dynamicDetection"
staticprotected

Definition at line 88 of file dynamicDetection.py.

◆ ConfigClass

lsst.meas.algorithms.dynamicDetection.DynamicDetectionTask.ConfigClass = DynamicDetectionConfig
static

Definition at line 87 of file dynamicDetection.py.

◆ skyMeasurement

lsst.meas.algorithms.dynamicDetection.DynamicDetectionTask.skyMeasurement

Definition at line 103 of file dynamicDetection.py.

◆ skySchema

lsst.meas.algorithms.dynamicDetection.DynamicDetectionTask.skySchema

Definition at line 102 of file dynamicDetection.py.


The documentation for this class was generated from the following file: