lsst.pipe.tasks g253578fa50+c1a9b1f270
Loading...
Searching...
No Matches
lsst.pipe.tasks.measurementDriver.MultiBandMeasurementDriverTask Class Reference
Inheritance diagram for lsst.pipe.tasks.measurementDriver.MultiBandMeasurementDriverTask:
lsst.pipe.tasks.measurementDriver.MeasurementDriverBaseTask

Public Member Functions

 __init__ (self, *args, **kwargs)
 
pipeBase.Struct run (self, afwImage.MultibandExposure|list[afwImage.Exposure]|afwImage.Exposure mExposure, afwImage.MultibandExposure|list[afwImage.Exposure]|afwImage.Exposure|None mDeconvolved=None, str|None refBand=None, list[str]|None bands=None, afwTable.SourceCatalog catalog=None, measBase.IdGenerator idGenerator=None)
 
 __setattr__ (self, name, value)
 

Public Attributes

scarlet.io.LsstScarletModelData modelData
 
afwTable.SchemaMapper schema = schema
 
 peakSchema = peakSchema
 
afwTable.SchemaMapper mapper
 
measAlgorithms.ScaleVarianceTask scaleVariance
 
measAlgorithms.SourceDetectionTask detection
 
measDeblender.SourceDeblendTask|scarlet.ScarletDeblendTask deblend
 
measBase.SingleFrameMeasurementTask|measBase.ForcedMeasurementTask measurement
 
measBase.ApplyApCorrTask applyApCorr
 
measBase.CatalogCalculationTask catalogCalculation
 
afwTable.Schema initSchema
 
 config
 

Static Public Attributes

 ConfigClass = MeasurementDriverBaseConfig
 

Protected Member Functions

tuple[afwImage.MultibandExposure, afwImage.MultibandExposure, str, list[str]|None] _ensureValidInputs (self, afwImage.MultibandExposure|list[afwImage.Exposure]|afwImage.Exposure mExposure, afwImage.MultibandExposure|list[afwImage.Exposure]|afwImage.Exposure|None mDeconvolved, str|None refBand, list[str]|None bands, afwTable.SourceCatalog|None catalog=None)
 
tuple[dict[str, afwTable.SourceCatalog], scarlet.io.LsstScarletModelData] _deblendSources (self, afwImage.MultibandExposure mExposure, afwImage.MultibandExposure|None mDeconvolved, afwTable.SourceCatalog catalog, str refBand)
 
afwImage.MultibandExposure _buildMultibandExposure (self, afwImage.MultibandExposure|list[afwImage.Exposure]|afwImage.Exposure mExposureData, list[str]|None bands)
 
 _initializeSchema (self, afwTable.SourceCatalog catalog=None)
 
 _addCoordErrorFieldsIfMissing (self, afwTable.Schema schema)
 
 _makeSubtasks (self)
 
afwTable.SourceCatalog|None _prepareSchemaAndSubtasks (self, afwTable.SourceCatalog|None catalog)
 
 _scaleVariance (self, afwImage.Exposure exposure, str band="a single")
 
afwTable.SourceCatalog|dict[str, afwTable.SourceCatalog] _toContiguous (self, afwTable.SourceCatalog|dict[str, afwTable.SourceCatalog] catalog)
 
afwTable.SourceCatalog _updateCatalogSchema (self, afwTable.SourceCatalog catalog)
 
tuple[afwTable.SourceCatalog, afwMath.BackgroundList] _detectSources (self, afwImage.Exposure|afwImage.MultibandExposure exposure, measBase.IdGenerator idGenerator)
 
 _measureSources (self, afwImage.Exposure exposure, afwTable.SourceCatalog catalog, measBase.IdGenerator idGenerator, afwTable.SourceCatalog|None refCat=None)
 
 _applyApCorr (self, afwImage.Exposure exposure, afwTable.SourceCatalog catalog, measBase.IdGenerator idGenerator)
 
 _runCatalogCalculation (self, afwTable.SourceCatalog catalog)
 
