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
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
lsst.meas.base.baseMeasurement.BaseMeasurementTask Class Reference
Inheritance diagram for lsst.meas.base.baseMeasurement.BaseMeasurementTask:
lsst.meas.base.forcedMeasurement.ForcedMeasurementTask lsst.meas.base.sfm.SingleFrameMeasurementTask lsst.ip.diffim.dipoleMeasurement.DipoleMeasurementTask

Public Member Functions

def __init__ (self, algMetadata=None, **kwds)
 
def initializePlugins (self, **kwds)
 
def callMeasure (self, measRecord, *args, **kwds)
 
def doMeasurement (self, plugin, measRecord, *args, **kwds)
 
def callMeasureN (self, measCat, *args, **kwds)
 
def doMeasurementN (self, plugin, measCat, *args, **kwds)
 

Public Attributes

 undeblendedPlugins
 

Static Public Attributes

 ConfigClass = BaseMeasurementConfig
 
 plugins = None
 
 algMetadata = None
 

Detailed Description

Ultimate base class for all measurement tasks.

Parameters
----------
algMetadata : `lsst.daf.base.PropertyList` or `None`
    Will be modified in-place to contain metadata about the plugins being
    run. If `None`, an empty `~lsst.daf.base.PropertyList` will be
    created.
**kwds
    Additional arguments passed to `lsst.pipe.base.Task.__init__`.

Notes
-----
This base class for `SingleFrameMeasurementTask` and
`ForcedMeasurementTask` mostly exists to share code between the two, and
generally should not be used directly.

Definition at line 196 of file baseMeasurement.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.meas.base.baseMeasurement.BaseMeasurementTask.__init__ (   self,
  algMetadata = None,
**  kwds 
)

Definition at line 232 of file baseMeasurement.py.

232  def __init__(self, algMetadata=None, **kwds):
233  super(BaseMeasurementTask, self).__init__(**kwds)
234  self.plugins = PluginMap()
235  self.undeblendedPlugins = PluginMap()
236  if algMetadata is None:
237  algMetadata = lsst.daf.base.PropertyList()
238  self.algMetadata = algMetadata
239 
Class for storing ordered metadata with comments.
Definition: PropertyList.h:68

Member Function Documentation

◆ callMeasure()

def lsst.meas.base.baseMeasurement.BaseMeasurementTask.callMeasure (   self,
  measRecord,
args,
**  kwds 
)
Call ``measure`` on all plugins and consistently handle exceptions.

Parameters
----------
measRecord : `lsst.afw.table.SourceRecord`
    The record corresponding to the object being measured. Will be
    updated in-place with the results of measurement.
*args
    Positional arguments forwarded to ``plugin.measure``
**kwds
    Keyword arguments. Two are handled locally:

    beginOrder : `int`
        Beginning execution order (inclusive). Measurements with
        ``executionOrder`` < ``beginOrder`` are not executed. `None`
        for no limit.

    endOrder : `int`
        Ending execution order (exclusive). Measurements with
        ``executionOrder`` >= ``endOrder`` are not executed. `None`
        for no limit.

    Others are forwarded to ``plugin.measure()``.

Notes
-----
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 295 of file baseMeasurement.py.

