lsst.meas.base  14.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Groups Pages
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:

Public Member Functions

def __init__
 Initialize the task. More...
 
def run
 Run single frame measurement over an exposure and source catalog. More...
 
def runPlugins
 
def measure
 Backwards-compatibility alias for run() More...
 

Public Attributes

 schema
 
 doBlendedness
 
 blendPlugin
 

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

1 from lsst.meas.algorithms.detection import SourceDetectionTask
2 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:

1  schema = afwTable.SourceTable.makeMinimalSchema()

Now we can configure and create the SourceDetectionTask:

1  #
2  # Create the detection task
3  #
4  config = SourceDetectionTask.ConfigClass()
5  config.thresholdPolarity = "both"
6  config.background.isNanSafe = True
7  config.thresholdValue = 3
8  detectionTask = SourceDetectionTask(config=config, schema=schema)

We then move on to configuring the measurement task:

1  #
2  # And the measurement Task
3  #
4  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:

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

Now, finally, we can construct the measurement task:

1  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 150 of file sfm.py.

Constructor & Destructor Documentation

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 249 of file sfm.py.

Member Function Documentation

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

Backwards-compatibility alias for run()

Definition at line 385 of file sfm.py.

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 274 of file sfm.py.

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 316 of file sfm.py.

Member Data Documentation

lsst.meas.base.sfm.SingleFrameMeasurementTask.blendPlugin

Definition at line 270 of file sfm.py.

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

Definition at line 242 of file sfm.py.

lsst.meas.base.sfm.SingleFrameMeasurementTask.doBlendedness

Definition at line 269 of file sfm.py.

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

Definition at line 247 of file sfm.py.

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

Definition at line 246 of file sfm.py.

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

Definition at line 244 of file sfm.py.

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

Definition at line 245 of file sfm.py.

lsst.meas.base.sfm.SingleFrameMeasurementTask.schema

Definition at line 263 of file sfm.py.


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