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.sfm.SingleFrameMeasurementTask Class Reference
Inheritance diagram for lsst.meas.base.sfm.SingleFrameMeasurementTask:
lsst.meas.base.baseMeasurement.BaseMeasurementTask lsst.ip.diffim.dipoleMeasurement.DipoleMeasurementTask

Public Member Functions

def __init__ (self, schema, algMetadata=None, **kwds)
 
def run (self, measCat, exposure, noiseImage=None, exposureId=None, beginOrder=None, endOrder=None)
 
def runPlugins (self, noiseReplacer, measCat, exposure, beginOrder=None, endOrder=None)
 
def measure (self, measCat, exposure)
 
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

 schema
 
 doBlendedness
 
 blendPlugin
 
 undeblendedPlugins
 

Static Public Attributes

 ConfigClass = SingleFrameMeasurementConfig
 
string NOISE_SEED_MULTIPLIER = "NOISE_SEED_MULTIPLIER"
 
string NOISE_SOURCE = "NOISE_SOURCE"
 
string NOISE_OFFSET = "NOISE_OFFSET"
 
string NOISE_EXPOSURE_ID = "NOISE_EXPOSURE_ID"
 
 plugins = None
 
 algMetadata = None
 

Detailed Description

A subtask for measuring the properties of sources on a single exposure.

Parameters
----------
schema : `lsst.afw.table.Schema`
    Schema of the output resultant catalog. Will be updated to provide
    fields to accept the outputs of plugins which will be executed by this
    task.
algMetadata : `lsst.daf.base.PropertyList`, optional
    Used to record metadaa about algorithm execution. An empty
    `lsst.daf.base.PropertyList` will be created if `None`.
**kwds
    Keyword arguments forwarded to `BaseMeasurementTask`.

Definition at line 166 of file sfm.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.meas.base.sfm.SingleFrameMeasurementTask.__init__ (   self,
  schema,
  algMetadata = None,
**  kwds 
)

Definition at line 200 of file sfm.py.

200  def __init__(self, schema, algMetadata=None, **kwds):
201  super(SingleFrameMeasurementTask, self).__init__(algMetadata=algMetadata, **kwds)
202  self.schema = schema
203  self.config.slots.setupSchema(self.schema)
204  self.initializePlugins(schema=self.schema)
205 
206  # Check to see if blendedness is one of the plugins
207  if 'base_Blendedness' in self.plugins:
208  self.doBlendedness = True
209  self.blendPlugin = self.plugins['base_Blendedness']
210  else:
211  self.doBlendedness = False
212 

Member Function Documentation

◆ callMeasure()

def lsst.meas.base.baseMeasurement.BaseMeasurementTask.callMeasure (   self,
  measRecord,
args,
**  kwds 
)
inherited
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 
)
inherited
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 
)
inherited
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 
)
inherited
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 
)
inherited
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 

◆ measure()

def lsst.meas.base.sfm.SingleFrameMeasurementTask.measure (   self,
  measCat,
  exposure 
)
Backwards-compatibility alias for `run`.

Definition at line 355 of file sfm.py.

355  def measure(self, measCat, exposure):
356  """Backwards-compatibility alias for `run`.
357  """
358  self.run(measCat, exposure)
def measure(mi, x, y, size, statistic, stats)
Definition: fringe.py:517

◆ run()

def lsst.meas.base.sfm.SingleFrameMeasurementTask.run (   self,
  measCat,
  exposure,
  noiseImage = None,
  exposureId = None,
  beginOrder = None,
  endOrder = None 
)
Run single frame measurement over an exposure and source catalog.

Parameters
----------
measCat : `lsst.afw.table.SourceCatalog`
    Catalog to be filled with the results of measurement. Must contain
    all the `lsst.afw.table.SourceRecord`\ s to be measured (with
    `lsst.afw.detection.Footprint`\ s attached), and have a schema
    that is a superset of ``self.schema``.
exposure : `lsst.afw.image.ExposureF`
    Image containing the pixel data to be measured together with
    associated PSF, WCS, etc.
noiseImage : `lsst.afw.image.ImageF`, optional
    Can be used to specify the a predictable noise replacement field
    for testing purposes.
exposureId : `int`, optional
    Unique exposure identifier used to calculate the random number
    generator seed during noise replacement.
beginOrder : `float`, optional
    Start execution order (inclusive): measurements with
    ``executionOrder < beginOrder`` are not executed. `None` for no
    limit.
endOrder : `float`, optional
    Final execution order (exclusive): measurements with
    ``executionOrder >= endOrder`` are not executed. `None` for no
    limit.

Definition at line 214 of file sfm.py.

