lsst.meas.base  16.0-8-g2ce35ff+2
Classes | Functions
lsst.meas.base.wrappers Namespace Reference

Classes

class  GenericPlugin
 
class  WrappedForcedPlugin
 
class  WrappedSingleFramePlugin
 

Functions

def wrapAlgorithmControl (Base, Control, module=2, hasMeasureN=False)
 Wrap a C++ algorithm's control class into a Python Config class. More...
 
def wrapAlgorithm (Base, AlgClass, factory, executionOrder, name=None, Control=None, ConfigClass=None, TransformClass=None, doRegister=True, shouldApCorr=False, apCorrList=(), hasLogName=False, kwds)
 Wrap a C++ Algorithm class into a Python Plugin class. More...
 
def wrapSingleFrameAlgorithm (AlgClass, executionOrder, name=None, needsMetadata=False, hasMeasureN=False, hasLogName=False, kwds)
 Wrap a C++ SingleFrameAlgorithm class into a Python SingleFramePlugin class. More...
 
def wrapForcedAlgorithm (AlgClass, executionOrder, name=None, needsMetadata=False, hasMeasureN=False, needsSchemaOnly=False, hasLogName=False, kwds)
 Wrap a C++ ForcedAlgorithm class into a Python ForcedPlugin class. More...
 
def wrapSimpleAlgorithm (AlgClass, executionOrder, name=None, needsMetadata=False, hasMeasureN=False, hasLogName=False, kwds)
 Wrap a C++ SimpleAlgorithm class into both a Python SingleFramePlugin and ForcedPlugin classes. More...
 
def wrapTransform (transformClass, hasLogName=False)
 

Function Documentation

◆ wrapAlgorithm()

def lsst.meas.base.wrappers.wrapAlgorithm (   Base,
  AlgClass,
  factory,
  executionOrder,
  name = None,
  Control = None,
  ConfigClass = None,
  TransformClass = None,
  doRegister = True,
  shouldApCorr = False,
  apCorrList = (),
  hasLogName = False,
  kwds 
)

Wrap a C++ Algorithm class into a Python Plugin class.

Parameters
[in]BaseBase class for the returned Plugin; one of SingleFramePlugin or ForcedPlugin
[in]AlgClassSwigged C++ Algorithm class to convert; must be a subclass of SingleFrameAlgorithm or ForcedAlgorithm (matching the Base argument), or an unrelated class with the same measure() and measureN() signatures as those base classes.
[in]factoryA callable that is used to construct an instance of AlgClass. It must take four arguments, either (config, name, schema, metadata) or (config, name, schemaMapper, metadata), depending on whether the algorithm is single-frame or forced.
[in]executionOrderThe order this plugin should be run, relative to others (see BasePlugin.getExecutionOrder()).
[in]nameString to use when registering the algorithm. Ignored if doRegistry=False, set to generateAlgorithmName(AlgClass) if None.
[in]ControlSwigged C++ Control class for the algorithm; AlgClass.Control is used if None. Ignored if ConfigClass is not None.
[in]ConfigClassPython Config class that wraps the C++ Algorithm's swigged Control class. If None, wrapAlgorithmControl is called to generate a Config class using the Control argument.
[in]TransformClassTransformation which may be used to post-process the results of measurement. If None, the default (defined by BasePlugin) is used.
[in]doRegisterIf True (the default), register the plugin with Base's registry, allowing it to be used by measurement Tasks.
[in]shouldApCorrDoes this algorithm measure a flux that can be aperture corrected? This is shorthand for apCorrList=[name] and is ignored if apCorrList is specified.
[in]apCorrListList of field name prefixes for flux fields that should be aperture corrected. If an algorithm produces a single flux that should be aperture corrected then it is simpler to set shouldApCorr=True. But if an algorithm produces multiple such fields then it must specify apCorrList, instead. For example modelfit_CModel produces 3 such fields: apCorrList= ("modelfit_CModel_exp", "modelfit_CModel_exp", "modelfit_CModel_def") If apCorrList is non-empty then shouldApCorr is ignored. If non-empty and doRegister is True then the names are added to the set retrieved by getApCorrNameSet
[in]hasLogNamePlugin supports a logName as a constructor argument
[in]**kwdsAdditional keyword arguments passed to generateAlgorithmControl, including:
  • hasMeasureN: Whether the plugin supports fitting multiple objects at once (if so, a config option to enable/disable this will be added).
  • executionOrder: If not None, an override for the default executionOrder for this plugin (the default is 2.0, which is usually appropriate for fluxes).
