LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Classes | Functions | Variables
lsst.meas.base.wrappers Namespace Reference

Classes

class  WrappedSingleFramePlugin
 
class  WrappedForcedPlugin
 

Functions

def wrapAlgorithmControl
 Wrap a C++ algorithm's control class into a Python Config class. More...
 
def wrapAlgorithm
 Wrap a C++ Algorithm class into a Python Plugin class. More...
 
def wrapSingleFrameAlgorithm
 Wrap a C++ SingleFrameAlgorithm class into a Python SingleFramePlugin class. More...
 
def wrapForcedAlgorithm
 Wrap a C++ ForcedAlgorithm class into a Python ForcedPlugin class. More...
 
def wrapSimpleAlgorithm
 Wrap a C++ SimpleAlgorithm class into both a Python SingleFramePlugin and ForcedPlugin classes. More...
 

Variables

tuple __all__ = ("wrapSingleFrameAlgorithm", "wrapForcedAlgorithm", "wrapSimpleAlgorithm")
 

Function Documentation

def lsst.meas.base.wrappers.wrapAlgorithm (   Base,
  AlgClass,
  factory,
  executionOrder,
  name = None,
  Control = None,
  ConfigClass = None,
  TransformClass = None,
  doRegister = True,
  shouldApCorr = False,
  apCorrList = (),
  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]**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 79 of file wrappers.py.

79 
80  apCorrList=(), **kwds):
81  """!
82  Wrap a C++ Algorithm class into a Python Plugin class.
83 
84  @param[in] Base Base class for the returned Plugin; one of SingleFramePlugin or
85  ForcedPlugin
86  @param[in] AlgClass Swigged C++ Algorithm class to convert; must be a subclass of
87  SingleFrameAlgorithm or ForcedAlgorithm (matching the Base argument), or
88  an unrelated class with the same measure() and measureN() signatures as
89  those base classes.
90  @param[in] factory A callable that is used to construct an instance of AlgClass. It must take
91  four arguments, either (config, name, schema, metadata) or
92  (config, name, schemaMapper, metadata), depending on whether the algorithm is
93  single-frame or forced.
94  @param[in] executionOrder The order this plugin should be run, relative to others
95  (see BasePlugin.getExecutionOrder()).
96  @param[in] name String to use when registering the algorithm. Ignored if doRegistry=False,
97  set to generateAlgorithmName(AlgClass) if None.
98  @param[in] Control Swigged C++ Control class for the algorithm; AlgClass.Control is used if None.
99  Ignored if ConfigClass is not None.
100  @param[in] ConfigClass Python Config class that wraps the C++ Algorithm's swigged Control class. If
101  None, wrapAlgorithmControl is called to generate a Config class using the
102  Control argument.
103  @param[in] TransformClass Transformation which may be used to post-process the results of measurement.
104  If None, the default (defined by BasePlugin) is used.
105  @param[in] doRegister If True (the default), register the plugin with Base's registry, allowing it
106  to be used by measurement Tasks.
107  @param[in] shouldApCorr Does this algorithm measure a flux that can be aperture corrected? This is
108  shorthand for apCorrList=[name] and is ignored if apCorrList is specified.
109  @param[in] apCorrList List of field name prefixes for flux fields that should be aperture corrected.
110  If an algorithm produces a single flux that should be
111  aperture corrected then it is simpler to set shouldApCorr=True. But if an
112  algorithm produces multiple such fields then it must specify apCorrList,
113  instead. For example modelfit_CModel produces 3 such fields: apCorrList=
114  ("modelfit_CModel_exp", "modelfit_CModel_exp", "modelfit_CModel_def")
115  If apCorrList is non-empty then shouldApCorr is ignored.
116  If non-empty and doRegister is True then the names are added to the set
117  retrieved by getApCorrNameSet
118 
119 
120  @param[in] **kwds Additional keyword arguments passed to generateAlgorithmControl, including:
121  - hasMeasureN: Whether the plugin supports fitting multiple objects at once
122  (if so, a config option to enable/disable this will be added).
123  - executionOrder: If not None, an override for the default executionOrder for
124  this plugin (the default is 2.0, which is usually appropriate for fluxes).
125 
126  @return the new Plugin class, a subclass of Base
127 
128  This function is generally only called by the public wrapSingleFrameAlgorithm, wrapForcedAlgorithm, and
129  wrapSimpleAlgorithm functions; it is unlikely users will have to call it directly.
130  """
131  if ConfigClass is None:
132  if Control is None:
133  Control = AlgClass.Control
134  ConfigClass = wrapAlgorithmControl(Base.ConfigClass, Control, **kwds)
135  def getExecutionOrder():
136  return executionOrder
137  typeDict = dict(AlgClass=AlgClass, ConfigClass=ConfigClass, factory=staticmethod(factory),
138  getExecutionOrder=staticmethod(getExecutionOrder))
139  if TransformClass:
140  typeDict['getTransformClass'] = staticmethod(lambda: TransformClass)
141  PluginClass = type(AlgClass.__name__ + Base.__name__, (Base,), typeDict)
142  if doRegister:
143  if name is None:
144  name = generateAlgorithmName(AlgClass)
145  Base.registry.register(name, PluginClass)
146  if shouldApCorr:
147  addApCorrName(name)
148  return PluginClass
149 
def wrapAlgorithmControl
Wrap a C++ algorithm's control class into a Python Config class.
Definition: wrappers.py:43
def addApCorrName
Add to the set of field name prefixes for fluxes that should be aperture corrected.
def lsst.meas.base.wrappers.wrapAlgorithmControl (   Base,
  Control,
  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]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 43 of file wrappers.py.