214  def run(self, measCat, exposure, noiseImage=None, exposureId=None, beginOrder=None, endOrder=None):
215  r"""Run single frame measurement over an exposure and source catalog.
216 
217  Parameters
218  ----------
219  measCat : `lsst.afw.table.SourceCatalog`
220  Catalog to be filled with the results of measurement. Must contain
221  all the `lsst.afw.table.SourceRecord`\ s to be measured (with
222  `lsst.afw.detection.Footprint`\ s attached), and have a schema
223  that is a superset of ``self.schema``.
224  exposure : `lsst.afw.image.ExposureF`
225  Image containing the pixel data to be measured together with
226  associated PSF, WCS, etc.
227  noiseImage : `lsst.afw.image.ImageF`, optional
228  Can be used to specify the a predictable noise replacement field
229  for testing purposes.
230  exposureId : `int`, optional
231  Unique exposure identifier used to calculate the random number
232  generator seed during noise replacement.
233  beginOrder : `float`, optional
234  Start execution order (inclusive): measurements with
235  ``executionOrder < beginOrder`` are not executed. `None` for no
236  limit.
237  endOrder : `float`, optional
238  Final execution order (exclusive): measurements with
239  ``executionOrder >= endOrder`` are not executed. `None` for no
240  limit.
241  """
242  assert measCat.getSchema().contains(self.schema)
243  footprints = {measRecord.getId(): (measRecord.getParent(), measRecord.getFootprint())
244  for measRecord in measCat}
245 
246  # noiseReplacer is used to fill the footprints with noise and save
247  # heavy footprints of the source pixels so that they can be restored
248  # one at a time for measurement. After the NoiseReplacer is
249  # constructed, all pixels in the exposure.getMaskedImage() which
250  # belong to objects in measCat will be replaced with noise
251 
252  if self.config.doReplaceWithNoise:
253  noiseReplacer = NoiseReplacer(self.config.noiseReplacer, exposure, footprints,
254  noiseImage=noiseImage, log=self.log, exposureId=exposureId)
255  algMetadata = measCat.getMetadata()
256  if algMetadata is not None:
257  algMetadata.addInt(self.NOISE_SEED_MULTIPLIER, self.config.noiseReplacer.noiseSeedMultiplier)
258  algMetadata.addString(self.NOISE_SOURCE, self.config.noiseReplacer.noiseSource)
259  algMetadata.addDouble(self.NOISE_OFFSET, self.config.noiseReplacer.noiseOffset)
260  if exposureId is not None:
261  algMetadata.addLong(self.NOISE_EXPOSURE_ID, exposureId)
262  else:
263  noiseReplacer = DummyNoiseReplacer()
264 
265  self.runPlugins(noiseReplacer, measCat, exposure, beginOrder, endOrder)
266 
def run(self, coaddExposures, bbox, wcs)
Definition: getTemplate.py:603

◆ runPlugins()

def lsst.meas.base.sfm.SingleFrameMeasurementTask.runPlugins (   self,
  noiseReplacer,
  measCat,
  exposure,
  beginOrder = None,
  endOrder = None 
)
Call the configured measument plugins on an image.

Parameters
----------
noiseReplacer : `NoiseReplacer`
    Used to fill sources not being measured with noise.
measCat : `lsst.afw.table.SourceCatalog`
    Catalog to be filled with the results of measurement. Must contain
    all the `lsst.afw.table.SourceRecord`\ s to be measured (with
    `lsst.afw.detection.Footprint`\ s attached), and have a schema
    that is a superset of ``self.schema``.
exposure : `lsst.afw.image.ExposureF`
    Image containing the pixel data to be measured together with
    associated PSF, WCS, etc.
beginOrder : `float`, optional
    Start execution order (inclusive): measurements with
    ``executionOrder < beginOrder`` are not executed. `None` for no
    limit.
endOrder : `float`, optional
    Final execution order (exclusive): measurements with
    ``executionOrder >= endOrder`` are not executed. `None` for no
    limit.

Definition at line 267 of file sfm.py.

