LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Classes | Functions
lsst.meas.base.wrappers Namespace Reference

Classes

class  WrappedSingleFramePlugin
 
class  WrappedForcedPlugin
 
class  GenericPlugin
 

Functions

def wrapAlgorithmControl (Base, Control, module=None, hasMeasureN=False)
 
def wrapAlgorithm (Base, AlgClass, factory, executionOrder, name=None, Control=None, ConfigClass=None, TransformClass=None, doRegister=True, shouldApCorr=False, apCorrList=(), hasLogName=False, **kwds)
 
def wrapSingleFrameAlgorithm (AlgClass, executionOrder, name=None, needsMetadata=False, hasMeasureN=False, hasLogName=False, **kwds)
 
def wrapForcedAlgorithm (AlgClass, executionOrder, name=None, needsMetadata=False, hasMeasureN=False, needsSchemaOnly=False, hasLogName=False, **kwds)
 
def wrapSimpleAlgorithm (AlgClass, executionOrder, name=None, needsMetadata=False, hasMeasureN=False, hasLogName=False, **kwds)
 
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 to create a measurement plugin.

Parameters
----------
Base : `SingleFramePlugin` or `ForcedPlugin`
    Base class for the returned Plugin.
AlgClass : API compatible with `SingleFrameAlgorithm` or `ForcedAlgorithm`
    C++ algorithm class to convert. May either derive directly from
    `SingleFrameAlgorithm` or `ForcedAlgorithm`, or be an unrelated class
    which has the same ``measure`` and ``measureN`` signatures.
factory : callable
    A 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.
executionOrder : `float`
    The order this plugin should be run, relative to others
    (see `BasePlugin.getExecutionOrder`).
name : `str`, optional
    String to use when registering the algorithm. Ignored if
    ``doRegistry=False``, set to ``generateAlgorithmName(AlgClass)`` if
    `None`.
Control : Pybind11-wrapped version of a C++ class, optional
    Pybind11-wrapped C++ Control class for the algorithm;
    ``AlgClass.Control`` is used if `None`. Ignored if ``ConfigClass``
    is not `None`.
ConfigClass : subclass of `BaseMeasurementPluginConfig`
    Python config class that wraps the C++ algorithm's pybind11-wrapped
    Control class.  If `None`, `wrapAlgorithmControl` is called to
    generate a Config class using the ``Control`` argument.
TransformClass : subclass of `MeasurementTransform`, optional
    Transformation which may be used to post-process the results of
    measurement.  If `None`, the default defined by `BasePlugin` is
    used.
doRegister : `bool`, optional
    If `True` (the default), register the plugin with ``Base``'s
    registry, allowing it to be used by measurement tasks.
shouldApCorr : `bool`, optional
    Does this algorithm measure an instFlux that can be aperture
    corrected?  This is shorthand for ``apCorrList=[name]`` and is ignored
    if ``apCorrList`` is specified.
apCorrList : iterable of `str`, optional
    Field name prefixes for instFlux fields to be aperture corrected. If
    an algorithm measures a single instFlux that should be aperture
    corrected, then it is simpler to set ``shouldApCorr=True``. However,
    if an algorithm produces multiple such fields, then specify
    ``apCorrList`` instead.  For example, ``modelfit_CModel`` produces
    three such fields: ``apCorrList= ("modelfit_CModel_exp",
    "modelfit_CModel_exp", "modelfit_CModel_def")`` If ``apCorrList`` is
    not empty then ``shouldApCorr`` is ignored.  If non-empty and
    ``doRegister`` is `True` then the names are added to the set
    retrieved by ``getApCorrNameSet``.
hasLogName : `bool`, optional
    `True` if the C++ algorithm supports ``logName`` as a constructor
    argument.