295  def callMeasure(self, measRecord, *args, **kwds):
296  """Call ``measure`` on all plugins and consistently handle exceptions.
297 
298  Parameters
299  ----------
300  measRecord : `lsst.afw.table.SourceRecord`
301  The record corresponding to the object being measured. Will be
302  updated in-place with the results of measurement.
303  *args
304  Positional arguments forwarded to ``plugin.measure``
305  **kwds
306  Keyword arguments. Two are handled locally:
307 
308  beginOrder : `int`
309  Beginning execution order (inclusive). Measurements with
310  ``executionOrder`` < ``beginOrder`` are not executed. `None`
311  for no limit.
312 
313  endOrder : `int`
314  Ending execution order (exclusive). Measurements with
315  ``executionOrder`` >= ``endOrder`` are not executed. `None`
316  for no limit.
317 
318  Others are forwarded to ``plugin.measure()``.
319 
320  Notes
321  -----
322  This method can be used with plugins that have different signatures;
323  the only requirement is that ``measRecord`` be the first argument.
324  Subsequent positional arguments and keyword arguments are forwarded
325  directly to the plugin.
326 
327  This method should be considered "protected": it is intended for use by
328  derived classes, not users.
329  """
330  beginOrder = kwds.pop("beginOrder", None)
331  endOrder = kwds.pop("endOrder", None)
332  for plugin in self.plugins.iter():
333  if beginOrder is not None and plugin.getExecutionOrder() < beginOrder:
334  continue
335  if endOrder is not None and plugin.getExecutionOrder() >= endOrder:
336  break
337  self.doMeasurement(plugin, measRecord, *args, **kwds)
338 

◆ callMeasureN()

def lsst.meas.base.baseMeasurement.BaseMeasurementTask.callMeasureN (   self,
  measCat,
args,
**  kwds 
)
Call ``measureN`` on all plugins and consistently handle exceptions.

Parameters
----------
measCat : `lsst.afw.table.SourceCatalog`
    Catalog containing only the records for the source family to be
    measured, and where outputs should be written.
*args
    Positional arguments forwarded to ``plugin.measure()``
**kwds
    Keyword 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``.

    Others are are forwarded to ``plugin.measure()``.

Notes
-----
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 381 of file baseMeasurement.py.

381  def callMeasureN(self, measCat, *args, **kwds):
382  """Call ``measureN`` on all plugins and consistently handle exceptions.
383 
384  Parameters
385  ----------
386  measCat : `lsst.afw.table.SourceCatalog`
387  Catalog containing only the records for the source family to be
388  measured, and where outputs should be written.
389  *args
390  Positional arguments forwarded to ``plugin.measure()``
391  **kwds
392  Keyword arguments. Two are handled locally:
393 
394  beginOrder:
395  Beginning execution order (inclusive): Measurements with
396  ``executionOrder`` < ``beginOrder`` are not executed. `None`
397  for no limit.
398  endOrder:
399  Ending execution order (exclusive): measurements with
400  ``executionOrder`` >= ``endOrder`` are not executed. `None` for
401  no ``limit``.
402 
403  Others are are forwarded to ``plugin.measure()``.
404 
405  Notes
406  -----
407  This method can be used with plugins that have different signatures;
408  the only requirement is that ``measRecord`` be the first argument.
409  Subsequent positional arguments and keyword arguments are forwarded
410  directly to the plugin.
411 
412  This method should be considered "protected": it is intended for use by
413  derived classes, not users.
414  """
415  beginOrder = kwds.pop("beginOrder", None)
416  endOrder = kwds.pop("endOrder", None)
417  for plugin in self.plugins.iterN():
418  if beginOrder is not None and plugin.getExecutionOrder() < beginOrder:
419  continue
420  if endOrder is not None and plugin.getExecutionOrder() >= endOrder:
421  break
422  self.doMeasurementN(plugin, measCat, *args, **kwds)
423 

◆ doMeasurement()

def lsst.meas.base.baseMeasurement.BaseMeasurementTask.doMeasurement (   self,
  plugin,
  measRecord,
args,
**  kwds 
)
Call ``measure`` on the specified plugin.

Exceptions are handled in a consistent way.

Parameters
----------
plugin : subclass of `BasePlugin`
    Plugin that will be executed.
measRecord : `lsst.afw.table.SourceRecord`
    The record corresponding to the object being measured. Will be
    updated in-place with the results of measurement.
*args
    Positional arguments forwarded to ``plugin.measure()``.
**kwds
    Keyword arguments forwarded to ``plugin.measure()``.

