lsst.pipe.tasks g540474b770+1ce96500e5
Loading...
Searching...
No Matches
lsst.pipe.tasks.measurementDriver.ForcedMeasurementDriverTask Class Reference
Inheritance diagram for lsst.pipe.tasks.measurementDriver.ForcedMeasurementDriverTask:
lsst.pipe.tasks.measurementDriver.SingleBandMeasurementDriverTask lsst.pipe.tasks.measurementDriver.MeasurementDriverBaseTask

Public Member Functions

 __init__ (self, *args, **kwargs)
 
astropy.table.Table runFromAstropy (self, astropy.table.Table table, afwImage.Exposure exposure, *, str id_column_name="objectId", str ra_column_name="coord_ra", str dec_column_name="coord_dec", float psf_footprint_scaling=3.0, measBase.IdGenerator|None idGenerator=None)
 
 run (self, *args, **kwargs)
 
 runFromImage (self, *args, **kwargs)
 
 __setattr__ (self, name, value)
 

Public Attributes

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

None _ensureValidInputs (self, astropy.table.Table table, afwImage.Exposure exposure, str id_column_name, str ra_column_name, str dec_column_name)
 
 _makeMinimalSourceCatalogFromAstropy (self, astropy.table.Table table, list[str] columns=["id", "ra", "dec"], str coord_unit="degrees")
 
afwTable.SourceCatalog _deblendSources (self, afwImage.Exposure exposure, afwTable.SourceCatalog catalog)
 
 _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

Forced measurement driver task for single-band data.

This task is the 'forced' version of the `SingleBandMeasurementDriverTask`,
intended as a convenience function for performing forced photometry on an
input image given a set of IDs and RA/Dec coordinates. It is designed as a
public-facing interface, allowing users to measure sources without
explicitly instantiating and running pipeline tasks.

Examples
--------
Here is an example of how to use this class to run forced measurements on
an exposure using an Astropy table containing source IDs and RA/Dec
coordinates:

>>> from lsst.pipe.tasks.measurementDriver import (
...     ForcedMeasurementDriverConfig,
...     ForcedMeasurementDriverTask,
... )
>>> import astropy.table
>>> import lsst.afw.image as afwImage
>>> config = ForcedMeasurementDriverConfig()
>>> config.doScaleVariance = True
>>> config.scaleVariance.background.binSize = 32
>>> config.doApCorr = True
>>> config.measurement.plugins.names = [
...     "base_PixelFlags",
...     "base_TransformedCentroidFromCoord",
...     "base_PsfFlux",
...     "base_CircularApertureFlux",
... ]
>>> config.measurement.slots.psfFlux = "base_PsfFlux"
>>> config.measurement.slots.centroid = "base_TransformedCentroidFromCoord"
>>> config.measurement.slots.shape = None
>>> config.measurement.doReplaceWithNoise = False
>>> calexp = butler.get("deepCoadd_calexp", dataId=...)
>>> objtable = butler.get(
...     "objectTable", dataId=..., storageClass="ArrowAstropy"
... )
>>> table = objtable[:5].copy()["objectId", "coord_ra", "coord_dec"]
>>> driver = ForcedMeasurementDriverTask(config=config)
>>> results = driver.runFromAstropy(
...     table,
...     calexp,
...     id_column_name="objectId",
...     ra_column_name="coord_ra",
...     dec_column_name="coord_dec",
...     psf_footprint_scaling=3.0,
... )
>>> results.writeFits("forced_meas_catalog.fits")

Definition at line 1432 of file measurementDriver.py.

Constructor & Destructor Documentation

◆ __init__()

lsst.pipe.tasks.measurementDriver.ForcedMeasurementDriverTask.__init__ ( self,
* args,
** kwargs )
Initialize the forced measurement driver task.

Definition at line 1487 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.

◆ _deblendSources()

afwTable.SourceCatalog lsst.pipe.tasks.measurementDriver.SingleBandMeasurementDriverTask._deblendSources ( self,
afwImage.Exposure exposure,
afwTable.SourceCatalog catalog )
protectedinherited
Run single-band deblending given an exposure and a catalog.

Parameters
----------
exposure :
    Exposure on which to run the deblending algorithm.
catalog :
    Catalog containing sources to be deblended.

Returns
-------
catalog :
    Catalog after deblending, with sources separated into their
    individual components if they were deblended.

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

Definition at line 863 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()

None lsst.pipe.tasks.measurementDriver.ForcedMeasurementDriverTask._ensureValidInputs ( self,
astropy.table.Table table,
afwImage.Exposure exposure,
str id_column_name,
str ra_column_name,
str dec_column_name )
protected
Validate the inputs for the forced measurement task.

Parameters
----------
table :
    Astropy table containing source IDs and RA/Dec coordinates.
exposure :
    Exposure on which to run the forced measurements.
id_column_name :
    Name of the column containing source IDs in the table.
ra_column_name :
    Name of the column containing RA coordinates in the table.
