DcrModel

class lsst.ip.diffim.DcrModel(modelImages, effectiveWavelength, bandwidth, filterLabel=None, psf=None, bbox=None, wcs=None, mask=None, variance=None, photoCalib=None)

Bases: object

A model of the true sky after correcting chromatic effects.

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.

Attributes:
dcrNumSubfiltersint

Number of sub-filters used to model chromatic effects within a band.

modelImageslist of lsst.afw.image.Image

A list of masked images, each containing the model for one subfilter

Attributes Summary

bandwidth

Return the bandwidth of the model.

bbox

Return the common bounding box of each subfilter image.

effectiveWavelength

Return the effective wavelength of the model.

filter

Return the filter label for the model.

mask

Return the common mask of each subfilter image.

psf

Return the psf of the model.

variance

Return the common variance of each subfilter image.

wcs

Return the WCS of each subfilter image.

Methods Summary

applyImageThresholds(image[, highThreshold, ...])

Restrict image values to be between upper and lower limits.

assign(dcrSubModel[, bbox])

Update a sub-region of the DcrModel with new values.

buildMatchedExposure([exposure, visitInfo, ...])

Wrapper to create an exposure from a template image.

buildMatchedTemplate([exposure, order, ...])

Create a DCR-matched template image for an exposure.

calculateNoiseCutoff(image, statsCtrl, ...)

Helper function to calculate the background noise level of an image.

conditionDcrModel(modelImages, bbox[, gain])

Average two iterations' solutions to reduce oscillations.

fromImage(maskedImage, dcrNumSubfilters, ...)

Initialize a DcrModel by dividing a coadd between the subfilters.

fromQuantum(availableCoaddRefs, ...)

Load an existing DcrModel from a Gen 3 repository.

getReferenceImage([bbox])

Calculate a reference image from the average of the subfilter images.

regularizeModelFreq(modelImages, bbox, ...)

Restrict large variations in the model between subfilters.

regularizeModelIter(subfilter, newModel, ...)

Restrict large variations in the model between iterations.

Attributes Documentation

bandwidth

Return the bandwidth of the model.

Returns:
bandwidthfloat

The bandwidth of the current filter, in nanometers.

bbox

Return the common bounding box of each subfilter image.

Returns:
bboxlsst.afw.geom.Box2I

Bounding box of the DCR model.

effectiveWavelength

Return the effective wavelength of the model.

Returns:
effectiveWavelengthfloat

The effective wavelength of the current filter, in nanometers.

filter

Return the filter label for the model.

Returns:
filterLabellsst.afw.image.FilterLabel

The filter used for the input observations.

mask

Return the common mask of each subfilter image.

Returns:
masklsst.afw.image.Mask

Mask plane of the DCR model.

psf

Return the psf of the model.

Returns:
psflsst.afw.detection.Psf

Point spread function (PSF) of the model.

variance

Return the common variance of each subfilter image.

Returns:
variancelsst.afw.image.Image

Variance plane of the DCR model.

wcs

Return the WCS of each subfilter image.

Returns:
bboxlsst.afw.geom.SkyWcs

Coordinate system definition (wcs) for the exposure.

Methods Documentation

