lsst.meas.base gcf00a76f74+68111a8d4a
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
lsst.meas.base.noiseReplacer.NoiseReplacer Class Reference

Public Member Functions

def __init__ (self, config, exposure, footprints, noiseImage=None, exposureId=None, log=None)
 
def insertSource (self, id)
 
def removeSource (self, id)
 
def end (self)
 
def getNoiseGenerator (self, exposure, noiseImage, noiseMeanVar, exposureId=None)
 

Public Attributes

 noiseSource
 
 noiseOffset
 
 noiseSeedMultiplier
 
 noiseGenMean
 
 noiseGenStd
 
 removeplanes
 
 otherbitmask
 
 heavies
 
 heavyNoise
 

Static Public Attributes

 ConfigClass = NoiseReplacerConfig
 
 exposure = None
 
 footprints = None
 
 log = None
 

Detailed Description

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.log.Log` or `logging.Logger`, 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
`~lsst.afw.detection.heavyFootprint.HeavyFootprint`\ s attached to the
`~lsst.afw.table.SourceRecord`\ s.  The algorithm works as follows:

#. All pixels in the source `~lsst.afw.detection.Footprint`\ s are replaced
   with artificially generated noise (in `NoiseReplacer.__init__`).
#. Before each source is measured, we restore the original pixel data by
   inserting that source's
   `~lsst.afw.detection.heavyFootprint.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 an `~lsst.pipe.base.Task`,
as the lifetime of a ``NoiseReplacer`` now corresponds to a single
exposure, not an entire processing run.

When processing the ``footprints`` parameter, this routine should create
`~lsst.afw.detection.heavyFootprint.HeavyFootprint`\ s for any non-Heavy
`~lsst.afw.detection.Footprint`\ s, and replace them in the dictionary. It
should then create a dict of
`~lsst.afw.detection.heavyFootprint.HeavyFootprint`\ 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.

Definition at line 58 of file noiseReplacer.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.meas.base.noiseReplacer.NoiseReplacer.__init__ (   self,
  config,
  exposure,
  footprints,
  noiseImage = None,
  exposureId = None,
  log = None 
)

Definition at line 136 of file noiseReplacer.py.

Member Function Documentation

◆ end()

def lsst.meas.base.noiseReplacer.NoiseReplacer.end (   self)
End the NoiseReplacer.

Restores original data to the exposure from the heavies dictionary and
the mask planes to their original state.

Definition at line 272 of file noiseReplacer.py.

◆ getNoiseGenerator()

def lsst.meas.base.noiseReplacer.NoiseReplacer.getNoiseGenerator (   self,
  exposure,
  noiseImage,
  noiseMeanVar,
  exposureId = None 
)
Return a generator of artificial noise.

Returns
-------
noiseGenerator : `lsst.afw.image.noiseReplacer.NoiseGenerator`

Definition at line 296 of file noiseReplacer.py.

◆ insertSource()

def lsst.meas.base.noiseReplacer.NoiseReplacer.insertSource (   self,
  id 
)
Insert the heavy footprint of a given source into the exposure.

Parameters
----------
id : `int`
    ID of the source to insert from original dictionary of footprints.

Notes
-----
Also adjusts the mask plane to show the source of this footprint.

Definition at line 212 of file noiseReplacer.py.

◆ removeSource()

def lsst.meas.base.noiseReplacer.NoiseReplacer.removeSource (   self,
  id 
)
Replace the heavy footprint of a given source with noise.

The same artificial noise is used as in the original replacement.

Parameters
----------
id : `int`
    ID of the source to replace from original dictionary of footprints.

Notes
-----
Also restores the mask plane.

Definition at line 239 of file noiseReplacer.py.

Member Data Documentation

◆ ConfigClass

lsst.meas.base.noiseReplacer.NoiseReplacer.ConfigClass = NoiseReplacerConfig
static

Definition at line 122 of file noiseReplacer.py.

◆ exposure

lsst.meas.base.noiseReplacer.NoiseReplacer.exposure = None
static

Definition at line 124 of file noiseReplacer.py.

◆ footprints

lsst.meas.base.noiseReplacer.NoiseReplacer.footprints = None
static

Definition at line 128 of file noiseReplacer.py.

◆ heavies

lsst.meas.base.noiseReplacer.NoiseReplacer.heavies

Definition at line 173 of file noiseReplacer.py.

◆ heavyNoise

lsst.meas.base.noiseReplacer.NoiseReplacer.heavyNoise

Definition at line 197 of file noiseReplacer.py.

◆ log

lsst.meas.base.noiseReplacer.NoiseReplacer.log = None
static

Definition at line 132 of file noiseReplacer.py.

◆ noiseGenMean

lsst.meas.base.noiseReplacer.NoiseReplacer.noiseGenMean

Definition at line 141 of file noiseReplacer.py.

◆ noiseGenStd

lsst.meas.base.noiseReplacer.NoiseReplacer.noiseGenStd

Definition at line 142 of file noiseReplacer.py.

◆ noiseOffset

lsst.meas.base.noiseReplacer.NoiseReplacer.noiseOffset

Definition at line 139 of file noiseReplacer.py.

◆ noiseSeedMultiplier

lsst.meas.base.noiseReplacer.NoiseReplacer.noiseSeedMultiplier

Definition at line 140 of file noiseReplacer.py.

◆ noiseSource

lsst.meas.base.noiseReplacer.NoiseReplacer.noiseSource

Definition at line 138 of file noiseReplacer.py.

◆ otherbitmask

lsst.meas.base.noiseReplacer.NoiseReplacer.otherbitmask

Definition at line 171 of file noiseReplacer.py.

◆ removeplanes

lsst.meas.base.noiseReplacer.NoiseReplacer.removeplanes

Definition at line 153 of file noiseReplacer.py.


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