43 
44 def wrapAlgorithmControl(Base, Control, hasMeasureN=False):
45  """!
46  Wrap a C++ algorithm's control class into a Python Config class.
47 
48  @param[in] Base Base class for the returned ConfigClass; one of SingleFramePluginConfig or
49  ForcedPluginConfig
50  @param[in] Control Control class to be wrapped (a Swigged C++ class)
51  @param[in] hasMeasureN Whether the plugin supports fitting multiple objects at once (if so, a
52  config option to enable/disable this will be added).
53 
54  @return a new subclass of lsst.pex.config.Config
55 
56  This function is generally only called by wrapAlgorithm; it is unlikely users will have to call it
57  directly.
58  """
59  if hasMeasureN:
60  # We need to add a Config field to enable multi-object measurement, to replace
61  # the simple bool class attribute that's on the base class. To do that, we
62  # create the Config class dynamically here, then call makeControlClass to finish
63  # it off by adding fields from the control object.
64  cls = type(
65  Control.__name__.replace("Control", "Config"),
66  (Base,),
67  {"doMeasureN": lsst.pex.config.Field(dtype=bool, default=True,
68  doc="whether to run this plugin in multi-object mode")}
69  )
70  ConfigClass = lsst.pex.config.makeConfigClass(Control, module=Control.__module__, cls=cls)
71  else:
72  # If we don't have to add that Config field, we can delegate all of the work to
73  # pex_config's makeControlClass
74  ConfigClass = lsst.pex.config.makeConfigClass(Control, module=Control.__module__, base=Base)
75  return ConfigClass
76 
def wrapAlgorithmControl
Wrap a C++ algorithm's control class into a Python Config class.
Definition: wrappers.py:43
def lsst.meas.base.wrappers.wrapForcedAlgorithm (   AlgClass,
  executionOrder,
  name = None,
  needsMetadata = False,
  hasMeasureN = False,
  needsSchemaOnly = 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]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 both are True, the metadata PropertySet precedes the doMeasureN bool.

Definition at line 229 of file wrappers.py.