**kwds
    Additional keyword arguments passed to generateAlgorithmControl, which
    may include:

    - ``hasMeasureN``:  Whether the plugin supports fitting multiple
      objects at once ;if so, a config option to enable/disable this will
      be added (`bool`).
    - ``executionOrder``: If not `None`, an override for the default
      execution order for this plugin (the default is ``2.0``, which is
      usually appropriate for fluxes; `bool`).

Returns
-------
PluginClass : subclass of ``Base``
    The new plugin class.

Definition at line 122 of file wrappers.py.

124  apCorrList=(), hasLogName=False, **kwds):
125  """Wrap a C++ algorithm class to create a measurement plugin.
126 
127  Parameters
128  ----------
129  Base : `SingleFramePlugin` or `ForcedPlugin`
130  Base class for the returned Plugin.
131  AlgClass : API compatible with `SingleFrameAlgorithm` or `ForcedAlgorithm`
132  C++ algorithm class to convert. May either derive directly from
133  `SingleFrameAlgorithm` or `ForcedAlgorithm`, or be an unrelated class
134  which has the same ``measure`` and ``measureN`` signatures.
135  factory : callable
136  A callable that is used to construct an instance of ``AlgClass``. It
137  must take four arguments, either ``(config, name, schema, metadata)``
138  or ``(config, name, schemaMapper, metadata)``, depending on whether
139  the algorithm is single-frame or forced.
140  executionOrder : `float`
141  The order this plugin should be run, relative to others
142  (see `BasePlugin.getExecutionOrder`).
143  name : `str`, optional
144  String to use when registering the algorithm. Ignored if
145  ``doRegistry=False``, set to ``generateAlgorithmName(AlgClass)`` if
146  `None`.
147  Control : Pybind11-wrapped version of a C++ class, optional
148  Pybind11-wrapped C++ Control class for the algorithm;
149  ``AlgClass.Control`` is used if `None`. Ignored if ``ConfigClass``
150  is not `None`.
151  ConfigClass : subclass of `BaseMeasurementPluginConfig`
152  Python config class that wraps the C++ algorithm's pybind11-wrapped
153  Control class. If `None`, `wrapAlgorithmControl` is called to
154  generate a Config class using the ``Control`` argument.
155  TransformClass : subclass of `MeasurementTransform`, optional
156  Transformation which may be used to post-process the results of
157  measurement. If `None`, the default defined by `BasePlugin` is
158  used.
159  doRegister : `bool`, optional
160  If `True` (the default), register the plugin with ``Base``'s
161  registry, allowing it to be used by measurement tasks.
162  shouldApCorr : `bool`, optional
163  Does this algorithm measure an instFlux that can be aperture
164  corrected? This is shorthand for ``apCorrList=[name]`` and is ignored
165  if ``apCorrList`` is specified.
166  apCorrList : iterable of `str`, optional
167  Field name prefixes for instFlux fields to be aperture corrected. If
168  an algorithm measures a single instFlux that should be aperture
169  corrected, then it is simpler to set ``shouldApCorr=True``. However,
170  if an algorithm produces multiple such fields, then specify
171  ``apCorrList`` instead. For example, ``modelfit_CModel`` produces
172  three such fields: ``apCorrList= ("modelfit_CModel_exp",
173  "modelfit_CModel_exp", "modelfit_CModel_def")`` If ``apCorrList`` is
174  not empty then ``shouldApCorr`` is ignored. If non-empty and
175  ``doRegister`` is `True` then the names are added to the set
176  retrieved by ``getApCorrNameSet``.
177  hasLogName : `bool`, optional
178  `True` if the C++ algorithm supports ``logName`` as a constructor
179  argument.
180  **kwds
181  Additional keyword arguments passed to generateAlgorithmControl, which
182  may include:
183 
184  - ``hasMeasureN``: Whether the plugin supports fitting multiple
185  objects at once ;if so, a config option to enable/disable this will
186  be added (`bool`).
187  - ``executionOrder``: If not `None`, an override for the default
188  execution order for this plugin (the default is ``2.0``, which is
189  usually appropriate for fluxes; `bool`).
190 
191  Returns
192  -------
193  PluginClass : subclass of ``Base``
194  The new plugin class.
195  """
196  if ConfigClass is None:
197  if Control is None:
198  Control = AlgClass.Control
199  ConfigClass = wrapAlgorithmControl(Base.ConfigClass, Control, **kwds)
200 
201  def getExecutionOrder():
202  return executionOrder
203  typeDict = dict(AlgClass=AlgClass, ConfigClass=ConfigClass, factory=staticmethod(factory),
204  getExecutionOrder=staticmethod(getExecutionOrder))
205  if TransformClass:
206  typeDict['getTransformClass'] = staticmethod(lambda: TransformClass)
207  PluginClass = type(AlgClass.__name__ + Base.__name__, (Base,), typeDict)
208  if doRegister:
209  if name is None:
210  name = generateAlgorithmName(AlgClass)
211  Base.registry.register(name, PluginClass)
212  if shouldApCorr:
213  addApCorrName(name)
214  PluginClass.hasLogName = hasLogName
215  return PluginClass
216 
217 
table::Key< int > type
Definition: Detector.cc:163
def wrapAlgorithmControl(Base, Control, module=None, hasMeasureN=False)
Definition: wrappers.py:71