Notes
-----
This method can be used with plugins that have different signatures;
the only requirement is that ``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 339 of file baseMeasurement.py.

339  def doMeasurement(self, plugin, measRecord, *args, **kwds):
340  """Call ``measure`` on the specified plugin.
341 
342  Exceptions are handled in a consistent way.
343 
344  Parameters
345  ----------
346  plugin : subclass of `BasePlugin`
347  Plugin that will be executed.
348  measRecord : `lsst.afw.table.SourceRecord`
349  The record corresponding to the object being measured. Will be
350  updated in-place with the results of measurement.
351  *args
352  Positional arguments forwarded to ``plugin.measure()``.
353  **kwds
354  Keyword arguments forwarded to ``plugin.measure()``.
355 
356  Notes
357  -----
358  This method can be used with plugins that have different signatures;
359  the only requirement is that ``plugin`` and ``measRecord`` be the first
360  two arguments. Subsequent positional arguments and keyword arguments
361  are forwarded directly to the plugin.
362 
363  This method should be considered "protected": it is intended for use by
364  derived classes, not users.
365  """
366  try:
367  plugin.measure(measRecord, *args, **kwds)
368  except FATAL_EXCEPTIONS:
369  raise
370  except MeasurementError as error:
371  self.log.getChild(plugin.name).debug(
372  "MeasurementError in %s.measure on record %s: %s",
373  plugin.name, measRecord.getId(), error)
374  plugin.fail(measRecord, error)
375  except Exception as error:
376  self.log.getChild(plugin.name).debug(
377  "Exception in %s.measure on record %s: %s",
378  plugin.name, measRecord.getId(), error)
379  plugin.fail(measRecord)
380 

◆ doMeasurementN()

def lsst.meas.base.baseMeasurement.BaseMeasurementTask.doMeasurementN (   self,
  plugin,
  measCat,
args,
**  kwds 
)
Call ``measureN`` on the specified plugin.

Exceptions are handled in a consistent way.

Parameters
----------
plugin : subclass of `BasePlugin`
    Plugin that will be executed.
measCat : `lsst.afw.table.SourceCatalog`
    Catalog containing only the records for the source family to be
    measured, and where outputs should be written.
*args
    Positional arguments forwarded to ``plugin.measureN()``.
**kwds
    Keyword arguments forwarded to ``plugin.measureN()``.

Notes
-----
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 424 of file baseMeasurement.py.

424  def doMeasurementN(self, plugin, measCat, *args, **kwds):
425  """Call ``measureN`` on the specified plugin.
426 
427  Exceptions are handled in a consistent way.
428 
429  Parameters
430  ----------
431  plugin : subclass of `BasePlugin`
432  Plugin that will be executed.
433  measCat : `lsst.afw.table.SourceCatalog`
434  Catalog containing only the records for the source family to be
435  measured, and where outputs should be written.
436  *args
437  Positional arguments forwarded to ``plugin.measureN()``.
438  **kwds
439  Keyword arguments forwarded to ``plugin.measureN()``.
440 
441  Notes
442  -----
443  This method can be used with plugins that have different signatures;
444  the only requirement is that the ``plugin`` and ``measCat`` be the
445  first two arguments. Subsequent positional arguments and keyword
446  arguments are forwarded directly to the plugin.
447 
448  This method should be considered "protected": it is intended for use by
449  derived classes, not users.
450  """
451  try:
452  plugin.measureN(measCat, *args, **kwds)
453  except FATAL_EXCEPTIONS:
454  raise
455 
456  except MeasurementError as error:
457  for measRecord in measCat:
458  self.log.getChild(plugin.name).debug(
459  "MeasurementError in %s.measureN on records %s-%s: %s",
460  plugin.name, measCat[0].getId(), measCat[-1].getId(), error)
461  plugin.fail(measRecord, error)
462  except Exception as error:
463  for measRecord in measCat:
464  plugin.fail(measRecord)
465  self.log.getChild(plugin.name).debug(
466  "Exception in %s.measureN on records %s-%s: %s",
467  plugin.name, measCat[0].getId(), measCat[-1].getId(), error)

