lsst.ip.diffim  16.0-12-g1dc09ba+4
Public Member Functions | Public Attributes | List of all members
lsst.ip.diffim.dcrModel.DcrModel Class Reference

Public Member Functions

def __init__ (self, modelImages, filterInfo=None, psf=None)
 
def fromImage (cls, maskedImage, dcrNumSubfilters, filterInfo=None, psf=None)
 
def fromDataRef (cls, dataRef, datasetType="dcrCoadd", numSubfilters=None, kwargs)
 
def __len__ (self)
 
def __getitem__ (self, subfilter)
 
def __setitem__ (self, subfilter, maskedImage)
 
def filter (self)
 
def psf (self)
 
def bbox (self)
 
def mask (self)
 
def getReferenceImage (self, bbox=None)
 
def assign (self, dcrSubModel, bbox=None)
 
def buildMatchedTemplate (self, exposure=None, warpCtrl=None, visitInfo=None, bbox=None, wcs=None, mask=None)
 
def buildMatchedExposure (self, exposure=None, warpCtrl=None, visitInfo=None, bbox=None, wcs=None, mask=None)
 
def conditionDcrModel (self, modelImages, bbox, gain=1.)
 
def regularizeModelIter (self, subfilter, newModel, bbox, regularizationFactor, regularizationWidth=2)
 
def regularizeModelFreq (self, modelImages, bbox, regularizationFactor, regularizationWidth=2)
 
def calculateNoiseCutoff (self, maskedImage, statsCtrl, bufferSize, convergenceMaskPlanes="DETECTED", mask=None, bbox=None)
 
def applyImageThresholds (self, maskedImage, highThreshold=None, lowThreshold=None, regularizationWidth=2)
 

Public Attributes

 dcrNumSubfilters
 
 modelImages
 

Detailed Description

A model of the true sky after correcting chromatic effects.

Attributes
----------
dcrNumSubfilters : `int`
    Number of sub-filters used to model chromatic effects within a band.
filterInfo : `lsst.afw.image.Filter`
    The filter definition, set in the current instruments' obs package.
modelImages : `list` of `lsst.afw.image.MaskedImage`
    A list of masked images, each containing the model for one subfilter

Parameters
----------
modelImages : `list` of `lsst.afw.image.MaskedImage`
    A list of masked images, each containing the model for one subfilter.
filterInfo : `lsst.afw.image.Filter`, optional
    The filter definition, set in the current instruments' obs package.
    Required for any calculation of DCR, including making matched templates.

Notes
-----
The ``DcrModel`` contains an estimate of the true sky, at a higher
wavelength resolution than the input observations. It can be forward-
modeled to produce Differential Chromatic Refraction (DCR) matched
templates for a given ``Exposure``, and provides utilities for conditioning
the model in ``dcrAssembleCoadd`` to avoid oscillating solutions between
iterations of forward modeling or between the subfilters of the model.

Definition at line 36 of file dcrModel.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.ip.diffim.dcrModel.DcrModel.__init__ (   self,
  modelImages,
  filterInfo = None,
  psf = None 
)

Definition at line 66 of file dcrModel.py.

Member Function Documentation

◆ __getitem__()

def lsst.ip.diffim.dcrModel.DcrModel.__getitem__ (   self,
  subfilter 
)
Iterate over the subfilters of the DCR model.

Parameters
----------
subfilter : `int`
    Index of the current ``subfilter`` within the full band.
    Negative indices are allowed, and count in reverse order
    from the highest ``subfilter``.

Returns
-------
modelImage : `lsst.afw.image.MaskedImage`
    The DCR model for the given ``subfilter``.

Raises
------
IndexError
    If the requested ``subfilter`` is greater or equal to the number
    of subfilters in the model.

Definition at line 159 of file dcrModel.py.

◆ __len__()

def lsst.ip.diffim.dcrModel.DcrModel.__len__ (   self)
Return the number of subfilters.

Returns
-------
dcrNumSubfilters : `int`
    The number of DCR subfilters in the model.

Definition at line 149 of file dcrModel.py.

◆ __setitem__()