afwTable.SourceCatalog _processCatalog (self, afwImage.Exposure exposure, afwTable.SourceCatalog catalog, measBase.IdGenerator idGenerator, str band="a single", afwTable.SourceCatalog|None refCat=None)
 

Static Protected Attributes

str _DefaultName = "measurementDriverBase"
 
str _Deblender = ""
 

Detailed Description

Mid-level driver for processing multi-band data.

The default behavior is to run detection on the reference band, use all
available bands for deblending, and then process everything downstream
separately for each band making per-band catalogs unless configured
otherwise. This subclass provides functionality for handling a singe-band
exposure and a list of single-band exposures in addition to a standard
multi-band exposure.

Examples
--------
Here is an example of how to use this class to run variance scaling,
detection, deblending, measurement, and aperture correction on a multi-band
exposure:

>>> from lsst.afw.image import MultibandExposure
>>> from lsst.pipe.tasks.measurementDriver import (
...     MultiBandMeasurementDriverConfig,
...     MultiBandMeasurementDriverTask,
... )
>>> import lsst.meas.extensions.shapeHSM  # To register its plugins
>>> config = MultiBandMeasurementDriverConfig()
>>> config.doScaleVariance = True
>>> config.doDetect = True
>>> config.doDeblend = True
>>> config.doMeasure = True
>>> config.doApCorr = True
>>> config.scaleVariance.background.binSize = 64
>>> config.detection.thresholdValue = 5.5
>>> config.deblend.minSNR = 42.0
>>> config.deblend.maxIter = 20
>>> config.measurement.plugins.names |= [
...     "base_SdssCentroid",
...     "base_SdssShape",
...     "ext_shapeHSM_HsmSourceMoments",
... ]
>>> config.measurement.slots.psfFlux = None
>>> config.measurement.doReplaceWithNoise = False
>>> config.applyApCorr.doFlagApCorrFailures = False
>>> mExposure = MultibandExposure.fromButler(
...     butler, ["g", "r", "i"], "deepCoadd_calexp", ...
... )
>>> driver = MultiBandMeasurementDriverTask(config=config)
>>> results = driver.run(mExposure, "r")
>>> for band, catalog in results.catalogs.items():
...     catalog.writeFits(f"meas_catalog_{band}.fits")

Definition at line 925 of file measurementDriver.py.

Constructor & Destructor Documentation

◆ __init__()

lsst.pipe.tasks.measurementDriver.MultiBandMeasurementDriverTask.__init__ ( self,
* args,
** kwargs )

Definition at line 978 of file measurementDriver.py.

Member Function Documentation

◆ __setattr__()

lsst.pipe.tasks.measurementDriver.MeasurementDriverBaseTask.__setattr__ ( self,
name,
value )
inherited
Prevent external modifications of the initial Schema.

Definition at line 196 of file measurementDriver.py.

◆ _addCoordErrorFieldsIfMissing()

lsst.pipe.tasks.measurementDriver.MeasurementDriverBaseTask._addCoordErrorFieldsIfMissing ( self,
afwTable.Schema schema )
protectedinherited
Add coordinate error fields to the schema in-place if they are not
already present.

Parameters
----------
schema :
    Schema to be checked for coordinate error fields.

Definition at line 292 of file measurementDriver.py.

◆ _applyApCorr()

lsst.pipe.tasks.measurementDriver.MeasurementDriverBaseTask._applyApCorr ( self,
afwImage.Exposure exposure,
afwTable.SourceCatalog catalog,
measBase.IdGenerator idGenerator )
protectedinherited
Apply aperture corrections to the catalog.

Parameters
----------
exposure :
    Exposure on which to apply aperture corrections.
catalog :
    Catalog to be corrected using the aperture correction map from
    the exposure.
idGenerator :
    Generator for unique source IDs.

Definition at line 541 of file measurementDriver.py.

◆ _buildMultibandExposure()