Returns
the new Plugin class, a subclass of Base

This function is generally only called by the public wrapSingleFrameAlgorithm, wrapForcedAlgorithm, and wrapSimpleAlgorithm functions; it is unlikely users will have to call it directly.

Definition at line 93 of file wrappers.py.

◆ wrapAlgorithmControl()

def lsst.meas.base.wrappers.wrapAlgorithmControl (   Base,
  Control,
  module = 2,
  hasMeasureN = False 
)

Wrap a C++ algorithm's control class into a Python Config class.

Parameters
[in]BaseBase class for the returned ConfigClass; one of SingleFramePluginConfig or ForcedPluginConfig
[in]ControlControl class to be wrapped (a Swigged C++ class)
[in]moduleEither a module object, a string specifying the name of the module, or an integer specifying how far back in the stack to look for the module to use: 0 is pex.config.wrap, 1 is lsst.meas.base.wrappers, 2 is the immediate caller, etc. This will be used to set module for the new config class, and the class will also be added to the module. The default is to use the callers' module.
[in]hasMeasureNWhether the plugin supports fitting multiple objects at once (if so, a config option to enable/disable this will be added).
Returns
a new subclass of lsst.pex.config.Config

This function is generally only called by wrapAlgorithm; it is unlikely users will have to call it directly.

Definition at line 51 of file wrappers.py.

◆ wrapForcedAlgorithm()

def lsst.meas.base.wrappers.wrapForcedAlgorithm (   AlgClass,
  executionOrder,
  name = None,
  needsMetadata = False,
  hasMeasureN = False,
  needsSchemaOnly = False,
  hasLogName = False,
  kwds 
)

Wrap a C++ ForcedAlgorithm class into a Python ForcedPlugin class.

Parameters
[in]AlgClassSwigged C++ Algorithm class to convert; must be a subclass of ForcedAlgorithm, or an unrelated class with the same measure(), measureN(), and fail() signatures.
[in]executionOrderThe order this plugin should be run, relative to others (see BasePlugin.getExecutionOrder()).
[in]nameString to use when registering the algorithm. Ignored if doRegistry=False, set to generateAlgorithmName(AlgClass) if None.
[in]needsMetadataSets whether the AlgClass's constructor should be passed a PropertySet metadata argument.
[in]hasMeasureNWhether the algorithm supports simultaneous measurement of multiple sources. If True, a bool doMeasureN field will be added to the generated Config class, and its value will be passed as the last argument when calling the AlgClass constructor.
[in]hasLogNamePlugin supports a logName as a constructor argument
[in]needsSchemaOnlyWhether the algorithm constructor expects a Schema argument (representing the output Schema) rather than the full SchemaMapper (which provides access to both the reference Schema and the output Schema).
[in]**kwdsAdditional keyword arguments passed to the lower-level wrapAlgorithm and wrapAlgorithmControl classes. These include:
  • Control: Swigged C++ Control class for the algorithm; AlgClass.Control is used if None. Ignored if ConfigClass is not None.
  • ConfigClass: Python Config class that wraps the C++ Algorithm's swigged Control class. If None, wrapAlgorithmControl is called to generate a Config class using the Control argument.
  • doRegister: If True (the default), register the plugin with ForcedPlugin.registry, allowing it to be used by ForcedMeasurementTask.
  • shouldApCorr: does this algorithm measure a flux that can be aperture corrected? This is shorthand for apCorrList=[name] and is ignored if apCorrList is specified.
  • apCorrList: list of field name prefixes for flux fields that should be aperture corrected. If an algorithm produces a single flux that should be aperture corrected then it is simpler to set shouldApCorr=True. But if an algorithm produces multiple such fields then it must specify apCorrList, instead. For example modelfit_CModel produces 3 such fields: apCorrList= ("modelfit_CModel_exp", "modelfit_CModel_exp", "modelfit_CModel_def") If apCorrList is non-empty then shouldApCorr is ignored. If non-empty and doRegister is True then the names are added to the set retrieved by getApCorrNameSet
  • executionOrder: If not None, an override for the default executionOrder for this plugin (the default is 2.0, which is usually appropriate for fluxes).