def lsst.ip.diffim.dcrModel.DcrModel.__setitem__ (   self,
  subfilter,
  maskedImage 
)
Update the model image for one subfilter.

Parameters
----------
subfilter : `int`
    Index of the current subfilter within the full band.
maskedImage : `lsst.afw.image.MaskedImage`
    The DCR model to set for the given ``subfilter``.

Raises
------
IndexError
    If the requested ``subfilter`` is greater or equal to the number
    of subfilters in the model.
ValueError
    If the bounding box of the new image does not match.

Definition at line 184 of file dcrModel.py.

◆ applyImageThresholds()

def lsst.ip.diffim.dcrModel.DcrModel.applyImageThresholds (   self,
  maskedImage,
  highThreshold = None,
  lowThreshold = None,
  regularizationWidth = 2 
)
Restrict image values to be between upper and lower limits.

This method flags all pixels in an image that are outside of the given
threshold values. The threshold values are taken from a reference image,
so noisy pixels are likely to get flagged. In order to exclude those
noisy pixels, the array of flags is eroded and dilated, which removes
isolated pixels outside of the thresholds from the list of pixels to be
modified. Pixels that remain flagged after this operation have their
values set to the appropriate upper or lower threshold value.

Parameters
----------
maskedImage : `lsst.afw.image.MaskedImage`
    The image to apply the thresholds to.
    The image plane values will be modified in place.
highThreshold : `numpy.ndarray`, optional
    Array of upper limit values for each pixel of ``maskedImage``.
lowThreshold : `numpy.ndarray`, optional
    Array of lower limit values for each pixel of ``maskedImage``.
regularizationWidth : `int`, optional
    Minimum radius of a region to include in regularization, in pixels.

Definition at line 493 of file dcrModel.py.

◆ assign()

def lsst.ip.diffim.dcrModel.DcrModel.assign (   self,
  dcrSubModel,
  bbox = None 
)
Update a sub-region of the ``DcrModel`` with new values.

Parameters
----------
dcrSubModel : `lsst.pipe.tasks.DcrModel`
    New model of the true scene after correcting chromatic effects.
bbox : `lsst.afw.geom.Box2I`, optional
    Sub-region of the coadd.
    Defaults to the bounding box of ``dcrSubModel``.

Raises
------
ValueError
    If the new model has a different number of subfilters.

Definition at line 268 of file dcrModel.py.

◆ bbox()

def lsst.ip.diffim.dcrModel.DcrModel.bbox (   self)
Return the common bounding box of each subfilter image.

Returns
-------
bbox : `lsst.afw.geom.Box2I`
    Bounding box of the DCR model.

Definition at line 231 of file dcrModel.py.

◆ buildMatchedExposure()

def lsst.ip.diffim.dcrModel.DcrModel.buildMatchedExposure (   self,
  exposure = None,
  warpCtrl = None,
  visitInfo = None,
  bbox = None,
  wcs = None,
  mask = None 
)
Wrapper to create an exposure from a template image.

Parameters
----------
exposure : `lsst.afw.image.Exposure`, optional
    The input exposure to build a matched template for.
    May be omitted if all of the metadata is supplied separately
warpCtrl : `lsst.afw.Math.WarpingControl`
    Configuration settings for warping an image
visitInfo : `lsst.afw.image.VisitInfo`, optional
    Metadata for the exposure. Ignored if ``exposure`` is set.
bbox : `lsst.afw.geom.Box2I`, optional
    Sub-region of the coadd. Ignored if ``exposure`` is set.
wcs : `lsst.afw.geom.SkyWcs`, optional
    Coordinate system definition (wcs) for the exposure.
    Ignored if ``exposure`` is set.
mask : `lsst.afw.image.Mask`, optional
    reference mask to use for the template image.

Returns
-------
templateExposure : `lsst.afw.image.exposureF`
    The DCR-matched template

Definition at line 347 of file dcrModel.py.

◆ buildMatchedTemplate()

def lsst.ip.diffim.dcrModel.DcrModel.buildMatchedTemplate (   self,
  exposure = None,
  warpCtrl = None,
  visitInfo = None,
  bbox = None,
  wcs = None,
  mask = None 
)
Create a DCR-matched template image for an exposure.