◆ wrapAlgorithmControl()

def lsst.meas.base.wrappers.wrapAlgorithmControl (   Base,
  Control,
  module = None,
  hasMeasureN = False 
)
Wrap a C++ algorithm's control class into a Python config class.

Parameters
----------
Base : `SingleFramePluginConfig` or `ForcedPluginConfig`
    Base class for the returned config.
Control : pybind11-wrapped version of a C++ class.
    Control class to be wrapped.
module : module, `str`, `int`, or `None`; optional
    Either 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 `lsst.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 none in which
    case module will be looked up from Control.
hasMeasureN : `bool`, optional
    Whether the plugin supports fitting multiple objects at once (if so, a
    config option to enable/disable this will be added).

Returns
-------
ConfigClass : `lsst.pex.config.Config`
    A new subclass of lsst.pex.config.Config.

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

Definition at line 71 of file wrappers.py.

71 def wrapAlgorithmControl(Base, Control, module=None, hasMeasureN=False):
72  """Wrap a C++ algorithm's control class into a Python config class.
73 
74  Parameters
75  ----------
76  Base : `SingleFramePluginConfig` or `ForcedPluginConfig`
77  Base class for the returned config.
78  Control : pybind11-wrapped version of a C++ class.
79  Control class to be wrapped.
80  module : module, `str`, `int`, or `None`; optional
81  Either a module object, a string specifying the name of the module, or
82  an integer specifying how far back in the stack to look for the module
83  to use: ``0`` is `lsst.pex.config.wrap`, ``1`` is
84  `lsst.meas.base.wrappers`, ``2`` is the immediate caller, etc. This
85  will be used to set ``__module__`` for the new config class, and the
86  class will also be added to the module. The default is none in which
87  case module will be looked up from Control.
88  hasMeasureN : `bool`, optional
89  Whether the plugin supports fitting multiple objects at once (if so, a
90  config option to enable/disable this will be added).
91 
92  Returns
93  -------
94  ConfigClass : `lsst.pex.config.Config`
95  A new subclass of lsst.pex.config.Config.
96 
97  Notes
98  -----
99  This function is generally only called by `wrapAlgorithm`; it is unlikely
100  users will have to call it directly.
101  """
102  if hasMeasureN:
103  # We need to add a Config field to enable multi-object measurement, to
104  # replace the simple bool class attribute that's on the base class.
105  # To do that, we create the Config class dynamically here, then call
106  # makeControlClass to finish it off by adding fields from the control
107  # object.
108  cls = type(
109  Control.__name__.replace("Control", "Config"),
110  (Base,),
111  {"doMeasureN": lsst.pex.config.Field(dtype=bool, default=True,
112  doc="whether to run this plugin in multi-object mode")}
113  )
114  ConfigClass = lsst.pex.config.makeConfigClass(Control, module=module, cls=cls)
115  else:
116  # If we don't have to add that Config field, we can delegate all of
117  # the work to pex_config's makeControlClass
118  ConfigClass = lsst.pex.config.makeConfigClass(Control, module=module, base=Base)
119  return ConfigClass
120 
121 

◆ wrapForcedAlgorithm()

def lsst.meas.base.wrappers.wrapForcedAlgorithm (   AlgClass,
  executionOrder,
  name = None,
  needsMetadata = False,
  hasMeasureN = False,
  needsSchemaOnly = False,
  hasLogName = False,
**  kwds 
)
Expose a C++ ``ForcedAlgorithm`` class as a measurement plugin.

Parameters
----------
AlgClass : API compatible with `ForcedAlgorithm`
    C++ algorithm class to convert. May either derive directly from
    `ForcedAlgorithm` or be an unrelated class which has the same
    ``measure``, ``measureN`` and ``fail`` signatures.
executionOrder : `float`
    The order this plugin should be run, relative to others
    (see `BasePlugin.getExecutionOrder`).
name : `str`, optional
    Name to use when registering the algorithm. Ignored if
    ``doRegistry=False``; set to ``generateAlgorithmName(AlgClass)`` if
    `None`.
needsMetadata : `bool`, optional
    Sets whether the ``AlgClass``'s constructor should be passed a
    `~lsst.daf.base.PropertySet` metadata argument.
hasMeasureN : `bool`, optional
    Does the algorithm support 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.
hasLogName : `bool`, optional
    `True` if the C++ algorithm supports ``logName`` as a constructor
    argument.
needsSchemaOnly : `bool`, optional
    Whether the algorithm constructor expects a Schema argument
    (representing the output `~lsst.afw.table.Schema`) rather than the
    full `~lsst.afw.table.SchemaMapper` (which provides access to both the
    reference schema and the output schema).
**kwds
    Additional keyword arguments are passed to the lower-level
    `wrapAlgorithm` and `wrapAlgorithmControl` classes.

Returns
-------
forcedPlugin : subclass of `ForcedPlugin`
    The new measurement plugin class.

Notes
-----
The first two arguments to the C++ constructor are expected 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`` is `True`, we also append ``PropertySet &
metadata``.

If ``hasMeasureN`` is `True`, we also append ``bool doMeasureN``.

If ``hasLogName`` is `True`, we also append ``std::string logName``.

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

Definition at line 289 of file wrappers.py.

290  hasMeasureN=False, needsSchemaOnly=False, hasLogName=False, **kwds):
291  """Expose a C++ ``ForcedAlgorithm`` class as a measurement plugin.
292 
293  Parameters
294  ----------
295  AlgClass : API compatible with `ForcedAlgorithm`
296  C++ algorithm class to convert. May either derive directly from
297  `ForcedAlgorithm` or be an unrelated class which has the same
298  ``measure``, ``measureN`` and ``fail`` signatures.
299  executionOrder : `float`
300  The order this plugin should be run, relative to others
301  (see `BasePlugin.getExecutionOrder`).
302  name : `str`, optional
303  Name to use when registering the algorithm. Ignored if
304  ``doRegistry=False``; set to ``generateAlgorithmName(AlgClass)`` if
305  `None`.
306  needsMetadata : `bool`, optional
307  Sets whether the ``AlgClass``'s constructor should be passed a
308  `~lsst.daf.base.PropertySet` metadata argument.
309  hasMeasureN : `bool`, optional
310  Does the algorithm support simultaneous measurement of multiple
311  sources? If `True`, a `bool` ``doMeasureN`` field will be added to
312  the generated config class, and its value will be passed as the last
313  argument when calling the ``AlgClass`` constructor.
314  hasLogName : `bool`, optional
315  `True` if the C++ algorithm supports ``logName`` as a constructor
316  argument.
317  needsSchemaOnly : `bool`, optional
318  Whether the algorithm constructor expects a Schema argument
319  (representing the output `~lsst.afw.table.Schema`) rather than the
320  full `~lsst.afw.table.SchemaMapper` (which provides access to both the
321  reference schema and the output schema).
322  **kwds
323  Additional keyword arguments are passed to the lower-level
324  `wrapAlgorithm` and `wrapAlgorithmControl` classes.
325 
326  Returns
327  -------
328  forcedPlugin : subclass of `ForcedPlugin`
329  The new measurement plugin class.
330 
331  Notes
332  -----
333  The first two arguments to the C++ constructor are expected to be
334  ``Control const & ctrl, std::string const & name``
335 
336  If ``needsSchemaOnly`` is `True`, then the third argument will be
337  ``Schema & schema``; otherwise, it will be ``SchemaMapper &
338  schemaMapper``.
339 
340  If ``needsMetadata`` is `True`, we also append ``PropertySet &
341  metadata``.
342 
343  If ``hasMeasureN`` is `True`, we also append ``bool doMeasureN``.
344 
345  If ``hasLogName`` is `True`, we also append ``std::string logName``.
346 
347  If more than one of the above is `True`, the metadata ``PropertySet``
348  precedes the ``doMeasureN`` ``bool`` and the ``logName`` comes last of the
349  three.
350  """
351  if needsSchemaOnly:
352  def extractSchemaArg(m):
353  return m.editOutputSchema()
354  else:
355  def extractSchemaArg(m):
356  return m
357  if hasMeasureN:
358  if needsMetadata:
359  def factory(config, name, schemaMapper, metadata, **kwargs):
360  return AlgClass(config.makeControl(), name, extractSchemaArg(schemaMapper),
361  metadata, config.doMeasureN, **kwargs)
362  else:
363  def factory(config, name, schemaMapper, metadata, **kwargs):
364  return AlgClass(config.makeControl(), name, extractSchemaArg(schemaMapper),
365  config.doMeasureN, **kwargs)
366  else:
367  if needsMetadata:
368  def factory(config, name, schemaMapper, metadata, **kwargs):
369  return AlgClass(config.makeControl(), name, extractSchemaArg(schemaMapper),
370  metadata, **kwargs)
371  else:
372  def factory(config, name, schemaMapper, metadata, **kwargs):
373  return AlgClass(config.makeControl(), name, extractSchemaArg(schemaMapper), **kwargs)
374 
375  return wrapAlgorithm(WrappedForcedPlugin, AlgClass, executionOrder=executionOrder, name=name,
376  factory=factory, hasLogName=hasLogName, **kwds)
377 
378 
def wrapAlgorithm(Base, AlgClass, factory, executionOrder, name=None, Control=None, ConfigClass=None, TransformClass=None, doRegister=True, shouldApCorr=False, apCorrList=(), hasLogName=False, **kwds)
Definition: wrappers.py:124

◆ wrapSimpleAlgorithm()

def lsst.meas.base.wrappers.wrapSimpleAlgorithm (   AlgClass,
  executionOrder,
  name = None,
  needsMetadata = False,
  hasMeasureN = False,
  hasLogName = False,
**  kwds 
)
Expose a C++ ``SimpleAlgorithm`` class as a measurement plugin.

``SimpleAlgorithm``\ s are made available as both `SingleFramePlugin`\ s
and `ForcedPlugin`\ s.

Parameters
----------
AlgClass : Subclass of C++ ``SimpleAlgorithm``, or API compatible
    Algorithm class to convert. The C++ class should be wrapped with
    Pybind11, and must provide ``measure()``, ``measureN()`` and ``fail()`
    signatures equivalent to ``SimpleAlgorithm``.