afwImage.MultibandExposure lsst.pipe.tasks.measurementDriver.MultiBandMeasurementDriverTask._buildMultibandExposure ( self,
afwImage.MultibandExposure | list[afwImage.Exposure] | afwImage.Exposure mExposureData,
list[str] | None bands )
protected
Convert a single-band exposure or a list of single-band exposures to
a `MultibandExposure` if not already of that type.

No conversion will be done if ``mExposureData`` is already a
`MultibandExposure` except it will be subsetted to the bands provided.

Parameters
----------
mExposureData :
    Input multi-band data.
bands :
    List of bands associated with the exposures in ``mExposure``. Only
    required if ``mExposure`` is a list of single-band exposures. If
    provided while ``mExposureData`` is a ``MultibandExposure``, it
    will be used to select a specific subset of bands from the
    available ones.

Returns
-------
mExposure :
    Converted multi-band exposure.

Definition at line 1337 of file measurementDriver.py.

◆ _deblendSources()

tuple[dict[str, afwTable.SourceCatalog], scarlet.io.LsstScarletModelData] lsst.pipe.tasks.measurementDriver.MultiBandMeasurementDriverTask._deblendSources ( self,
afwImage.MultibandExposure mExposure,
afwImage.MultibandExposure | None mDeconvolved,
afwTable.SourceCatalog catalog,
str refBand )
protected
Run multi-band deblending given a multi-band exposure and a catalog.

Parameters
----------
mExposure :
    Multi-band exposure on which to run the deblending algorithm.
mDeconvolved :
    Multi-band deconvolved exposure to use for deblending. If None,
    the deblender will create it internally using the provided
    ``mExposure``.
catalog :
    Catalog containing sources to be deblended.
refBand :
    Reference band used for detection or the band to use for
    measurements if `measureOnlyInRefBand` is enabled.

Returns
-------
catalogs :
    Dictionary of catalogs containing the deblended sources. If
    `measureOnlyInRefBand` is enabled, this will only contain the
    reference-band catalog; otherwise, it will contain a catalog for
    each band.
modelData :
    Multiband scarlet models produced during deblending.

Reimplemented from lsst.pipe.tasks.measurementDriver.MeasurementDriverBaseTask.

Definition at line 1270 of file measurementDriver.py.

◆ _detectSources()

tuple[afwTable.SourceCatalog, afwMath.BackgroundList] lsst.pipe.tasks.measurementDriver.MeasurementDriverBaseTask._detectSources ( self,
afwImage.Exposure | afwImage.MultibandExposure exposure,
measBase.IdGenerator idGenerator )
protectedinherited
Run the detection subtask to identify sources in the image.

Parameters
----------
exposure :
    Exposure on which to run the detection algorithm.
idGenerator :
    Generator for unique source IDs.

Returns
-------
catalog :
    A catalog containing detected sources.
backgroundList :
    A list of background models obtained from the detection process,
    if available.

Definition at line 458 of file measurementDriver.py.

◆ _ensureValidInputs()

tuple[afwImage.MultibandExposure, afwImage.MultibandExposure, str, list[str] | None] lsst.pipe.tasks.measurementDriver.MultiBandMeasurementDriverTask._ensureValidInputs ( self,
afwImage.MultibandExposure | list[afwImage.Exposure] | afwImage.Exposure mExposure,
afwImage.MultibandExposure | list[afwImage.Exposure] | afwImage.Exposure | None mDeconvolved,
str | None refBand,
list[str] | None bands,
afwTable.SourceCatalog | None catalog = None )
protected
Perform validation and adjustments of inputs without heavy
computation.

Parameters
----------
mExposure :
    Multi-band data to be processed by the driver task.
mDeconvolved :
    Multi-band deconvolved data to be processed by the driver task.
refBand :
    Reference band to use for detection.
bands :
    List of bands associated with the exposures in ``mExposure``.
catalog :
    Catalog to be extended by the driver task.

Returns
-------
mExposure :
    Multi-band exposure to be processed by the driver task. If the
    input was not already a `MultibandExposure` (optionally with the
    relevant ``bands``), it is converted into one and returned
    here; otherwise, the original input is returned unchanged.