230  hasMeasureN=False, needsSchemaOnly=False, **kwds):
231  """!
232  Wrap a C++ ForcedAlgorithm class into a Python ForcedPlugin class.
233 
234  @param[in] AlgClass Swigged C++ Algorithm class to convert; must be a subclass of
235  ForcedAlgorithm, or an unrelated class with the same measure(), measureN(),
236  and fail() signatures.
237  @param[in] executionOrder The order this plugin should be run, relative to others
238  (see BasePlugin.getExecutionOrder()).
239  @param[in] name String to use when registering the algorithm. Ignored if doRegistry=False,
240  set to generateAlgorithmName(AlgClass) if None.
241  @param[in] needsMetadata Sets whether the AlgClass's constructor should be passed a PropertySet
242  metadata argument.
243  @param[in] hasMeasureN Whether the algorithm supports simultaneous measurement of multiple sources.
244  If True, a bool doMeasureN field will be added to the generated Config class,
245  and its value will be passed as the last argument when calling the AlgClass
246  constructor.
247  @param[in] needsSchemaOnly Whether the algorithm constructor expects a Schema argument (representing the
248  output Schema) rather than the full SchemaMapper (which provides access to
249  both the reference Schema and the output Schema).
250  @param[in] **kwds Additional keyword arguments passed to the lower-level wrapAlgorithm and
251  wrapAlgorithmControl classes. These include:
252  - Control: Swigged C++ Control class for the algorithm; AlgClass.Control
253  is used if None. Ignored if ConfigClass is not None.
254  - ConfigClass: Python Config class that wraps the C++ Algorithm's swigged
255  Control class. If None, wrapAlgorithmControl is called to generate a
256  Config class using the Control argument.
257  - doRegister: If True (the default), register the plugin with
258  ForcedPlugin.registry, allowing it to be used by ForcedMeasurementTask.
259  - shouldApCorr: does this algorithm measure a flux that can be aperture
260  corrected? This is shorthand for apCorrList=[name] and is ignored if
261  apCorrList is specified.
262  - apCorrList: list of field name prefixes for flux fields that should be
263  aperture corrected. If an algorithm produces a single flux that should be
264  aperture corrected then it is simpler to set shouldApCorr=True. But if an
265  algorithm produces multiple such fields then it must specify apCorrList,
266  instead. For example modelfit_CModel produces 3 such fields: apCorrList=
267  ("modelfit_CModel_exp", "modelfit_CModel_exp", "modelfit_CModel_def")
268  If apCorrList is non-empty then shouldApCorr is ignored.
269  If non-empty and doRegister is True then the names are added to the set
270  retrieved by getApCorrNameSet
271  - executionOrder: If not None, an override for the default executionOrder for
272  this plugin (the default is 2.0, which is usually appropriate for fluxes).
273 
274  @return the new ForcedPlugin subclass
275 
276  The needsMetadata, hasMeasureN, and needsSchemaOnly arguments combine to determine the expected
277  constructor signature; we always expect the first two arguments to be:
278  @verbatim
279  Control const & ctrl, std::string const & name
280  @endverbatim
281  If needsSchemaOnly is True, then the third argument will be
282  @verbatim
283  Schema & schema
284  @endverbatim
285  otherwise, it will be:
286  @verbatim
287  SchemaMapper & schemaMapper
288  @endverbatim
289  If needsMetadata, we also append:
290  @verbatim
291  PropertySet & metadata
292  @endverbatim
293  If hasMeasureN, we also append:
294  @verbatim
295  bool doMeasureN
296  @endverbatim
297  If both are True, the metadata PropertySet precedes the doMeasureN bool.
298  """
299  if needsSchemaOnly:
300  extractSchemaArg = lambda m: m.editOutputSchema()
301  else:
302  extractSchemaArg = lambda m: m
303  if hasMeasureN:
304  if needsMetadata:
305  def factory(config, name, schemaMapper, metadata):
306  return AlgClass(config.makeControl(), name, extractSchemaArg(schemaMapper),
307  metadata, config.doMeasureN)
308  else:
309  def factory(config, name, schemaMapper, metadata):
310  return AlgClass(config.makeControl(), name, extractSchemaArg(schemaMapper),
311  config.doMeasureN)
312  else:
313  if needsMetadata:
314  def factory(config, name, schemaMapper, metadata):
315  return AlgClass(config.makeControl(), name, extractSchemaArg(schemaMapper),
316  metadata)
317  else:
318  def factory(config, name, schemaMapper, metadata):
319  return AlgClass(config.makeControl(), name, extractSchemaArg(schemaMapper))
320  return wrapAlgorithm(WrappedForcedPlugin, AlgClass, executionOrder=executionOrder, name=name,
321  factory=factory, **kwds)
322 
def wrapAlgorithm
Wrap a C++ Algorithm class into a Python Plugin class.
Definition: wrappers.py:79
def lsst.meas.base.wrappers.wrapSimpleAlgorithm (   AlgClass,
  executionOrder,
  name = None,
  needsMetadata = False,
  hasMeasureN = 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]**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 both are True, the metadata PropertySet precedes the doMeasureN bool.

Definition at line 323 of file wrappers.py.