executionOrder : `float`
    The order this plugin should be run, relative to others
    (see `~BasePlugin.getExecutionOrder`).
name : `str`, optional
    Name to use when registering the algorithm. Ignored if
    ``doRegistry=False``; set to ``generateAlgorithmName(AlgClass)`` if
    `None`.
needsMetadata : `bool`, optional
    Sets whether the ``AlgClass``'s constructor should be passed a
    `~lsst.daf.base.PropertySet` metadata argument.
hasMeasureN : `bool`, optional
    Does the algorithm support 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.
hasLogName : `bool`, optional
    `True` if the C++ algorithm supports ``logName`` as a constructor
    argument.
**kwds
    Additional keyword arguments are passed to the lower-level
    `wrapAlgorithm` and `wrapAlgorithmControl` classes.

Returns
-------
singleFramePlugin : subclass of `SingleFramePlugin`
    The new single frame measurement plugin class.
forcedPlugin : subclass of `ForcedPlugin`
    The new forced measurement plugin class.

Notes
-----
The first three arguments to the C++ constructor are expected to be
``Control const & ctrl, std::string const & name, Schema & schema``.

If ``needsMetadata`` is `True`, we also append ``PropertySet &
metadata``.

If ``hasMeasureN`` is `True`, we also append ``bool doMeasureN``.

