261 """Initialize plugins (and slots) according to configuration.
266 Keyword arguments forwarded directly to plugin constructors.
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.
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.
278 Keyword arguments are forwarded directly to plugin constructors,
279 allowing derived classes to use plugins with different signatures.
285 if self.config.slots.centroid
is not None:
286 self.
plugins[self.config.slots.centroid] =
None
289 for executionOrder, name, config, PluginClass
in sorted(self.config.plugins.apply()):
292 if getattr(PluginClass,
"hasLogName",
False):
294 logName=self.log.getChild(name).name, **kwds)
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]
304 for executionOrder, name, config, PluginClass
in sorted(self.config.undeblended.apply()):
305 undeblendedName = self.config.undeblendedPrefix + name
306 if getattr(PluginClass,
"hasLogName",
False):
309 logName=self.log.getChild(undeblendedName).name,
316 """Call ``measure`` on all plugins and consistently handle exceptions.
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.
324 Positional arguments forwarded to ``plugin.measure``
326 Keyword arguments. Two are handled locally:
329 Beginning execution order (inclusive). Measurements with
330 ``executionOrder`` < ``beginOrder`` are not executed. `None`
334 Ending execution order (exclusive). Measurements with
335 ``executionOrder`` >= ``endOrder`` are not executed. `None`
338 Others are forwarded to ``plugin.measure()``.
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.
347 This method should be considered "protected": it is intended for use by
348 derived classes, not users.
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:
355 if endOrder
is not None and plugin.getExecutionOrder() >= endOrder:
360 """Call ``measure`` on the specified plugin.
362 Exceptions are handled in a consistent way.
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.
372 Positional arguments forwarded to ``plugin.measure()``.
374 Keyword arguments forwarded to ``plugin.measure()``.
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.
383 This method should be considered "protected": it is intended for use by
384 derived classes, not users.
387 plugin.measure(measRecord, *args, **kwds)
388 except FATAL_EXCEPTIONS:
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).
warning(
397 "Exception in %s.measure on record %s: %s",
398 plugin.name, measRecord.getId(), error)
399 plugin.fail(measRecord)
402 """Call ``measureN`` on all plugins and consistently handle exceptions.
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.
410 Positional arguments forwarded to ``plugin.measure()``
412 Keyword arguments. Two are handled locally:
415 Beginning execution order (inclusive): Measurements with
416 ``executionOrder`` < ``beginOrder`` are not executed. `None`
419 Ending execution order (exclusive): measurements with
420 ``executionOrder`` >= ``endOrder`` are not executed. `None` for
423 Others are are forwarded to ``plugin.measure()``.
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.
432 This method should be considered "protected": it is intended for use by
433 derived classes, not users.
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:
440 if endOrder
is not None and plugin.getExecutionOrder() >= endOrder:
445 """Call ``measureN`` on the specified plugin.
447 Exceptions are handled in a consistent way.
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.
457 Positional arguments forwarded to ``plugin.measureN()``.
459 Keyword arguments forwarded to ``plugin.measureN()``.
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.
468 This method should be considered "protected": it is intended for use by
469 derived classes, not users.
472 plugin.measureN(measCat, *args, **kwds)
473 except FATAL_EXCEPTIONS:
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).
warning(
486 "Exception in %s.measureN on records %s-%s: %s",
487 plugin.name, measCat[0].getId(), measCat[-1].getId(), error)