dec_column_name :
    Name of the column containing Dec coordinates in the table.

Returns
-------
coord_unit : `str`
    Unit of the sky coordinates extracted from the table.

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

Definition at line 1606 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.

◆ _makeMinimalSourceCatalogFromAstropy()

lsst.pipe.tasks.measurementDriver.ForcedMeasurementDriverTask._makeMinimalSourceCatalogFromAstropy ( self,
astropy.table.Table table,
list[str] columns = ["id", "ra", "dec"],
str coord_unit = "degrees" )
protected
Convert an Astropy Table to a minimal LSST SourceCatalog.

This is intended for use with the forced measurement subtask, which
expects a `SourceCatalog` input with a minimal schema containing `id`,
`ra`, and `dec`.

Parameters
----------
table :
    Astropy Table containing source IDs and sky coordinates.
columns :
    Names of the columns in the order [id, ra, dec], where `ra` and
    `dec` are in degrees by default. If the coordinates are in radians,
    set `coord_unit` to "radians".
coord_unit : `str`
    Unit of the sky coordinates. Can be either "degrees" or "radians".

Returns
-------
outputCatalog : `lsst.afw.table.SourceCatalog`
    A SourceCatalog with minimal schema populated from the input table.

Raises
------
ValueError
    If `coord_unit` is not "degrees" or "radians".
    If `columns` does not contain exactly 3 items.
KeyError
    If any of the specified columns are missing from the input table.

Definition at line 1657 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()

lsst.pipe.tasks.measurementDriver.ForcedMeasurementDriverTask.run ( self,
* exposure,
** catalog )
Process a single-band exposure through the configured subtasks and
return the results as a struct.

Parameters
----------
exposure :
    The exposure on which to run the driver task.
catalog :
    Catalog to be extended by the driver task. If not provided, an
    empty catalog will be created and populated.
idGenerator :
    Object that generates source IDs and provides random seeds.

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

    ``catalog``
        Catalog containing the measured sources
        (`~lsst.afw.table.SourceCatalog`).
    ``backgroundList``
        List of backgrounds (`list[~lsst.afw.math.Background]`). Only
        populated if detection is enabled.

Reimplemented from lsst.pipe.tasks.measurementDriver.SingleBandMeasurementDriverTask.

Definition at line 1594 of file measurementDriver.py.

◆ runFromAstropy()

astropy.table.Table lsst.pipe.tasks.measurementDriver.ForcedMeasurementDriverTask.runFromAstropy ( self,
astropy.table.Table table,
afwImage.Exposure exposure,
* ,
str id_column_name = "objectId",
str ra_column_name = "coord_ra",
str dec_column_name = "coord_dec",
float psf_footprint_scaling = 3.0,
measBase.IdGenerator | None idGenerator = None )
Run forced measurements on an exposure using an Astropy table.

Parameters
----------
table :
    Astropy table containing source IDs and RA/Dec coordinates.
    Must contain columns with names specified by `id_column_name`,
    `ra_column_name`, and `dec_column_name`.
exposure :
    Exposure on which to run the forced measurements.
id_column_name :
    Name of the column containing source IDs in the table.
ra_column_name :
    Name of the column containing RA coordinates in the table.
dec_column_name :
    Name of the column containing Dec coordinates in the table.
psf_footprint_scaling :
    Scaling factor to apply to the PSF second-moments ellipse in order
    to determine the footprint boundary.
idGenerator :
    Object that generates source IDs and provides random seeds.
    If not provided, a new `IdGenerator` will be created.

Returns
-------
result :
    Astropy table containing the measured sources with columns
    corresponding to the source IDs, RA, Dec, from the input table, and
    additional measurement columns defined in the configuration.

Definition at line 1493 of file measurementDriver.py.

◆ runFromImage()

lsst.pipe.tasks.measurementDriver.ForcedMeasurementDriverTask.runFromImage ( self,
* image,
** mask )
Convert image data to an `Exposure`, then run it through the
configured subtasks.

Parameters
----------
image :
    Input image data. Will be converted into an `Exposure` before
    processing.
mask :
    Mask data for the image. Used if ``image`` is a bare `array` or
    `Image`.
variance :
    Variance plane data for the image.
wcs :
    World Coordinate System to associate with the exposure that will
    be created from ``image``.
psf :
    PSF model for the exposure.
photoCalib :
    Photometric calibration model for the exposure.
catalog :
    Catalog to be extended by the driver task. If not provided, a new
    catalog will be created during detection and populated.
idGenerator :
    Generator for unique source IDs.

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

    ``catalog``
        Catalog containing the measured sources
        (`~lsst.afw.table.SourceCatalog`).
    ``backgroundList``
        List of backgrounds (`list[~lsst.afw.math.Background]`).

Reimplemented from lsst.pipe.tasks.measurementDriver.SingleBandMeasurementDriverTask.

Definition at line 1600 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.

◆ 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: