LSST Applications g0265f82a02+d6b5cd48b5,g02d81e74bb+a41d3748ce,g1470d8bcf6+6be6c9203b,g2079a07aa2+14824f138e,g212a7c68fe+a4f2ea4efa,g2305ad1205+72971fe858,g295015adf3+ab2c85acae,g2bbee38e9b+d6b5cd48b5,g337abbeb29+d6b5cd48b5,g3ddfee87b4+31b3a28dff,g487adcacf7+082e807817,g50ff169b8f+5929b3527e,g52b1c1532d+a6fc98d2e7,g591dd9f2cf+b2918d57ae,g5a732f18d5+66d966b544,g64a986408d+a41d3748ce,g858d7b2824+a41d3748ce,g8a8a8dda67+a6fc98d2e7,g99cad8db69+7fe4acdf18,g9ddcbc5298+d4bad12328,ga1e77700b3+246acaaf9c,ga8c6da7877+84af8b3ff8,gb0e22166c9+3863383f4c,gb6a65358fc+d6b5cd48b5,gba4ed39666+9664299f35,gbb8dafda3b+d8d527deb2,gc07e1c2157+b2dbe6b631,gc120e1dc64+61440b2abb,gc28159a63d+d6b5cd48b5,gcf0d15dbbd+31b3a28dff,gdaeeff99f8+a38ce5ea23,ge6526c86ff+39927bb362,ge79ae78c31+d6b5cd48b5,gee10cc3b42+a6fc98d2e7,gf1cff7945b+a41d3748ce,v24.1.5.rc1
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | Static Protected 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

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

Public Attributes

 undeblendedPlugins
 

Static Public Attributes

 ConfigClass = BaseMeasurementConfig
 
 plugins = None
 
 algMetadata = None
 

Static Protected Attributes

str _DefaultName = "measurement"
 

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

Constructor & Destructor Documentation

◆ __init__()

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

Reimplemented in lsst.meas.base.forcedMeasurement.ForcedMeasurementTask, and lsst.meas.base.sfm.SingleFrameMeasurementTask.

Definition at line 252 of file baseMeasurement.py.

252 def __init__(self, algMetadata=None, **kwds):
253 super(BaseMeasurementTask, self).__init__(**kwds)
254 self.plugins = PluginMap()
255 self.undeblendedPlugins = PluginMap()
256 if algMetadata is None:
257 algMetadata = lsst.daf.base.PropertyList()
258 self.algMetadata = algMetadata
259
Class for storing ordered metadata with comments.

Member Function Documentation

◆ callMeasure()

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

315 def callMeasure(self, measRecord, *args, **kwds):
316 """Call ``measure`` on all plugins and consistently handle exceptions.
317
318 Parameters
319 ----------
320 measRecord : `lsst.afw.table.SourceRecord`
321 The record corresponding to the object being measured. Will be
322 updated in-place with the results of measurement.
323 *args
324 Positional arguments forwarded to ``plugin.measure``
325 **kwds
326 Keyword arguments. Two are handled locally:
327
328 beginOrder : `int`
329 Beginning execution order (inclusive). Measurements with
330 ``executionOrder`` < ``beginOrder`` are not executed. `None`
331 for no limit.
332
333 endOrder : `int`
334 Ending execution order (exclusive). Measurements with
335 ``executionOrder`` >= ``endOrder`` are not executed. `None`
336 for no limit.
337
338 Others are forwarded to ``plugin.measure()``.
339
340 Notes
341 -----
342 This method can be used with plugins that have different signatures;
343 the only requirement is that ``measRecord`` be the first argument.
344 Subsequent positional arguments and keyword arguments are forwarded
345 directly to the plugin.
346
347 This method should be considered "protected": it is intended for use by
348 derived classes, not users.
349 """
350 beginOrder = kwds.pop("beginOrder", None)
351 endOrder = kwds.pop("endOrder", None)
352 for plugin in self.plugins.iter():
353 if beginOrder is not None and plugin.getExecutionOrder() < beginOrder:
354 continue
355 if endOrder is not None and plugin.getExecutionOrder() >= endOrder:
356 break
357 self.doMeasurement(plugin, measRecord, *args, **kwds)
358

◆ callMeasureN()

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

