LSST Applications g07dc498a13+7851b72aa9,g1409bbee79+7851b72aa9,g1a7e361dbc+7851b72aa9,g1fd858c14a+a4e18a0dda,g33399d78f5+a0324bbf49,g35bb328faa+e55fef2c71,g3bd4b5ce2c+8524b1c0c8,g53246c7159+e55fef2c71,g579b87e3d2+a58ba40925,g60b5630c4e+7b4465799a,g78460c75b0+8427c4cc8f,g78619a8342+5517f7db9e,g786e29fd12+307f82e6af,g8534526c7b+8e1c6b434f,g89139ef638+7851b72aa9,g8b49a6ea8e+7b4465799a,g8ffcb69f3d+0065d7bbc8,g9125e01d80+e55fef2c71,g97b8272a79+a8c4cb337e,g989de1cb63+7851b72aa9,g9f33ca652e+747bd1f1f9,gaaedd4e678+7851b72aa9,gabe3b4be73+9c0c3c7524,gb1101e3267+c03a154bbb,gb58c049af0+28045f66fd,gc1fe0db326+7b4465799a,gca43fec769+e55fef2c71,gce7788e931+99adca4f64,gcf25f946ba+a0324bbf49,gd397e13551+18f805d5e0,gd6cbbdb0b4+f6e5445f66,gde0f65d7ad+78b6ec8427,ge278dab8ac+b4c2c8faf7,geab183fbe5+7b4465799a,gecb8035dfe+1f480bec5e,gf58bf46354+e55fef2c71,gf92a8ffd38+e7bc33f3ea,gfe7187db8c+38a2c5c626,w.2025.03
LSST Data Management Base Package
Loading...
Searching...
No Matches
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

 __init__ (self, schema, algMetadata=None, **kwds)
 
 run (self, measCat, exposure, noiseImage=None, exposureId=None, beginOrder=None, endOrder=None, footprints=None)
 
 runPlugins (self, noiseReplacer, measCat, exposure, beginOrder=None, endOrder=None)
 
 measure (self, measCat, exposure)
 

Public Attributes

 schema
 
 plugins
 
 doBlendedness
 
 blendPlugin
 
 NOISE_SEED_MULTIPLIER
 
 NOISE_SOURCE
 
 NOISE_OFFSET
 
 NOISE_EXPOSURE_ID
 

Static Public Attributes

 ConfigClass = SingleFrameMeasurementConfig
 
str NOISE_SEED_MULTIPLIER = "NOISE_SEED_MULTIPLIER"
 
str NOISE_SOURCE = "NOISE_SOURCE"
 
str NOISE_OFFSET = "NOISE_OFFSET"
 
str NOISE_EXPOSURE_ID = "NOISE_EXPOSURE_ID"
 

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 161 of file sfm.py.

Constructor & Destructor Documentation

◆ __init__()

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

Reimplemented from lsst.meas.base.baseMeasurement.BaseMeasurementTask.

Definition at line 195 of file sfm.py.

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

Member Function Documentation

◆ measure()

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

Definition at line 361 of file sfm.py.

361 def measure(self, measCat, exposure):
362 """Backwards-compatibility alias for `run`.
363 """
364 self.run(measCat, exposure)

◆ run()

lsst.meas.base.sfm.SingleFrameMeasurementTask.run ( self,
measCat,
exposure,
noiseImage = None,
exposureId = None,
beginOrder = None,
endOrder = None,
footprints = 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.
    footprints : `dict` {`int`: `lsst.afw.detection.Footprint`}, optional
        List of footprints to use for noise replacement. If this is not
        supplied then the footprints from the measCat are used.

Definition at line 209 of file sfm.py.

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

◆ runPlugins()

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 274 of file sfm.py.

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

Member Data Documentation

◆ blendPlugin

lsst.meas.base.sfm.SingleFrameMeasurementTask.blendPlugin

Definition at line 204 of file sfm.py.

◆ ConfigClass

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

Definition at line 177 of file sfm.py.

◆ doBlendedness

lsst.meas.base.sfm.SingleFrameMeasurementTask.doBlendedness

Definition at line 203 of file sfm.py.

◆ NOISE_EXPOSURE_ID [1/2]

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

Definition at line 191 of file sfm.py.

◆ NOISE_EXPOSURE_ID [2/2]

lsst.meas.base.sfm.SingleFrameMeasurementTask.NOISE_EXPOSURE_ID

Definition at line 268 of file sfm.py.

◆ NOISE_OFFSET [1/2]

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

Definition at line 187 of file sfm.py.

◆ NOISE_OFFSET [2/2]

lsst.meas.base.sfm.SingleFrameMeasurementTask.NOISE_OFFSET

Definition at line 266 of file sfm.py.

◆ NOISE_SEED_MULTIPLIER [1/2]

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

Definition at line 179 of file sfm.py.

◆ NOISE_SEED_MULTIPLIER [2/2]

lsst.meas.base.sfm.SingleFrameMeasurementTask.NOISE_SEED_MULTIPLIER

Definition at line 264 of file sfm.py.

◆ NOISE_SOURCE [1/2]

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

Definition at line 183 of file sfm.py.

◆ NOISE_SOURCE [2/2]

lsst.meas.base.sfm.SingleFrameMeasurementTask.NOISE_SOURCE

Definition at line 265 of file sfm.py.

◆ plugins

lsst.meas.base.sfm.SingleFrameMeasurementTask.plugins

Definition at line 202 of file sfm.py.

◆ schema

lsst.meas.base.sfm.SingleFrameMeasurementTask.schema

Definition at line 197 of file sfm.py.


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