mDeconvolved :
    Multi-band deconvolved exposure to be processed by the driver task.
    Same adjustments apply as for ``mExposure`` except that it is
    optional and may be returned as None if not provided as input.
refBand :
    Reference band to use for detection after potential adjustments.
    If not provided in the input, and only one band is set to be
    processed, ``refBand`` will be chosen to be the only existing band
    in the ``bands`` list, or `mExposure.bands`, and if neither is
    provided, it will be set to "unknown" for single-band exposures
    processed by this multi-band driver.
bands :
    List of bands associated with the exposures in ``mExposure`` after
    potential adjustments. If not provided in the input, it will be set
    to a list containing only the provided (or inferred as "unknown")
    ``refBand`` value.

Reimplemented from lsst.pipe.tasks.measurementDriver.MeasurementDriverBaseTask.

Definition at line 1097 of file measurementDriver.py.

◆ _initializeSchema()

lsst.pipe.tasks.measurementDriver.MeasurementDriverBaseTask._initializeSchema ( self,
afwTable.SourceCatalog catalog = None )
protectedinherited
Initialize the Schema to be used for constructing the subtasks.

Though it may seem clunky, this workaround is necessary to ensure
Schema consistency across all subtasks.

Parameters
----------
catalog :
    Catalog from which to extract the Schema. If not provided, the
    user-provided Schema and if that is also not provided during
    initialization, a minimal Schema will be used.

Definition at line 233 of file measurementDriver.py.

◆ _makeSubtasks()

lsst.pipe.tasks.measurementDriver.MeasurementDriverBaseTask._makeSubtasks ( self)
protectedinherited
Construct subtasks based on the configuration and the Schema.

Definition at line 307 of file measurementDriver.py.

◆ _measureSources()

lsst.pipe.tasks.measurementDriver.MeasurementDriverBaseTask._measureSources ( self,
afwImage.Exposure exposure,
afwTable.SourceCatalog catalog,
measBase.IdGenerator idGenerator,
afwTable.SourceCatalog | None refCat = None )
protectedinherited
Run the measurement subtask to compute properties of sources.

Parameters
----------
exposure :
    Exposure on which to run the measurement algorithm.
catalog :
    Catalog containing sources on which to run the measurement subtask.
idGenerator :
    Generator for unique source IDs.
refCat :
    Reference catalog to be used for forced measurements, if any.
    If not provided, the measurement will be run on the sources in the
    catalog in a standard manner without reference.

Definition at line 503 of file measurementDriver.py.

◆ _prepareSchemaAndSubtasks()

afwTable.SourceCatalog | None lsst.pipe.tasks.measurementDriver.MeasurementDriverBaseTask._prepareSchemaAndSubtasks ( self,
afwTable.SourceCatalog | None catalog )
protectedinherited
Ensure subtasks are properly initialized according to the
configuration and the provided catalog.

Parameters
----------
catalog :
    Optional catalog to be used for initializing the Schema and the
    subtasks.

Returns
-------
catalog :
    Updated catalog to be passed to the subtasks, if it was provided.

Definition at line 357 of file measurementDriver.py.

◆ _processCatalog()

afwTable.SourceCatalog lsst.pipe.tasks.measurementDriver.MeasurementDriverBaseTask._processCatalog ( self,
afwImage.Exposure exposure,
afwTable.SourceCatalog catalog,
measBase.IdGenerator idGenerator,
str band = "a single",
afwTable.SourceCatalog | None refCat = None )
protectedinherited
Process a catalog through measurement, aperture correction, and
catalog calculation subtasks.

Parameters
----------
exposure :
    Exposure associated with the catalog.
catalog :
    Catalog to be processed by the subtasks.
idGenerator :
    Generator for unique source IDs.
band :
    Band associated with the exposure and catalog. Used for logging.
refCat :
    Reference catalog for forced measurements. If not provided, the
    measurement will be run on the sources in the catalog in a standard
    manner without reference.

Returns
-------
catalog :
    Catalog after processing through the configured subtasks.

Definition at line 575 of file measurementDriver.py.

◆ _runCatalogCalculation()