324 def wrapSimpleAlgorithm(AlgClass, executionOrder, name=None, needsMetadata=False, hasMeasureN=False, **kwds):
325  """!
326  Wrap a C++ SimpleAlgorithm class into both a Python SingleFramePlugin and ForcedPlugin classes
327 
328  @param[in] AlgClass Swigged C++ Algorithm class to convert; must be a subclass of
329  simpleAlgorithm, or an unrelated class with the same measure(), measureN(),
330  and fail() signatures.
331  @param[in] executionOrder The order this plugin should be run, relative to others
332  (see BasePlugin.getExecutionOrder()).
333  @param[in] name String to use when registering the algorithm. Ignored if doRegistry=False,
334  set to generateAlgorithmName(AlgClass) if None.
335  @param[in] needsMetadata Sets whether the AlgClass's constructor should be passed a PropertySet
336  metadata argument.
337  @param[in] hasMeasureN Whether the algorithm supports simultaneous measurement of multiple sources.
338  If True, a bool doMeasureN field will be added to the generated Config class,
339  and its value will be passed as the last argument when calling the AlgClass
340  constructor.
341  @param[in] **kwds Additional keyword arguments passed to the lower-level wrapAlgorithm and
342  wrapAlgorithmControl classes. These include:
343  - Control: Swigged C++ Control class for the algorithm; AlgClass.Control
344  is used if None. Ignored if ConfigClass is not None.
345  - ConfigClass: Python Config class that wraps the C++ Algorithm's swigged
346  Control class. If None, wrapAlgorithmControl is called to generate a
347  Config class using the Control argument.
348  - doRegister: If True (the default), register the plugins with Base's
349  registry, allowing it to be used by measurement Tasks.
350  - shouldApCorr: does this algorithm measure a flux that can be aperture
351  corrected? This is shorthand for apCorrList=[name] and is ignored if
352  apCorrList is specified.
353  - apCorrList: list of field name prefixes for flux fields that should be
354  aperture corrected. If an algorithm produces a single flux that should be
355  aperture corrected then it is simpler to set shouldApCorr=True. But if an
356  algorithm produces multiple such fields then it must specify apCorrList,
357  instead. For example modelfit_CModel produces 3 such fields: apCorrList=
358  ("modelfit_CModel_exp", "modelfit_CModel_exp", "modelfit_CModel_def")
359  If apCorrList is non-empty then shouldApCorr is ignored.
360  If non-empty and doRegister is True then the names are added to the set
361  retrieved by getApCorrNameSet
362  - executionOrder: If not None, an override for the default executionOrder for
363  this plugin (the default is 2.0, which is usually appropriate for fluxes).
364 
365  @return a two-element tuple, containing the new SingleFramePlugin and ForcedPlugin subclasses
366 
367  The needsMetadata and hasMeasureN arguments combine to determine the expected constructor signature;
368  we always expect the first three arguments to be:
369  @verbatim
370  Control const & ctrl, std::string const & name, Schema & schema
371  @endverbatim
372  If needsMetadata, we also append:
373  @verbatim
374  PropertySet & metadata
375  @endverbatim
376  If hasMeasureN, we also append:
377  @verbatim
378  bool doMeasureN
379  @endverbatim
380  If both are True, the metadata PropertySet precedes the doMeasureN bool.
381  """
382  return (wrapSingleFrameAlgorithm(AlgClass, executionOrder=executionOrder, name=name,
383  needsMetadata=needsMetadata, **kwds),
384  wrapForcedAlgorithm(AlgClass, executionOrder=executionOrder, name=name,
385  needsMetadata=needsMetadata, needsSchemaOnly=True, **kwds))
def wrapSingleFrameAlgorithm
Wrap a C++ SingleFrameAlgorithm class into a Python SingleFramePlugin class.
Definition: wrappers.py:151
def wrapForcedAlgorithm
Wrap a C++ ForcedAlgorithm class into a Python ForcedPlugin class.
Definition: wrappers.py:229
def wrapSimpleAlgorithm
Wrap a C++ SimpleAlgorithm class into both a Python SingleFramePlugin and ForcedPlugin classes...
Definition: wrappers.py:323
def lsst.meas.base.wrappers.wrapSingleFrameAlgorithm (   AlgClass,
  executionOrder,
  name = None,
  needsMetadata = False,
  hasMeasureN = 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]**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 both are True, the metadata PropertySet precedes the doMeasureN bool.

Definition at line 151 of file wrappers.py.

