lsst.meas.base  16.0-12-g5ad1ebf+14
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
lsst.meas.base.sfm.SingleFrameMeasurementTask Class Reference

A subtask for measuring the properties of sources on a single exposure. More...

Inheritance diagram for lsst.meas.base.sfm.SingleFrameMeasurementTask:
lsst.meas.base.baseMeasurement.BaseMeasurementTask

Public Member Functions

def __init__ (self, schema, algMetadata=None, kwds)
 Initialize the task. More...
 
def run (self, measCat, exposure, noiseImage=None, exposureId=None, beginOrder=None, endOrder=None)
 Run single frame measurement over an exposure and source catalog. More...
 
def runPlugins (self, noiseReplacer, measCat, exposure, beginOrder=None, endOrder=None)
 
def measure (self, measCat, exposure)
 Backwards-compatibility alias for run() More...
 
def getPluginLogName (self, pluginName)
 
def initializePlugins (self, kwds)
 
def callMeasure (self, measRecord, args, kwds)
 Call the measure() method on all plugins, handling exceptions in a consistent way. More...
 
def doMeasurement (self, plugin, measRecord, args, kwds)
 Call the measure() method on the nominated plugin, handling exceptions in a consistent way. More...
 
def callMeasureN (self, measCat, args, kwds)
 Call the measureN() method on all plugins, handling exceptions in a consistent way. More...
 
def doMeasurementN (self, plugin, measCat, args, kwds)
 Call the measureN() method on the nominated plugin, handling exceptions in a consistent way. More...
 

Public Attributes

 schema
 
 doBlendedness
 
 blendPlugin
 
 plugins
 
 undeblendedPlugins
 
 algMetadata
 

Static Public Attributes

 ConfigClass = SingleFrameMeasurementConfig
 
string NOISE_SEED_MULTIPLIER = "NOISE_SEED_MULTIPLIER"
 
string NOISE_SOURCE = "NOISE_SOURCE"
 
string NOISE_OFFSET = "NOISE_OFFSET"
 
string NOISE_EXPOSURE_ID = "NOISE_EXPOSURE_ID"
 

Detailed Description

A subtask for measuring the properties of sources on a single exposure.

The task is configured with a list of "plugins": each plugin defines the values it measures (i.e. the columns in a table it will fill) and conducts that measurement on each detected source (see SingleFramePlugin). The job of the measurement task is to initialize the set of plugins (which includes setting up the catalog schema) from their configuration, and then invoke each plugin on each source.

When run after the deblender (see lsst.meas.deblender.SourceDeblendTask), SingleFrameMeasurementTask also replaces each source's neighbors with noise before measuring each source, utilizing the HeavyFootprints created by the deblender (see NoiseReplacer).

SingleFrameMeasurementTask has only two methods: init() and run(). For configuration options, see SingleFrameMeasurementConfig.

A complete example of using SingleFrameMeasurementTask

The code below is in examples/runSingleFrameTask.py

See meas_algorithms_detection_Example for more information on SourceDetectionTask.

