LSST Applications 24.1.5,g02d81e74bb+fa3a7a026e,g180d380827+a53a32eff8,g2079a07aa2+86d27d4dc4,g2305ad1205+c0501b3732,g295015adf3+7d3e92f0ec,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g33d1c0ed96+0e5473021a,g3a166c0a6a+0e5473021a,g3ddfee87b4+5dd1654d75,g48712c4677+3bf1020dcb,g487adcacf7+065c13d9cf,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+d7ac436cfb,g5a732f18d5+53520f316c,g64a986408d+fa3a7a026e,g858d7b2824+fa3a7a026e,g8a8a8dda67+585e252eca,g99cad8db69+a5a909b84f,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+4cf350ccb2,gb0e22166c9+60f28cb32d,gba4ed39666+c2a2e4ac27,gbb8dafda3b+f991a0b59f,gc120e1dc64+9ccbfdb8be,gc28159a63d+0e5473021a,gcf0d15dbbd+5dd1654d75,gd96a1ce819+42fd0ee607,gdaeeff99f8+f9a426f77a,ge6526c86ff+0d71447b4b,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gff1a9f87cc+fa3a7a026e
LSST Data Management Base Package
Loading...
Searching...
No Matches
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

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

Public Attributes

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

349 def measure(self, measCat, exposure):
350 """Backwards-compatibility alias for `run`.
351 """
352 self.run(measCat, exposure)

◆ run()

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

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

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

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

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 256 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 254 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 252 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 253 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: