NoiseReplacer¶
-
class
lsst.meas.base.
NoiseReplacer
(config, exposure, footprints, noiseImage=None, exposureId=None, log=None)¶ Bases:
object
Replace sources with noise during measurement.
Parameters: - config :
NoiseReplacerConfig
Configuration.
- exposure :
lsst.afw.image.Exposure
Image in which sources will be replaced by noise. During operation, the image will be modified in-place to replace all sources. At the end of the measurment procedure, the original sources will be replaced.
- footprints :
dict
Mapping of
id
to a tuple of(parent, Footprint)
. When used in single-frame measurement,id
is the source ID, but in forced photometry this is the reference ID (as that is used to determine deblend families).- noiseImage :
lsst.afw.image.ImageF
An image used as a predictable noise replacement source. Used during testing only.
- log :
lsst.log.Log
, optional Logger to use for status messages; no status messages will be recorded if
None
.
Notes
When measuring a source (or the children associated with a parent source), this class is used to replace its neighbors with noise, using the deblender’s definition of the sources as stored in
HeavyFootprint
s attached to theSourceRecord
s. The algorithm works as follows:- All pixels in the source
Footprint
s are replaced with artificially generated noise (inNoiseReplacer.__init__
). - Before each source is measured, we restore the original pixel data by
inserting that source’s
HeavyFootprint
(from the deblender) into the image. - After measurement, we again replace the source pixels with (the same) artificial noise.
- After measuring all sources, the image is returned to its original state.
This is a functional copy of the code in the older
ReplaceWithNoiseTask
, but with a slightly different API needed for the new measurement framework; note that it is not anTask
, as the lifetime of aNoiseReplacer
now corresponds to a single exposure, not an entire processing run.When processing the
footprints
parameter, this routine should createHeavyFootprint
s for any non-HeavyFootprint
s, and replace them in the dictionary. It should then create a dict ofHeavyFootprint
s containing noise, but only for parent objects, then replace all sources with noise. This should ignore any footprints that lay outside the bounding box of the exposure, and clip those that lie on the border.As the code currently stands, the heavy footprint for a deblended object must be available from the input catalog. If it is not, it cannot be reproduced here. In that case, the topmost parent in the objects parent chain must be used. The heavy footprint for that source is created in this class from the masked image.
Attributes Summary
exposure
Image on which the NoiseReplacer is operating ( lsst.afw.image.Exposure
).footprints
Mapping of id
to a tuple of(parent, Footprint)
(dict
).log
Logger used for status messages. Methods Summary
end
()End the NoiseReplacer. getNoiseGenerator
(exposure, noiseImage, …)Return a generator of artificial noise. insertSource
(id)Insert the heavy footprint of a given source into the exposure. removeSource
(id)Replace the heavy footprint of a given source with noise. Attributes Documentation
-
exposure
= None¶ Image on which the NoiseReplacer is operating (
lsst.afw.image.Exposure
).
-
log
= None¶ Logger used for status messages.
Methods Documentation
-
end
()¶ End the NoiseReplacer.
Restores original data to the exposure from the heavies dictionary and the mask planes to their original state.
-
getNoiseGenerator
(exposure, noiseImage, noiseMeanVar, exposureId=None)¶ Return a generator of artificial noise.
Returns: - noiseGenerator :
lsst.afw.image.noiseReplacer.NoiseGenerator
- noiseGenerator :
- config :