Returns
the new ForcedPlugin subclass

The needsMetadata, hasMeasureN, and needsSchemaOnly arguments combine to determine the expected constructor signature; we always expect the first two arguments to be:

Control const & ctrl, std::string const & name

If needsSchemaOnly is True, then the third argument will be

Schema & schema

otherwise, it will be:

SchemaMapper & schemaMapper

If needsMetadata, we also append:

PropertySet & metadata

If hasMeasureN, we also append:

bool doMeasureN

If hasLogName, we also append:

std::string logName

If more than one is True, the metadata PropertySet precedes the doMeasureN bool and the logName comes last of the three

Definition at line 253 of file wrappers.py.

◆ wrapSimpleAlgorithm()

def lsst.meas.base.wrappers.wrapSimpleAlgorithm (   AlgClass,
  executionOrder,
  name = None,
  needsMetadata = False,
  hasMeasureN = False,
  hasLogName = False,
  kwds 
)

Wrap a C++ SimpleAlgorithm class into both a Python SingleFramePlugin and ForcedPlugin classes.

Parameters
[in]AlgClassSwigged C++ Algorithm class to convert; must be a subclass of simpleAlgorithm, or an unrelated class with the same measure(), measureN(), and fail() signatures.
[in]executionOrderThe order this plugin should be run, relative to others (see BasePlugin.getExecutionOrder()).
[in]nameString to use when registering the algorithm. Ignored if doRegistry=False, set to generateAlgorithmName(AlgClass) if None.
[in]needsMetadataSets whether the AlgClass's constructor should be passed a PropertySet metadata argument.
[in]hasMeasureNWhether the algorithm supports simultaneous measurement of multiple sources. If True, a bool doMeasureN field will be added to the generated Config class, and its value will be passed as the last argument when calling the AlgClass constructor.
[in]hasLogNamePlugin supports a logName as a constructor argument
[in]**kwdsAdditional keyword arguments passed to the lower-level wrapAlgorithm and wrapAlgorithmControl classes. These include:
  • Control: Swigged C++ Control class for the algorithm; AlgClass.Control is used if None. Ignored if ConfigClass is not None.
  • ConfigClass: Python Config class that wraps the C++ Algorithm's swigged Control class. If None, wrapAlgorithmControl is called to generate a Config class using the Control argument.
  • doRegister: If True (the default), register the plugins with Base's registry, allowing it to be used by measurement Tasks.
  • shouldApCorr: does this algorithm measure a flux that can be aperture corrected? This is shorthand for apCorrList=[name] and is ignored if apCorrList is specified.
  • apCorrList: list of field name prefixes for flux fields that should be aperture corrected. If an algorithm produces a single flux that should be aperture corrected then it is simpler to set shouldApCorr=True. But if an algorithm produces multiple such fields then it must specify apCorrList, instead. For example modelfit_CModel produces 3 such fields: apCorrList= ("modelfit_CModel_exp", "modelfit_CModel_exp", "modelfit_CModel_def") If apCorrList is non-empty then shouldApCorr is ignored. If non-empty and doRegister is True then the names are added to the set retrieved by getApCorrNameSet
  • executionOrder: If not None, an override for the default executionOrder for this plugin (the default is 2.0, which is usually appropriate for fluxes).
Returns
a two-element tuple, containing the new SingleFramePlugin and ForcedPlugin subclasses