267  def runPlugins(self, noiseReplacer, measCat, exposure, beginOrder=None, endOrder=None):
268  r"""Call the configured measument plugins on an image.
269 
270  Parameters
271  ----------
272  noiseReplacer : `NoiseReplacer`
273  Used to fill sources not being measured with noise.
274  measCat : `lsst.afw.table.SourceCatalog`
275  Catalog to be filled with the results of measurement. Must contain
276  all the `lsst.afw.table.SourceRecord`\ s to be measured (with
277  `lsst.afw.detection.Footprint`\ s attached), and have a schema
278  that is a superset of ``self.schema``.
279  exposure : `lsst.afw.image.ExposureF`
280  Image containing the pixel data to be measured together with
281  associated PSF, WCS, etc.
282  beginOrder : `float`, optional
283  Start execution order (inclusive): measurements with
284  ``executionOrder < beginOrder`` are not executed. `None` for no
285  limit.
286  endOrder : `float`, optional
287  Final execution order (exclusive): measurements with
288  ``executionOrder >= endOrder`` are not executed. `None` for no
289  limit.
290  """
291  # First, create a catalog of all parentless sources. Loop through all
292  # the parent sources, first processing the children, then the parent.
293  measParentCat = measCat.getChildren(0)
294 
295  nMeasCat = len(measCat)
296  nMeasParentCat = len(measParentCat)
297  self.log.info("Measuring %d source%s (%d parent%s, %d child%s) ",
298  nMeasCat, ("" if nMeasCat == 1 else "s"),
299  nMeasParentCat, ("" if nMeasParentCat == 1 else "s"),
300  nMeasCat - nMeasParentCat, ("" if nMeasCat - nMeasParentCat == 1 else "ren"))
301  nextLogTime = time.time() + self.config.loggingInterval
302 
303  childrenIter = measCat.getChildren([measParentRecord.getId() for measParentRecord in measParentCat])
304  for parentIdx, (measParentRecord, measChildCat) in enumerate(zip(measParentCat, childrenIter)):
305  # first get all the children of this parent, insert footprint in
306  # turn, and measure
307  # TODO: skip this loop if there are no plugins configured for
308  # single-object mode
309  for measChildRecord in measChildCat:
310  noiseReplacer.insertSource(measChildRecord.getId())
311  self.callMeasure(measChildRecord, exposure, beginOrder=beginOrder, endOrder=endOrder)
312 
313  if self.doBlendedness:
314  self.blendPlugin.cpp.measureChildPixels(exposure.getMaskedImage(), measChildRecord)
315 
316  noiseReplacer.removeSource(measChildRecord.getId())
317 
318  # Then insert the parent footprint, and measure that
319  noiseReplacer.insertSource(measParentRecord.getId())
320  self.callMeasure(measParentRecord, exposure, beginOrder=beginOrder, endOrder=endOrder)
321 
322  if self.doBlendedness:
323  self.blendPlugin.cpp.measureChildPixels(exposure.getMaskedImage(), measParentRecord)
324 
325  # Finally, process both parent and child set through measureN
326  self.callMeasureN(measParentCat[parentIdx:parentIdx+1], exposure,
327  beginOrder=beginOrder, endOrder=endOrder)
328  self.callMeasureN(measChildCat, exposure, beginOrder=beginOrder, endOrder=endOrder)
329  noiseReplacer.removeSource(measParentRecord.getId())
330  # Log a message if it has been a while since the last log.
331  if (currentTime := time.time()) > nextLogTime:
332  self.log.verbose("Measurement complete for %d parents (and their children) out of %d",
333  parentIdx + 1, nMeasParentCat)
334  nextLogTime = currentTime + self.config.loggingInterval
335 
336  # When done, restore the exposure to its original state
337  noiseReplacer.end()
338 
339  # Undeblended plugins only fire if we're running everything
340  if endOrder is None:
341  for sourceIndex, source in enumerate(measCat):
342  for plugin in self.undeblendedPlugins.iter():
343  self.doMeasurement(plugin, source, exposure)
344  if (currentTime := time.time()) > nextLogTime:
345  self.log.verbose("Undeblended measurement complete for %d sources out of %d",
346  sourceIndex + 1, nMeasCat)
347  nextLogTime = currentTime + self.config.loggingInterval
348 
349  # Now we loop over all of the sources one more time to compute the
350  # blendedness metrics
351  if self.doBlendedness:
352  for source in measCat:
353  self.blendPlugin.cpp.measureParentPixels(exposure.getMaskedImage(), source)
354 

Member Data Documentation

◆ algMetadata

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

Definition at line 225 of file baseMeasurement.py.

◆ blendPlugin

lsst.meas.base.sfm.SingleFrameMeasurementTask.blendPlugin

Definition at line 209 of file sfm.py.

◆ ConfigClass

lsst.meas.base.sfm.SingleFrameMeasurementTask.ConfigClass = SingleFrameMeasurementConfig
static

Definition at line 182 of file sfm.py.

◆ doBlendedness

lsst.meas.base.sfm.SingleFrameMeasurementTask.doBlendedness

Definition at line 208 of file sfm.py.

◆ NOISE_EXPOSURE_ID

string lsst.meas.base.sfm.SingleFrameMeasurementTask.NOISE_EXPOSURE_ID = "NOISE_EXPOSURE_ID"
static

Definition at line 196 of file sfm.py.

◆ NOISE_OFFSET

string lsst.meas.base.sfm.SingleFrameMeasurementTask.NOISE_OFFSET = "NOISE_OFFSET"
static

Definition at line 192 of file sfm.py.

◆ NOISE_SEED_MULTIPLIER

string lsst.meas.base.sfm.SingleFrameMeasurementTask.NOISE_SEED_MULTIPLIER = "NOISE_SEED_MULTIPLIER"
static

Definition at line 184 of file sfm.py.

◆ NOISE_SOURCE

string lsst.meas.base.sfm.SingleFrameMeasurementTask.NOISE_SOURCE = "NOISE_SOURCE"
static

Definition at line 188 of file sfm.py.

◆ plugins

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

Definition at line 218 of file baseMeasurement.py.

◆ schema

lsst.meas.base.sfm.SingleFrameMeasurementTask.schema

Definition at line 202 of file sfm.py.

◆ undeblendedPlugins

lsst.meas.base.baseMeasurement.BaseMeasurementTask.undeblendedPlugins
inherited

Definition at line 235 of file baseMeasurement.py.


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