Parameters
----------
exposure : `lsst.afw.image.Exposure`, optional
    The input exposure to build a matched template for.
    May be omitted if all of the metadata is supplied separately
warpCtrl : `lsst.afw.Math.WarpingControl`, optional
    Configuration settings for warping an image.
    If not set, defaults to a lanczos3 warping kernel for the image,
    and a bilinear kernel for the mask
visitInfo : `lsst.afw.image.VisitInfo`, optional
    Metadata for the exposure. Ignored if ``exposure`` is set.
bbox : `lsst.afw.geom.Box2I`, optional
    Sub-region of the coadd. Ignored if ``exposure`` is set.
wcs : `lsst.afw.geom.SkyWcs`, optional
    Coordinate system definition (wcs) for the exposure.
    Ignored if ``exposure`` is set.
mask : `lsst.afw.image.Mask`, optional
    reference mask to use for the template image.

Returns
-------
templateImage : `lsst.afw.image.maskedImageF`
    The DCR-matched template

Raises
------
ValueError
    If neither ``exposure`` or all of ``visitInfo``, ``bbox``, and ``wcs`` are set.

Definition at line 292 of file dcrModel.py.

◆ calculateNoiseCutoff()

def lsst.ip.diffim.dcrModel.DcrModel.calculateNoiseCutoff (   self,
  maskedImage,
  statsCtrl,
  bufferSize,
  convergenceMaskPlanes = "DETECTED",
  mask = None,
  bbox = None 
)
Helper function to calculate the background noise level of an image.

Parameters
----------
maskedImage : `lsst.afw.image.MaskedImage`
    The input image to evaluate the background noise properties.
statsCtrl : `lsst.afw.math.StatisticsControl`
    Statistics control object for coaddition.
bufferSize : `int`
    Number of additional pixels to exclude
    from the edges of the bounding box.
convergenceMaskPlanes : `list` of `str`, or `str`
    Mask planes to use to calculate convergence.
mask : `lsst.afw.image.Mask`, Optional
    Optional alternate mask
bbox : `lsst.afw.geom.Box2I`, optional
    Sub-region of the masked image to calculate the noise level over.

Returns
-------
noiseCutoff : `float`
    The threshold value to treat pixels as noise in an image..

Definition at line 456 of file dcrModel.py.

◆ conditionDcrModel()

def lsst.ip.diffim.dcrModel.DcrModel.conditionDcrModel (   self,
  modelImages,
  bbox,
  gain = 1. 
)
Average two iterations' solutions to reduce oscillations.

Parameters
----------
modelImages : `list` of `lsst.afw.image.MaskedImage`
    The new DCR model images from the current iteration.
    The values will be modified in place.
bbox : `lsst.afw.geom.Box2I`
    Sub-region of the coadd
gain : `float`, optional
    Relative weight to give the new solution when updating the model.
    Defaults to 1.0, which gives equal weight to both solutions.

Definition at line 379 of file dcrModel.py.

◆ filter()

def lsst.ip.diffim.dcrModel.DcrModel.filter (   self)
Return the filter of the model.

Returns
-------
filter : `lsst.afw.image.Filter`
    The filter definition, set in the current instruments' obs package.

Definition at line 209 of file dcrModel.py.

◆ fromDataRef()

def lsst.ip.diffim.dcrModel.DcrModel.fromDataRef (   cls,
  dataRef,
  datasetType = "dcrCoadd",
  numSubfilters = None,
  kwargs 
)
Load an existing DcrModel from a repository.

Parameters
----------
dataRef : `lsst.daf.persistence.ButlerDataRef`
    Data reference defining the patch for coaddition and the
    reference Warp
datasetType : `str`, optional
    Name of the DcrModel in the registry {"dcrCoadd", "dcrCoadd_sub"}
numSubfilters : `int`
    Number of sub-filters used to model chromatic effects within a band.
**kwargs
    Additional keyword arguments to pass to look up the model in the data registry.
    Common keywords and their types include: ``tract``:`str`, ``patch``:`str`,
    ``bbox``:`lsst.afw.geom.Box2I`