◆ initializePlugins()

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

Parameters
----------
**kwds
    Keyword arguments forwarded directly to plugin constructors.

Notes
-----
Derived class constructors should call this method to fill the
`plugins` attribute and add corresponding output fields and slot
aliases to the output schema.

In addition to the attributes added by `BaseMeasurementTask.__init__`,
a ``schema``` attribute holding the output schema must 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 240 of file baseMeasurement.py.

240  def initializePlugins(self, **kwds):
241  """Initialize plugins (and slots) according to configuration.
242 
243  Parameters
244  ----------
245  **kwds
246  Keyword arguments forwarded directly to plugin constructors.
247 
248  Notes
249  -----
250  Derived class constructors should call this method to fill the
251  `plugins` attribute and add corresponding output fields and slot
252  aliases to the output schema.
253 
254  In addition to the attributes added by `BaseMeasurementTask.__init__`,
255  a ``schema``` attribute holding the output schema must be present
256  before this method is called.
257 
258  Keyword arguments are forwarded directly to plugin constructors,
259  allowing derived classes to use plugins with different signatures.
260  """
261  # Make a place at the beginning for the centroid plugin to run first
262  # (because it's an OrderedDict, adding an empty element in advance
263  # means it will get run first when it's reassigned to the actual
264  # Plugin).
265  if self.config.slots.centroid is not None:
266  self.plugins[self.config.slots.centroid] = None
267  # Init the plugins, sorted by execution order. At the same time add to
268  # the schema
269  for executionOrder, name, config, PluginClass in sorted(self.config.plugins.apply()):
270  # Pass logName to the plugin if the plugin is marked as using it
271  # The task will use this name to log plugin errors, regardless.
272  if getattr(PluginClass, "hasLogName", False):
273  self.plugins[name] = PluginClass(config, name, metadata=self.algMetadata,
274  logName=self.log.getChild(name).name, **kwds)
275  else:
276  self.plugins[name] = PluginClass(config, name, metadata=self.algMetadata, **kwds)
277 
278  # In rare circumstances (usually tests), the centroid slot not be
279  # coming from an algorithm, which means we'll have added something we
280  # don't want to the plugins map, and we should remove it.
281  if self.config.slots.centroid is not None and self.plugins[self.config.slots.centroid] is None:
282  del self.plugins[self.config.slots.centroid]
283  # Initialize the plugins to run on the undeblended image
284  for executionOrder, name, config, PluginClass in sorted(self.config.undeblended.apply()):
285  undeblendedName = self.config.undeblendedPrefix + name
286  if getattr(PluginClass, "hasLogName", False):
287  self.undeblendedPlugins[name] = PluginClass(config, undeblendedName,
288  metadata=self.algMetadata,
289  logName=self.log.getChild(undeblendedName).name,
290  **kwds)
291  else:
292  self.undeblendedPlugins[name] = PluginClass(config, undeblendedName,
293  metadata=self.algMetadata, **kwds)
294 

Member Data Documentation

◆ algMetadata

lsst.meas.base.baseMeasurement.BaseMeasurementTask.algMetadata = None
static

Definition at line 225 of file baseMeasurement.py.

◆ ConfigClass

lsst.meas.base.baseMeasurement.BaseMeasurementTask.ConfigClass = BaseMeasurementConfig
static

Definition at line 215 of file baseMeasurement.py.

◆ plugins

lsst.meas.base.baseMeasurement.BaseMeasurementTask.plugins = None
static

Definition at line 218 of file baseMeasurement.py.

◆ undeblendedPlugins

lsst.meas.base.baseMeasurement.BaseMeasurementTask.undeblendedPlugins

Definition at line 235 of file baseMeasurement.py.


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