If ``hasLogName`` is `True`, we also append ``std::string logName``.

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

Definition at line 379 of file wrappers.py.

380  hasLogName=False, **kwds):
381  r"""Expose a C++ ``SimpleAlgorithm`` class as a measurement plugin.
382 
383  ``SimpleAlgorithm``\ s are made available as both `SingleFramePlugin`\ s
384  and `ForcedPlugin`\ s.
385 
386  Parameters
387  ----------
388  AlgClass : Subclass of C++ ``SimpleAlgorithm``, or API compatible
389  Algorithm class to convert. The C++ class should be wrapped with
390  Pybind11, and must provide ``measure()``, ``measureN()`` and ``fail()`
391  signatures equivalent to ``SimpleAlgorithm``.
392  executionOrder : `float`
393  The order this plugin should be run, relative to others
394  (see `~BasePlugin.getExecutionOrder`).
395  name : `str`, optional
396  Name to use when registering the algorithm. Ignored if
397  ``doRegistry=False``; set to ``generateAlgorithmName(AlgClass)`` if
398  `None`.
399  needsMetadata : `bool`, optional
400  Sets whether the ``AlgClass``'s constructor should be passed a
401  `~lsst.daf.base.PropertySet` metadata argument.
402  hasMeasureN : `bool`, optional
403  Does the algorithm support simultaneous measurement of multiple
404  sources? If `True`, a `bool` ``doMeasureN`` field will be added to
405  the generated config class, and its value will be passed as the last
406  argument when calling the ``AlgClass`` constructor.
407  hasLogName : `bool`, optional
408  `True` if the C++ algorithm supports ``logName`` as a constructor
409  argument.
410  **kwds
411  Additional keyword arguments are passed to the lower-level
412  `wrapAlgorithm` and `wrapAlgorithmControl` classes.
413 
414  Returns
415  -------
416  singleFramePlugin : subclass of `SingleFramePlugin`
417  The new single frame measurement plugin class.
418  forcedPlugin : subclass of `ForcedPlugin`
419  The new forced measurement plugin class.
420 
421  Notes
422  -----
423  The first three arguments to the C++ constructor are expected to be
424  ``Control const & ctrl, std::string const & name, Schema & schema``.
425 
426  If ``needsMetadata`` is `True`, we also append ``PropertySet &
427  metadata``.
428 
429  If ``hasMeasureN`` is `True`, we also append ``bool doMeasureN``.
430 
431  If ``hasLogName`` is `True`, we also append ``std::string logName``.
432 
433  If more than one of the above is `True`, the metadata ``PropertySet``
434  precedes the ``doMeasureN`` ``bool`` and the ``logName`` comes last of the
435  three.
436  """
437  return (wrapSingleFrameAlgorithm(AlgClass, executionOrder=executionOrder, name=name,
438  needsMetadata=needsMetadata, hasLogName=hasLogName, **kwds),
439  wrapForcedAlgorithm(AlgClass, executionOrder=executionOrder, name=name,
440  needsMetadata=needsMetadata, hasLogName=hasLogName,
441  needsSchemaOnly=True, **kwds))
442 
443 
def wrapForcedAlgorithm(AlgClass, executionOrder, name=None, needsMetadata=False, hasMeasureN=False, needsSchemaOnly=False, hasLogName=False, **kwds)
Definition: wrappers.py:290
def wrapSingleFrameAlgorithm(AlgClass, executionOrder, name=None, needsMetadata=False, hasMeasureN=False, hasLogName=False, **kwds)
Definition: wrappers.py:219