152  **kwds):
153  """!
154  Wrap a C++ SingleFrameAlgorithm class into a Python SingleFramePlugin class.
155 
156  @param[in] AlgClass Swigged C++ Algorithm class to convert; must be a subclass of
157  SingleFrameAlgorithm, or an unrelated class with the same measure(),
158  measureN(), and fail() signatures.
159  @param[in] executionOrder The order this plugin should be run, relative to others
160  (see BasePlugin.getExecutionOrder()).
161  @param[in] name String to use when registering the algorithm. Ignored if doRegistry=False,
162  set to generateAlgorithmName(AlgClass) if None.
163  @param[in] needsMetadata Sets whether the AlgClass's constructor should be passed a PropertySet
164  metadata argument.
165  @param[in] hasMeasureN Whether the algorithm supports simultaneous measurement of multiple sources.
166  If True, a bool doMeasureN field will be added to the generated Config class,
167  and its value will be passed as the last argument when calling the AlgClass
168  constructor.
169  @param[in] **kwds Additional keyword arguments passed to the lower-level wrapAlgorithm and
170  wrapAlgorithmControl classes. These include:
171  - Control: Swigged C++ Control class for the algorithm; AlgClass.Control
172  is used if None. Ignored if ConfigClass is not None.
173  - ConfigClass: Python Config class that wraps the C++ Algorithm's swigged
174  Control class. If None, wrapAlgorithmControl is called to generate a
175  Config class using the Control argument.
176  - doRegister: If True (the default), register the plugin with
177  SingleFramePlugin.registry, allowing it to be used by
178  SingleFrameMeasurementTask.
179  - shouldApCorr: does this algorithm measure a flux that can be aperture
180  corrected? This is shorthand for apCorrList=[name] and is ignored if
181  apCorrList is specified.
182  - apCorrList: list of field name prefixes for flux fields that should be
183  aperture corrected. If an algorithm produces a single flux that should be
184  aperture corrected then it is simpler to set shouldApCorr=True. But if an
185  algorithm produces multiple such fields then it must specify apCorrList,
186  instead. For example modelfit_CModel produces 3 such fields: apCorrList=
187  ("modelfit_CModel_exp", "modelfit_CModel_exp", "modelfit_CModel_def")
188  If apCorrList is non-empty then shouldApCorr is ignored.
189  If non-empty and doRegister is True then the names are added to the set
190  retrieved by getApCorrNameSet
191  - executionOrder: If not None, an override for the default executionOrder for
192  this plugin (the default is 2.0, which is usually appropriate for fluxes).
193 
194  @return the new SingleFramePlugin subclass
195 
196  The needsMetadata and hasMeasureN arguments combine to determine the expected constructor signature;
197  we always expect the first three arguments to be:
198  @verbatim
199  Control const & ctrl, std::string const & name, Schema & schema
200  @endverbatim
201  If needsMetadata, we also append:
202  @verbatim
203  PropertySet & metadata
204  @endverbatim
205  If hasMeasureN, we also append:
206  @verbatim
207  bool doMeasureN
208  @endverbatim
209  If both are True, the metadata PropertySet precedes the doMeasureN bool.
210  """
211  if hasMeasureN:
212  if needsMetadata:
213  def factory(config, name, schema, metadata):
214  return AlgClass(config.makeControl(), name, schema, metadata, config.doMeasureN)
215  else:
216  def factory(config, name, schema, metadata):
217  return AlgClass(config.makeControl(), name, schema, config.doMeasureN)
218  else:
219  if needsMetadata:
220  def factory(config, name, schema, metadata):
221  return AlgClass(config.makeControl(), name, schema, metadata)
222  else:
223  def factory(config, name, schema, metadata):
224  return AlgClass(config.makeControl(), name, schema)
225  return wrapAlgorithm(WrappedSingleFramePlugin, AlgClass, executionOrder=executionOrder, name=name,
226  factory=factory, hasMeasureN=hasMeasureN, **kwds)
227 
def wrapAlgorithm
Wrap a C++ Algorithm class into a Python Plugin class.
Definition: wrappers.py:79

Variable Documentation

tuple lsst.meas.base.wrappers.__all__ = ("wrapSingleFrameAlgorithm", "wrapForcedAlgorithm", "wrapSimpleAlgorithm")

Definition at line 8 of file wrappers.py.