First, import the required tasks (there are some other standard imports; read the file if you're confused):

from lsst.meas.algorithms.detection import SourceDetectionTask
from lsst.meas.base import SingleFrameMeasurementTask

We need to create our tasks before processing any data as the task constructors can add extra columns to the schema. The most important argument we pass these to these is an lsst.afw.table.Schema object, which contains information about the fields (i.e. columns) of the measurement catalog we'll create, including names, types, and additional documentation. Tasks that operate on a catalog are typically passed a Schema upon construction, to which they add the fields they'll fill later when run. We construct a mostly empty Schema that contains just the fields required for a SourceCatalog like this:

schema = afwTable.SourceTable.makeMinimalSchema()

Now we can configure and create the SourceDetectionTask:

#
# Create the detection task
#
config = SourceDetectionTask.ConfigClass()
config.thresholdPolarity = "both"
config.background.isNanSafe = True
config.thresholdValue = 3
detectionTask = SourceDetectionTask(config=config, schema=schema)

We then move on to configuring the measurement task:

#
# And the measurement Task
#
config = SingleFrameMeasurementTask.ConfigClass()

While a reasonable set of plugins is configured by default, we'll customize the list. We also need to unset one of the slots at the same time, because we're not running the algorithm that it's set to by default, and that would cause problems later:

config.plugins.names.clear()
for plugin in ["base_SdssCentroid", "base_SdssShape", "base_CircularApertureFlux", "base_GaussianFlux"]:
config.plugins.names.add(plugin)
config.slots.psfFlux = None

Now, finally, we can construct the measurement task:

measureTask = SingleFrameMeasurementTask(schema, config=config)

After constructing all the tasks, we can inspect the Schema we've created:

All of the fields in the schema can be accessed via the get() method on a record object. See afwTable for more information.

We're now ready to process the data (we could loop over multiple exposures/catalogs using the same task objects). First create the output table and process the image to find sources:

Then measure them:

We then might plot the results (e.g. if you set --ds9 on the command line)

and end up with something like

runSingleFrameTask-ds9.png

Definition at line 152 of file sfm.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.meas.base.sfm.SingleFrameMeasurementTask.__init__ (   self,
  schema,
  algMetadata = None,
  kwds 
)

Initialize the task.

Set up the execution order of the plugins and initialize the plugins, giving each plugin an opportunity to add its measurement fields to the output schema and to record information in the task metadata.

Parameters
[in,out]schemalsst.afw.table.Schema, to be initialized to include the measurement fields from the plugins already
[in,out]algMetadatalsst.daf.base.PropertyList used to record information about each algorithm. An empty PropertyList will be created if None.
[in]**kwdsKeyword arguments forwarded to lsst.pipe.base.Task.__init__

Definition at line 251 of file sfm.py.

Member Function Documentation

◆ callMeasure()

def lsst.meas.base.baseMeasurement.BaseMeasurementTask.callMeasure (   self,
  measRecord,
  args,
  kwds 
)
inherited

Call the measure() method on all plugins, handling exceptions in a consistent way.

Parameters
[in,out]measRecordlsst.afw.table.SourceRecord that corresponds to the object being measured, and where outputs should be written.
[in]*argsPositional arguments forwarded to Plugin.measure()
[in]**kwdsKeyword arguments. Two are handled locally:
  • beginOrder: beginning execution order (inclusive): measurements with executionOrder < beginOrder are not executed. None for no limit.
  • endOrder: ending execution order (exclusive): measurements with executionOrder >= endOrder are not executed. None for no limit. the rest are forwarded to Plugin.measure()

This method can be used with plugins that have different signatures; the only requirement is that 'measRecord' be the first argument. Subsequent positional arguments and keyword arguments are forwarded directly to the plugin.

This method should be considered "protected"; it is intended for use by derived classes, not users.

Definition at line 255 of file baseMeasurement.py.

◆ callMeasureN()

def lsst.meas.base.baseMeasurement.BaseMeasurementTask.callMeasureN (   self,
  measCat,
  args,
  kwds 
)
inherited

Call the measureN() method on all plugins, handling exceptions in a consistent way.

Parameters
[in,out]measCatlsst.afw.table.SourceCatalog containing records for just the source family to be measured, and where outputs should be written.
[in]beginOrderbeginning execution order (inclusive): measurements with executionOrder < beginOrder are not executed. None for no limit.
[in]endOrderending execution order (exclusive): measurements with executionOrder >= endOrder are not executed. None for no limit.
[in]*argsPositional arguments forwarded to Plugin.measure()
[in]**kwdsKeyword arguments. Two are handled locally:
  • beginOrder: beginning execution order (inclusive): measurements with executionOrder < beginOrder are not executed. None for no limit.
  • endOrder: ending execution order (exclusive): measurements with executionOrder >= endOrder are not executed. None for no limit. the rest are forwarded to Plugin.measure()

This method can be used with plugins that have different signatures; the only requirement is that 'measRecord' be the first argument. Subsequent positional arguments and keyword arguments are forwarded directly to the plugin.

This method should be considered "protected"; it is intended for use by derived classes, not users.

Definition at line 315 of file baseMeasurement.py.

◆ doMeasurement()

def lsst.meas.base.baseMeasurement.BaseMeasurementTask.doMeasurement (   self,
  plugin,
  measRecord,
  args,
  kwds 
)
inherited

Call the measure() method on the nominated plugin, handling exceptions in a consistent way.

Parameters
[in]pluginPlugin that will measure
[in,out]measRecordlsst.afw.table.SourceRecord that corresponds to the object being measured, and where outputs should be written.
[in]*argsPositional arguments forwarded to plugin.measure()
[in]**kwdsKeyword arguments forwarded to plugin.measure()

This method can be used with plugins that have different signatures; the only requirement is that the 'plugin' and 'measRecord' be the first two arguments. Subsequent positional arguments and keyword arguments are forwarded directly to the plugin.

This method should be considered "protected"; it is intended for use by derived classes, not users.

Definition at line 284 of file baseMeasurement.py.

◆ doMeasurementN()

def lsst.meas.base.baseMeasurement.BaseMeasurementTask.doMeasurementN (   self,
  plugin,
  measCat,
  args,
  kwds 
)
inherited

Call the measureN() method on the nominated plugin, handling exceptions in a consistent way.

Parameters
[in]pluginPlugin that will measure
[in,out]measCatlsst.afw.table.SourceCatalog containing records for just the source family to be measured, and where outputs should be written.
[in]*argsPositional arguments forwarded to plugin.measureN()
[in]**kwdsKeyword arguments forwarded to plugin.measureN()

This method can be used with plugins that have different signatures; the only requirement is that the 'plugin' and 'measCat' be the first two arguments. Subsequent positional arguments and keyword arguments are forwarded directly to the plugin.

This method should be considered "protected"; it is intended for use by derived classes, not users.

Definition at line 349 of file baseMeasurement.py.

◆ getPluginLogName()

def lsst.meas.base.baseMeasurement.BaseMeasurementTask.getPluginLogName (   self,
  pluginName 
)
inherited

Definition at line 214 of file baseMeasurement.py.

◆ initializePlugins()

def lsst.meas.base.baseMeasurement.BaseMeasurementTask.initializePlugins (   self,
  kwds 
)
inherited
Initialize the plugins (and slots) according to the configuration.

Derived class constructors should call this method to fill the self.plugins
attribute and add correspond output fields and slot aliases to the output schema.

In addition to the attributes added by BaseMeasurementTask.__init__, a self.schema
attribute holding the output schema must also be present before this method is called, .

Keyword arguments are forwarded directly to plugin constructors, allowing derived
classes to use plugins with different signatures.

Definition at line 217 of file baseMeasurement.py.

◆ measure()

def lsst.meas.base.sfm.SingleFrameMeasurementTask.measure (   self,
  measCat,
  exposure 
)

Backwards-compatibility alias for run()

Definition at line 392 of file sfm.py.

◆ run()

def lsst.meas.base.sfm.SingleFrameMeasurementTask.run (   self,
  measCat,
  exposure,
  noiseImage = None,
  exposureId = None,
  beginOrder = None,
  endOrder = None 
)

Run single frame measurement over an exposure and source catalog.

Parameters
[in,out]measCatlsst.afw.table.SourceCatalog to be filled with outputs. Must contain all the SourceRecords to be measured (with Footprints attached), and have a schema that is a superset of self.schema.
[in]exposurelsst.afw.image.ExposureF, containing the pixel data to be measured and the associated Psf, Wcs, etc.
[in]noiseImageoptional lsst.afw.image.ImageF for test which need to control noiseReplacement
[in]exposureIdoptional unique exposureId used to calculate random number generator seed in the NoiseReplacer.
[in]beginOrderbeginning execution order (inclusive): measurements with executionOrder < beginOrder are not executed. None for no limit.
[in]endOrderending execution order (exclusive): measurements with executionOrder >= endOrder are not executed. None for no limit.

Definition at line 277 of file sfm.py.

◆ runPlugins()

def lsst.meas.base.sfm.SingleFrameMeasurementTask.runPlugins (   self,
  noiseReplacer,
  measCat,
  exposure,
  beginOrder = None,
  endOrder = None 
)
Function which calls the defined measument plugins on an exposure

Parameters
----------
noiseReplacer : lsst.meas.base.NoiseReplacer
    noiseReplacer to fill sources not being measured with noise.

measCat : lsst.afw.table.SourceCatalog
    SourceCatalog to be filled with outputs. Must contain all the SourceRecords to be measured (with
    Footprints attached), and have a schema that is a superset of self.schema.

exposure : lsst.afw.image.ExposureF
    Exposure contaning the pixel data to be measured and the associated PSF, WCS, etc.

beginOrder : float
    beginning execution order (inclusive): measurements with executionOrder < beginOrder are not
    executed. None for no limit.

endOrder : float
    ending execution order (exclusive): measurements with executionOrder >= endOrder are not
    executed. None for no limit.

Definition at line 319 of file sfm.py.

Member Data Documentation

◆ algMetadata

lsst.meas.base.baseMeasurement.BaseMeasurementTask.algMetadata
inherited

Definition at line 212 of file baseMeasurement.py.

◆ blendPlugin

lsst.meas.base.sfm.SingleFrameMeasurementTask.blendPlugin

Definition at line 272 of file sfm.py.

◆ ConfigClass

lsst.meas.base.sfm.SingleFrameMeasurementTask.ConfigClass = SingleFrameMeasurementConfig
static

Definition at line 244 of file sfm.py.

◆ doBlendedness

lsst.meas.base.sfm.SingleFrameMeasurementTask.doBlendedness

Definition at line 271 of file sfm.py.

◆ NOISE_EXPOSURE_ID

string lsst.meas.base.sfm.SingleFrameMeasurementTask.NOISE_EXPOSURE_ID = "NOISE_EXPOSURE_ID"
static

Definition at line 249 of file sfm.py.

◆ NOISE_OFFSET

string lsst.meas.base.sfm.SingleFrameMeasurementTask.NOISE_OFFSET = "NOISE_OFFSET"
static

Definition at line 248 of file sfm.py.

◆ NOISE_SEED_MULTIPLIER

string lsst.meas.base.sfm.SingleFrameMeasurementTask.NOISE_SEED_MULTIPLIER = "NOISE_SEED_MULTIPLIER"
static

Definition at line 246 of file sfm.py.

◆ NOISE_SOURCE

string lsst.meas.base.sfm.SingleFrameMeasurementTask.NOISE_SOURCE = "NOISE_SOURCE"
static

Definition at line 247 of file sfm.py.

◆ plugins

lsst.meas.base.baseMeasurement.BaseMeasurementTask.plugins
inherited

Definition at line 208 of file baseMeasurement.py.

◆ schema

lsst.meas.base.sfm.SingleFrameMeasurementTask.schema

Definition at line 265 of file sfm.py.

◆ undeblendedPlugins

lsst.meas.base.baseMeasurement.BaseMeasurementTask.undeblendedPlugins
inherited

Definition at line 209 of file baseMeasurement.py.


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