The needsMetadata and hasMeasureN arguments combine to determine the expected constructor signature; we always expect the first three arguments to be:

Control const & ctrl, std::string const & name, Schema & schema

If needsMetadata, we also append:

PropertySet & metadata

If hasMeasureN, we also append:

bool doMeasureN

If hasLogName, we also append:

std::string logName

If more than one is True, the metadata PropertySet precedes the doMeasureN bool and the logName comes last of the three

Definition at line 357 of file wrappers.py.

◆ wrapSingleFrameAlgorithm()

def lsst.meas.base.wrappers.wrapSingleFrameAlgorithm (   AlgClass,
  executionOrder,
  name = None,
  needsMetadata = False,
  hasMeasureN = False,
  hasLogName = False,
  kwds 
)

Wrap a C++ SingleFrameAlgorithm class into a Python SingleFramePlugin class.

Parameters
[in]AlgClassSwigged C++ Algorithm class to convert; must be a subclass of SingleFrameAlgorithm, or an unrelated class with the same measure(), measureN(), and fail() signatures.
[in]executionOrderThe order this plugin should be run, relative to others (see BasePlugin.getExecutionOrder()).
[in]nameString to use when registering the algorithm. Ignored if doRegistry=False, set to generateAlgorithmName(AlgClass) if None.
[in]needsMetadataSets whether the AlgClass's constructor should be passed a PropertySet metadata argument.
[in]hasMeasureNWhether the algorithm supports simultaneous measurement of multiple sources. If True, a bool doMeasureN field will be added to the generated Config class, and its value will be passed as the last argument when calling the AlgClass constructor.
[in]hasLogNamePlugin supports a logName as a constructor argument
[in]**kwdsAdditional keyword arguments passed to the lower-level wrapAlgorithm and wrapAlgorithmControl classes. These include:
  • Control: Swigged C++ Control class for the algorithm; AlgClass.Control is used if None. Ignored if ConfigClass is not None.
  • ConfigClass: Python Config class that wraps the C++ Algorithm's swigged Control class. If None, wrapAlgorithmControl is called to generate a Config class using the Control argument.
  • doRegister: If True (the default), register the plugin with SingleFramePlugin.registry, allowing it to be used by SingleFrameMeasurementTask.
  • shouldApCorr: does this algorithm measure a flux that can be aperture corrected? This is shorthand for apCorrList=[name] and is ignored if apCorrList is specified.
  • apCorrList: list of field name prefixes for flux fields that should be aperture corrected. If an algorithm produces a single flux that should be aperture corrected then it is simpler to set shouldApCorr=True. But if an algorithm produces multiple such fields then it must specify apCorrList, instead. For example modelfit_CModel produces 3 such fields: apCorrList= ("modelfit_CModel_exp", "modelfit_CModel_exp", "modelfit_CModel_def") If apCorrList is non-empty then shouldApCorr is ignored. If non-empty and doRegister is True then the names are added to the set retrieved by getApCorrNameSet
  • executionOrder: If not None, an override for the default executionOrder for this plugin (the default is 2.0, which is usually appropriate for fluxes).
Returns
the new SingleFramePlugin subclass

The needsMetadata and hasMeasureN arguments combine to determine the expected constructor signature; we always expect the first three arguments to be:

Control const & ctrl, std::string const & name, Schema & schema

If needsMetadata, we also append:

PropertySet & metadata

If hasMeasureN, we also append:

bool doMeasureN

If hasLogName, we also append:

std::string logName

If more than one is True, the metadata PropertySet precedes the doMeasureN bool and the logName comes last of the three

Definition at line 168 of file wrappers.py.

◆ wrapTransform()

def lsst.meas.base.wrappers.wrapTransform (   transformClass,
  hasLogName = False 
)
Modify a C++ Transform class so that it can be configured with either a Config or a Control.

Parameters
----------
transformClass: class
    A Transform class. Its constructor must take a Control, a string, and
    a SchemaMapper, in that order.

Definition at line 428 of file wrappers.py.