lsst.pipe.tasks.measurementDriver.MeasurementDriverBaseTask._runCatalogCalculation ( self,
afwTable.SourceCatalog catalog )
protectedinherited
Run the catalog calculation plugins on the catalog.

Parameters
----------
catalog :
    Catalog to be processed by the catalog calculation subtask.

Definition at line 565 of file measurementDriver.py.

◆ _scaleVariance()

lsst.pipe.tasks.measurementDriver.MeasurementDriverBaseTask._scaleVariance ( self,
afwImage.Exposure exposure,
str band = "a single" )
protectedinherited
Scale the variance plane of an exposure to match the observed
variance.

Parameters
----------
exposure :
    Exposure on which to run the variance scaling algorithm.
band :
    Band associated with the exposure. Used for logging.

Definition at line 390 of file measurementDriver.py.

◆ _toContiguous()

afwTable.SourceCatalog | dict[str, afwTable.SourceCatalog] lsst.pipe.tasks.measurementDriver.MeasurementDriverBaseTask._toContiguous ( self,
afwTable.SourceCatalog | dict[str, afwTable.SourceCatalog] catalog )
protectedinherited
Make a catalog or catalogs contiguous if they are not already.

Parameters
----------
catalog :
    Catalog or dictionary of catalogs with bands as keys to be made
    contiguous.

Returns
-------
catalog :
    Contiguous catalog or dictionary of contiguous catalogs.

Definition at line 405 of file measurementDriver.py.

◆ _updateCatalogSchema()

afwTable.SourceCatalog lsst.pipe.tasks.measurementDriver.MeasurementDriverBaseTask._updateCatalogSchema ( self,
afwTable.SourceCatalog catalog )
protectedinherited
Update the Schema of the provided catalog to incorporate changes
made by the configured subtasks.

Parameters
----------
catalog :
    Catalog to be updated with the Schema changes.

Returns
-------
updatedCatalog :
    Catalog with the updated Schema.

Definition at line 432 of file measurementDriver.py.

◆ run()

pipeBase.Struct lsst.pipe.tasks.measurementDriver.MultiBandMeasurementDriverTask.run ( self,
afwImage.MultibandExposure | list[afwImage.Exposure] | afwImage.Exposure mExposure,
afwImage.MultibandExposure | list[afwImage.Exposure] | afwImage.Exposure | None mDeconvolved = None,
str | None refBand = None,
list[str] | None bands = None,
afwTable.SourceCatalog catalog = None,
measBase.IdGenerator idGenerator = None )
Process an exposure through the configured subtasks while using
multi-band information for deblending.

Parameters
----------
mExposure :
    Multi-band data containing images of the same shape and region of
    the sky. May be a `MultibandExposure`, a single-band exposure
    (i.e., `Exposure`), or a list of single-band exposures associated
    with different bands in which case ``bands`` must be provided. If a
    single-band exposure is given, it will be treated as a
    `MultibandExposure` that contains only that one band whose name may
    be "unknown" unless either ``bands`` or ``refBand`` is provided.
mDeconvolved :
    Multi-band deconvolved images of the same shape and region of the
    sky. Follows the same type conventions as ``mExposure``. If not
    provided, the deblender will run the deconvolution internally
    using the provided ``mExposure``.
refBand :
    Reference band to use for detection. Not required for single-band
    exposures. If `measureOnlyInRefBand` is enabled while detection is
    disabled and a catalog of detected sources is provided, this
    should specify the band the sources were detected on (or the band
    you want to use to perform measurements on exclusively). If
    `measureOnlyInRefBand` is disabled instead in the latter scenario,
    ``refBand`` does not need to be provided.
bands :
    List of bands associated with the exposures in ``mExposure``. Only
    required if ``mExposure`` is a list of single-band exposures. If
    provided for a multi-band exposure, it will be used to only process
    that subset of bands from the available ones in the exposure.
catalog :
    Catalog to be extended by the driver task. If not provided, a new
    catalog will be created and populated.
idGenerator :
    Generator for unique source IDs.