applyImageThresholds(image, 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:
imagenumpy.ndarray

The image to apply the thresholds to. The values will be modified in place.

highThresholdnumpy.ndarray, optional

Array of upper limit values for each pixel of image.

lowThresholdnumpy.ndarray, optional

Array of lower limit values for each pixel of image.

regularizationWidthint, optional

Minimum radius of a region to include in regularization, in pixels.

assign(dcrSubModel, bbox=None)

Update a sub-region of the DcrModel with new values.

Parameters:
dcrSubModellsst.pipe.tasks.DcrModel

New model of the true scene after correcting chromatic effects.

bboxlsst.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.

buildMatchedExposure(exposure=None, visitInfo=None, bbox=None, mask=None)

Wrapper to create an exposure from a template image.

Parameters:
exposurelsst.afw.image.Exposure, optional

The input exposure to build a matched template for. May be omitted if all of the metadata is supplied separately

visitInfolsst.afw.image.VisitInfo, optional

Metadata for the exposure. Ignored if exposure is set.

bboxlsst.afw.geom.Box2I, optional

Sub-region of the coadd, or use the entire coadd if not supplied.

masklsst.afw.image.Mask, optional

reference mask to use for the template image.

Returns:
templateExposurelsst.afw.image.exposureF

The DCR-matched template

Raises:
RuntimeError

If no photcCalib is set.

buildMatchedTemplate(exposure=None, order=3, visitInfo=None, bbox=None, mask=None, splitSubfilters=True, splitThreshold=0.0, amplifyModel=1.0)

Create a DCR-matched template image for an exposure.

Parameters:
exposurelsst.afw.image.Exposure, optional

The input exposure to build a matched template for. May be omitted if all of the metadata is supplied separately

orderint, optional

Interpolation order of the DCR shift.

visitInfolsst.afw.image.VisitInfo, optional

Metadata for the exposure. Ignored if exposure is set.

bboxlsst.afw.geom.Box2I, optional

Sub-region of the coadd, or use the entire coadd if not supplied.

masklsst.afw.image.Mask, optional

reference mask to use for the template image.

splitSubfiltersbool, optional

Calculate DCR for two evenly-spaced wavelengths in each subfilter, instead of at the midpoint. Default: True

splitThresholdfloat, optional

Minimum DCR difference within a subfilter required to use splitSubfilters

amplifyModelfloat, optional

Multiplication factor to amplify differences between model planes. Used to speed convergence of iterative forward modeling.

Returns:
templateImagelsst.afw.image.ImageF

The DCR-matched template

Raises:
ValueError

If neither exposure or visitInfo are set.

calculateNoiseCutoff(image, statsCtrl, bufferSize, convergenceMaskPlanes='DETECTED', mask=None, bbox=None)

Helper function to calculate the background noise level of an image.

Parameters:
imagelsst.afw.image.Image

The input image to evaluate the background noise properties.

statsCtrllsst.afw.math.StatisticsControl

Statistics control object for coaddition.

bufferSizeint

Number of additional pixels to exclude from the edges of the bounding box.

convergenceMaskPlaneslist of str, or str

Mask planes to use to calculate convergence.

masklsst.afw.image.Mask, Optional

Optional alternate mask

bboxlsst.afw.geom.Box2I, optional

Sub-region of the masked image to calculate the noise level over.

Returns:
noiseCutofffloat

The threshold value to treat pixels as noise in an image..

conditionDcrModel(modelImages, bbox, gain=1.0)

Average two iterations’ solutions to reduce oscillations.

Parameters:
modelImageslist of lsst.afw.image.Image

The new DCR model images from the current iteration. The values will be modified in place.

bboxlsst.afw.geom.Box2I

Sub-region of the coadd

gainfloat, optional

Relative weight to give the new solution when updating the model. Defaults to 1.0, which gives equal weight to both solutions.

classmethod fromImage(maskedImage, dcrNumSubfilters, effectiveWavelength, bandwidth, wcs=None, filterLabel=None, psf=None, photoCalib=None)

Initialize a DcrModel by dividing a coadd between the subfilters.

Parameters:
maskedImagelsst.afw.image.MaskedImage

Input coadded image to divide equally between the subfilters.

dcrNumSubfiltersint

Number of sub-filters used to model chromatic effects within a band.

effectiveWavelengthfloat

The effective wavelengths of the current filter, in nanometers.

bandwidthfloat

The bandwidth of the current filter, in nanometers.

wcslsst.afw.geom.SkyWcs

Coordinate system definition (wcs) for the exposure.

filterLabellsst.afw.image.FilterLabel, optional

The filter label, set in the current instruments’ obs package. Required for any calculation of DCR, including making matched templates.

psflsst.afw.detection.Psf, optional

Point spread function (PSF) of the model. Required if the DcrModel will be persisted.

photoCaliblsst.afw.image.PhotoCalib, optional

Calibration to convert instrumental flux and flux error to nanoJansky.

Returns:
dcrModellsst.pipe.tasks.DcrModel

Best fit model of the true sky after correcting chromatic effects.

classmethod fromQuantum(availableCoaddRefs, effectiveWavelength, bandwidth, numSubfilters)

Load an existing DcrModel from a Gen 3 repository.

Parameters:
availableCoaddRefsdict [int, lsst.daf.butler.DeferredDatasetHandle]

Dictionary of spatially relevant retrieved coadd patches, indexed by their sequential patch number.

effectiveWavelengthfloat

The effective wavelengths of the current filter, in nanometers.

bandwidthfloat

The bandwidth of the current filter, in nanometers.

numSubfiltersint

Number of subfilters in the DcrCoadd.

Returns:
dcrModellsst.pipe.tasks.DcrModel

Best fit model of the true sky after correcting chromatic effects.

getReferenceImage(bbox=None)

Calculate a reference image from the average of the subfilter images.

Parameters:
bboxlsst.afw.geom.Box2I, optional

Sub-region of the coadd. Returns the entire image if None.

Returns:
refImagenumpy.ndarray

The reference image with no chromatic effects applied.

regularizeModelFreq(modelImages, bbox, statsCtrl, regularizationFactor, regularizationWidth=2, mask=None, convergenceMaskPlanes='DETECTED')

Restrict large variations in the model between subfilters.

Parameters:
modelImageslist of lsst.afw.image.Image

The new DCR model images from the current iteration. The values will be modified in place.

bboxlsst.afw.geom.Box2I

Sub-region to coadd

statsCtrllsst.afw.math.StatisticsControl

Statistics control object for coaddition.

regularizationFactorfloat

Maximum relative change of the model allowed between subfilters.

regularizationWidthint, optional

Minimum radius of a region to include in regularization, in pixels.

masklsst.afw.image.Mask, optional

Optional alternate mask

convergenceMaskPlaneslist of str, or str, optional

Mask planes to use to calculate convergence.

Notes

This implementation of frequency regularization restricts each subfilter image to be a smoothly-varying function times a reference image.

regularizeModelIter(subfilter, newModel, bbox, regularizationFactor, regularizationWidth=2)

Restrict large variations in the model between iterations.

Parameters:
subfilterint

Index of the current subfilter within the full band.

newModellsst.afw.image.Image

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.

bboxlsst.afw.geom.Box2I

Sub-region to coadd

regularizationFactorfloat

Maximum relative change of the model allowed between iterations.

regularizationWidthint, optional

Minimum radius of a region to include in regularization, in pixels.