Returns
-------
dcrModel : `lsst.pipe.tasks.DcrModel`
    Best fit model of the true sky after correcting chromatic effects.

Definition at line 114 of file dcrModel.py.

◆ fromImage()

def lsst.ip.diffim.dcrModel.DcrModel.fromImage (   cls,
  maskedImage,
  dcrNumSubfilters,
  filterInfo = None,
  psf = None 
)
Initialize a DcrModel by dividing a coadd between the subfilters.

Parameters
----------
maskedImage : `lsst.afw.image.MaskedImage`
    Input coadded image to divide equally between the subfilters.
dcrNumSubfilters : `int`
    Number of sub-filters used to model chromatic effects within a band.
filterInfo : `lsst.afw.image.Filter`, optional
    The filter definition, set in the current instruments' obs package.
    Required for any calculation of DCR, including making matched templates.
psf : `lsst.afw.detection.Psf`, optional
    Point spread function (PSF) of the model.
    Required if the ``DcrModel`` will be persisted.

Returns
-------
dcrModel : `lsst.pipe.tasks.DcrModel`
    Best fit model of the true sky after correcting chromatic effects.

Definition at line 73 of file dcrModel.py.

◆ getReferenceImage()

def lsst.ip.diffim.dcrModel.DcrModel.getReferenceImage (   self,
  bbox = None 
)
Create a simple template from the DCR model.

Parameters
----------
bbox : `lsst.afw.geom.Box2I`, optional
    Sub-region of the coadd. Returns the entire image if `None`.

Returns
-------
templateImage : `numpy.ndarray`
    The template with no chromatic effects applied.

Definition at line 252 of file dcrModel.py.

◆ mask()

def lsst.ip.diffim.dcrModel.DcrModel.mask (   self)
Return the common mask of each subfilter image.

Returns
-------
bbox : `lsst.afw.image.Mask`
    Mask plane of the DCR model.

Definition at line 242 of file dcrModel.py.

◆ psf()

def lsst.ip.diffim.dcrModel.DcrModel.psf (   self)
Return the psf of the model.

Returns
-------
psf : `lsst.afw.detection.Psf`
    Point spread function (PSF) of the model.

Definition at line 220 of file dcrModel.py.

◆ regularizeModelFreq()

def lsst.ip.diffim.dcrModel.DcrModel.regularizeModelFreq (   self,
  modelImages,
  bbox,
  regularizationFactor,
  regularizationWidth = 2 
)
Restrict large variations in the model between subfilters.

Parameters
----------
modelImages : `list` of `lsst.afw.image.MaskedImage`
    The new DCR model images from the current iteration.
    The values will be modified in place.
bbox : `lsst.afw.geom.Box2I`
    Sub-region to coadd
regularizationFactor : `float`
    Maximum relative change of the model allowed between subfilters.
regularizationWidth : `int`, optional
    Minimum radius of a region to include in regularization, in pixels.

Definition at line 429 of file dcrModel.py.

◆ regularizeModelIter()

def lsst.ip.diffim.dcrModel.DcrModel.regularizeModelIter (   self,
  subfilter,
  newModel,
  bbox,
  regularizationFactor,
  regularizationWidth = 2 
)
Restrict large variations in the model between iterations.

Parameters
----------
subfilter : `int`
    Index of the current subfilter within the full band.
newModel : `lsst.afw.image.MaskedImage`
    The new DCR model for one subfilter from the current iteration.
    Values in ``newModel`` that are extreme compared with the last
    iteration are modified in place.
bbox : `lsst.afw.geom.Box2I`
    Sub-region to coadd
regularizationFactor : `float`
    Maximum relative change of the model allowed between iterations.
regularizationWidth : int, optional
    Minimum radius of a region to include in regularization, in pixels.

Definition at line 404 of file dcrModel.py.

Member Data Documentation

◆ dcrNumSubfilters

lsst.ip.diffim.dcrModel.DcrModel.dcrNumSubfilters

Definition at line 67 of file dcrModel.py.

◆ modelImages

lsst.ip.diffim.dcrModel.DcrModel.modelImages

Definition at line 68 of file dcrModel.py.


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