◆ wrapSingleFrameAlgorithm()

def lsst.meas.base.wrappers.wrapSingleFrameAlgorithm (   AlgClass,
  executionOrder,
  name = None,
  needsMetadata = False,
  hasMeasureN = False,
  hasLogName = False,
**  kwds 
)
Expose a C++ ``SingleFrameAlgorithm`` class as a measurement plugin.

Parameters
----------
AlgClass : API compatible with `SingleFrameAlgorithm`
    C++ algorithm class to convert. May either derive directly from
    `SingleFrameAlgorithm` or be an unrelated class which has the same
    ``measure``, ``measureN`` and ``fail`` signatures.
executionOrder : `float`
    The order this plugin should be run, relative to others
    (see `BasePlugin.getExecutionOrder`).
name : `str`, optional
    Name to use when registering the algorithm. Ignored if
    ``doRegistry=False``; set to ``generateAlgorithmName(AlgClass)`` if
    `None`.
needsMetadata : `bool`, optional
    Sets whether the ``AlgClass``'s constructor should be passed a
    `~lsst.daf.base.PropertySet` metadata argument.
hasMeasureN : `bool`, optional
    Does the algorithm support 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.
hasLogName : `bool`, optional
    `True` if the C++ algorithm supports ``logName`` as a constructor
    argument.