Returns
-------
result :
    Results as a struct with attributes:

    ``catalogs``
        Dictionary of catalogs containing the measured sources with
        bands as keys (`dict[str, ~lsst.afw.table.SourceCatalog]`). If
        `measureOnlyInRefBand` is enabled or deblending is disabled,
        this will only contain the reference-band catalog; otherwise,
        it will contain a catalog for each band.
    ``backgroundList``
        List of backgrounds (`list[~lsst.afw.math.Background]`). Will
        be None if detection is disabled.
    ``modelData``
        Multiband scarlet models produced during deblending
        (`~scarlet.io.LsstScarletModelData`). Will be None if
        deblending is disabled.

Reimplemented from lsst.pipe.tasks.measurementDriver.MeasurementDriverBaseTask.

Definition at line 987 of file measurementDriver.py.

Member Data Documentation

◆ _Deblender

str lsst.pipe.tasks.measurementDriver.MeasurementDriverBaseTask._Deblender = ""
staticprotectedinherited

Definition at line 169 of file measurementDriver.py.

◆ _DefaultName

str lsst.pipe.tasks.measurementDriver.MeasurementDriverBaseTask._DefaultName = "measurementDriverBase"
staticprotectedinherited

Definition at line 168 of file measurementDriver.py.

◆ applyApCorr

measBase.ApplyApCorrTask lsst.pipe.tasks.measurementDriver.MeasurementDriverBaseTask.applyApCorr
inherited

Definition at line 186 of file measurementDriver.py.

◆ catalogCalculation

measBase.CatalogCalculationTask lsst.pipe.tasks.measurementDriver.MeasurementDriverBaseTask.catalogCalculation
inherited

Definition at line 187 of file measurementDriver.py.

◆ config

lsst.pipe.tasks.measurementDriver.MeasurementDriverBaseTask.config
inherited

Definition at line 310 of file measurementDriver.py.

◆ ConfigClass

lsst.pipe.tasks.measurementDriver.MeasurementDriverBaseTask.ConfigClass = MeasurementDriverBaseConfig
staticinherited

Definition at line 167 of file measurementDriver.py.

◆ deblend

measDeblender.SourceDeblendTask | scarlet.ScarletDeblendTask lsst.pipe.tasks.measurementDriver.MeasurementDriverBaseTask.deblend
inherited

Definition at line 184 of file measurementDriver.py.

◆ detection

measAlgorithms.SourceDetectionTask lsst.pipe.tasks.measurementDriver.MeasurementDriverBaseTask.detection
inherited

Definition at line 183 of file measurementDriver.py.

◆ initSchema

afwTable.Schema lsst.pipe.tasks.measurementDriver.MeasurementDriverBaseTask.initSchema
inherited

Definition at line 190 of file measurementDriver.py.

◆ mapper

afwTable.SchemaMapper lsst.pipe.tasks.measurementDriver.MeasurementDriverBaseTask.mapper
inherited

Definition at line 181 of file measurementDriver.py.

◆ measurement

measBase.SingleFrameMeasurementTask | measBase.ForcedMeasurementTask lsst.pipe.tasks.measurementDriver.MeasurementDriverBaseTask.measurement
inherited

Definition at line 185 of file measurementDriver.py.

◆ modelData

scarlet.io.LsstScarletModelData lsst.pipe.tasks.measurementDriver.MultiBandMeasurementDriverTask.modelData

Definition at line 985 of file measurementDriver.py.

◆ peakSchema

lsst.pipe.tasks.measurementDriver.MeasurementDriverBaseTask.peakSchema = peakSchema
inherited

Definition at line 178 of file measurementDriver.py.

◆ scaleVariance

measAlgorithms.ScaleVarianceTask lsst.pipe.tasks.measurementDriver.MeasurementDriverBaseTask.scaleVariance
inherited

Definition at line 182 of file measurementDriver.py.

◆ schema

lsst.pipe.tasks.measurementDriver.MeasurementDriverBaseTask.schema = schema
inherited

Definition at line 175 of file measurementDriver.py.


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