401 def callMeasureN(self, measCat, *args, **kwds):
402 """Call ``measureN`` on all plugins and consistently handle exceptions.
403
404 Parameters
405 ----------
406 measCat : `lsst.afw.table.SourceCatalog`
407 Catalog containing only the records for the source family to be
408 measured, and where outputs should be written.
409 *args
410 Positional arguments forwarded to ``plugin.measure()``
411 **kwds
412 Keyword arguments. Two are handled locally:
413
414 beginOrder:
415 Beginning execution order (inclusive): Measurements with
416 ``executionOrder`` < ``beginOrder`` are not executed. `None`
417 for no limit.
418 endOrder:
419 Ending execution order (exclusive): measurements with
420 ``executionOrder`` >= ``endOrder`` are not executed. `None` for
421 no ``limit``.
422
423 Others are are forwarded to ``plugin.measure()``.
424
425 Notes
426 -----
427 This method can be used with plugins that have different signatures;
428 the only requirement is that ``measRecord`` be the first argument.
429 Subsequent positional arguments and keyword arguments are forwarded
430 directly to the plugin.
431
432 This method should be considered "protected": it is intended for use by
433 derived classes, not users.
434 """
435 beginOrder = kwds.pop("beginOrder", None)
436 endOrder = kwds.pop("endOrder", None)
437 for plugin in self.plugins.iterN():
438 if beginOrder is not None and plugin.getExecutionOrder() < beginOrder:
439 continue
440 if endOrder is not None and plugin.getExecutionOrder() >= endOrder:
441 break
442 self.doMeasurementN(plugin, measCat, *args, **kwds)
443

◆ doMeasurement()

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

359 def doMeasurement(self, plugin, measRecord, *args, **kwds):
360 """Call ``measure`` on the specified plugin.
361
362 Exceptions are handled in a consistent way.
363
364 Parameters
365 ----------
366 plugin : subclass of `BasePlugin`
367 Plugin that will be executed.
368 measRecord : `lsst.afw.table.SourceRecord`
369 The record corresponding to the object being measured. Will be
370 updated in-place with the results of measurement.
371 *args
372 Positional arguments forwarded to ``plugin.measure()``.
373 **kwds
374 Keyword arguments forwarded to ``plugin.measure()``.
375
376 Notes
377 -----
378 This method can be used with plugins that have different signatures;
379 the only requirement is that ``plugin`` and ``measRecord`` be the first
380 two arguments. Subsequent positional arguments and keyword arguments
381 are forwarded directly to the plugin.
382
383 This method should be considered "protected": it is intended for use by
384 derived classes, not users.
385 """
386 try:
387 plugin.measure(measRecord, *args, **kwds)
388 except FATAL_EXCEPTIONS:
389 raise
390 except MeasurementError as error:
391 self.log.getChild(plugin.name).debug(
392 "MeasurementError in %s.measure on record %s: %s",
393 plugin.name, measRecord.getId(), error)
394 plugin.fail(measRecord, error)
395 except Exception as error:
396 self.log.getChild(plugin.name).debug(
397 "Exception in %s.measure on record %s: %s",
398 plugin.name, measRecord.getId(), error)
399 plugin.fail(measRecord)
400

◆ doMeasurementN()

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

444 def doMeasurementN(self, plugin, measCat, *args, **kwds):
445 """Call ``measureN`` on the specified plugin.
446
447 Exceptions are handled in a consistent way.
448
449 Parameters
450 ----------
451 plugin : subclass of `BasePlugin`
452 Plugin that will be executed.
453 measCat : `lsst.afw.table.SourceCatalog`
454 Catalog containing only the records for the source family to be
455 measured, and where outputs should be written.
456 *args
457 Positional arguments forwarded to ``plugin.measureN()``.
458 **kwds
459 Keyword arguments forwarded to ``plugin.measureN()``.
460
461 Notes
462 -----
463 This method can be used with plugins that have different signatures;
464 the only requirement is that the ``plugin`` and ``measCat`` be the
465 first two arguments. Subsequent positional arguments and keyword
466 arguments are forwarded directly to the plugin.
467
468 This method should be considered "protected": it is intended for use by
469 derived classes, not users.
470 """
471 try:
472 plugin.measureN(measCat, *args, **kwds)
473 except FATAL_EXCEPTIONS:
474 raise
475
476 except MeasurementError as error:
477 for measRecord in measCat:
478 self.log.getChild(plugin.name).debug(
479 "MeasurementError in %s.measureN on records %s-%s: %s",
480 plugin.name, measCat[0].getId(), measCat[-1].getId(), error)
481 plugin.fail(measRecord, error)
482 except Exception as error:
483 for measRecord in measCat:
484 plugin.fail(measRecord)
485 self.log.getChild(plugin.name).debug(
486 "Exception in %s.measureN on records %s-%s: %s",
487 plugin.name, measCat[0].getId(), measCat[-1].getId(), error)

◆ initializePlugins()

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

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

Member Data Documentation

◆ _DefaultName

str lsst.meas.base.baseMeasurement.BaseMeasurementTask._DefaultName = "measurement"
staticprotected

Definition at line 236 of file baseMeasurement.py.

◆ algMetadata

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

Definition at line 245 of file baseMeasurement.py.

◆ ConfigClass

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

Definition at line 235 of file baseMeasurement.py.

◆ plugins

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

Definition at line 238 of file baseMeasurement.py.

◆ undeblendedPlugins

lsst.meas.base.baseMeasurement.BaseMeasurementTask.undeblendedPlugins

Definition at line 255 of file baseMeasurement.py.


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