**kwds
    Additional keyword arguments are passed to the lower-level
    `wrapAlgorithm` and `wrapAlgorithmControl` classes.

Returns
-------
singleFramePlugin : subclass of `SingleFramePlugin`
    The new measurement plugin class.

Notes
-----
The first three arguments to the C++ constructor are expected to be
``Control const & ctrl, std::string const & name, Schema & schema``.

If ``needsMetadata`` is `True`, we also append ``PropertySet & metadata``.

If ``hasMeasureN`` is `True`, we also append ``bool doMeasureN``.

If ``hasLogName`` is `True`, we also append ``std::string logName``.

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

Definition at line 218 of file wrappers.py.

219  hasLogName=False, **kwds):
220  """Expose a C++ ``SingleFrameAlgorithm`` class as a measurement plugin.
221 
222  Parameters
223  ----------
224  AlgClass : API compatible with `SingleFrameAlgorithm`
225  C++ algorithm class to convert. May either derive directly from
226  `SingleFrameAlgorithm` or be an unrelated class which has the same
227  ``measure``, ``measureN`` and ``fail`` signatures.
228  executionOrder : `float`
229  The order this plugin should be run, relative to others
230  (see `BasePlugin.getExecutionOrder`).
231  name : `str`, optional
232  Name to use when registering the algorithm. Ignored if
233  ``doRegistry=False``; set to ``generateAlgorithmName(AlgClass)`` if
234  `None`.
235  needsMetadata : `bool`, optional
236  Sets whether the ``AlgClass``'s constructor should be passed a
237  `~lsst.daf.base.PropertySet` metadata argument.
238  hasMeasureN : `bool`, optional
239  Does the algorithm support simultaneous measurement of multiple
240  sources? If `True`, a `bool` ``doMeasureN`` field will be added to
241  the generated config class, and its value will be passed as the last
242  argument when calling the ``AlgClass`` constructor.
243  hasLogName : `bool`, optional
244  `True` if the C++ algorithm supports ``logName`` as a constructor
245  argument.
246  **kwds
247  Additional keyword arguments are passed to the lower-level
248  `wrapAlgorithm` and `wrapAlgorithmControl` classes.
249 
250  Returns
251  -------
252  singleFramePlugin : subclass of `SingleFramePlugin`
253  The new measurement plugin class.
254 
255  Notes
256  -----
257  The first three arguments to the C++ constructor are expected to be
258  ``Control const & ctrl, std::string const & name, Schema & schema``.
259 
260  If ``needsMetadata`` is `True`, we also append ``PropertySet & metadata``.
261 
262  If ``hasMeasureN`` is `True`, we also append ``bool doMeasureN``.
263 
264  If ``hasLogName`` is `True`, we also append ``std::string logName``.
265 
266  If more than one of the above is `True`, the metadata ``PropertySet``
267  precedes the ``doMeasureN`` ``bool`` and the ``logName`` comes last of the
268  three.
269  """
270  if hasMeasureN:
271  if needsMetadata:
272  def factory(config, name, schema, metadata, **kwargs):
273  return AlgClass(config.makeControl(), name, schema, metadata, config.doMeasureN, **kwargs)
274  else:
275  def factory(config, name, schema, metadata, **kwargs):
276  return AlgClass(config.makeControl(), name, schema, config.doMeasureN, **kwargs)
277  else:
278  if needsMetadata:
279  def factory(config, name, schema, metadata, **kwargs):
280  return AlgClass(config.makeControl(), name, schema, metadata, **kwargs)
281  else:
282  def factory(config, name, schema, metadata, **kwargs):
283  return AlgClass(config.makeControl(), name, schema, **kwargs)
284 
285  return wrapAlgorithm(WrappedSingleFramePlugin, AlgClass, executionOrder=executionOrder, name=name,
286  factory=factory, hasMeasureN=hasMeasureN, hasLogName=hasLogName, **kwds)
287 
288 

◆ wrapTransform()

def lsst.meas.base.wrappers.wrapTransform (   transformClass,
  hasLogName = False 
)
Modify a C++ transform to accept either a ``Config`` or a ``Control``.

That is, the configuration may either be provided as a (C++) ``Control``
object or an instance of a Python class derived from
`~lsst.meas.base.BasePluginConfig`.

Parameters
----------
transformClass : Subclass of C++ ``BaseTransform``
    A C++ transform class, wrapped with pybind11. Its constructor must
    take a ``Control`` object, a ``std::string``, and a
    `~lsst.afw.table.SchemaMapper`, in that order.
hasLogName : `bool`, optional
    Unused.

Definition at line 444 of file wrappers.py.

444 def wrapTransform(transformClass, hasLogName=False):
445  """Modify a C++ transform to accept either a ``Config`` or a ``Control``.
446 
447  That is, the configuration may either be provided as a (C++) ``Control``
448  object or an instance of a Python class derived from
449  `~lsst.meas.base.BasePluginConfig`.
450 
451  Parameters
452  ----------
453  transformClass : Subclass of C++ ``BaseTransform``
454  A C++ transform class, wrapped with pybind11. Its constructor must
455  take a ``Control`` object, a ``std::string``, and a
456  `~lsst.afw.table.SchemaMapper`, in that order.
457  hasLogName : `bool`, optional
458  Unused.
459  """
460  oldInit = transformClass.__init__
461 
462  def _init(self, ctrl, name, mapper, logName=None):
463  if hasattr(ctrl, "makeControl"):
464  ctrl = ctrl.makeControl()
465  # logName signature needs to be on this Class __init__, but is not
466  # needed by the C++ plugin.
467  oldInit(self, ctrl, name, mapper)
468 
469  transformClass.__init__ = _init
470 
471 
def wrapTransform(transformClass, hasLogName=False)
Definition: wrappers.py:444