lsst.ip.diffim gd3aeb4ad21+de74bbf6b5
Loading...
Searching...
No Matches
lsst.ip.diffim.getTemplate Namespace Reference

Classes

class  GetTemplateConnections
class  GetTemplateTask
class  GetDcrTemplateConnections

Functions

 _pixelTransform (fromWcs, toWcs)
 _getImageOverlap (record, coaddWcs, scienceFootprint, coaddToScienceTransform, scienceBox, border)
 _warpBorder (kernelName)
 _warpKernelSumSq (kernelName, nPhase=100)
 setDefaults (self)
 checkPatchList (self, patchList)
 getDcrModel (self, patchList, coaddRefs, visitInfo)
 _selectDataRef (coaddRef, tract, patch)

Variables

int _PSF_STAMP_SIGMAS = 5
str _UNKNOWN_INSTRUMENT = "UNKNOWN"
float _FOOTPRINT_MARGIN = 32.0
 output_image_type
type allowed
bool optional = False,
str default = "legacy",
 raiseOnUndefinedMaskMap
 detectorPolygon = geom.Box2D(bbox)
int overlappingArea = 0
 dataIds = collections.defaultdict(list)
 patchList = dict()
 dataId = coaddRef.dataId
 subfilter = dataId["subfilter"]
 patchWcs = skymap[dataId["tract"]].getWcs()
 patchBBox = skymap[dataId["tract"]][dataId["patch"]].getOuterBBox()
 patchCorners = patchWcs.pixelToSky(geom.Box2D(patchBBox).getCorners())
 patchPolygon = afwGeom.Polygon(wcs.skyToPixel(patchCorners))
 coaddExposures = self.getDcrModel(patchList, dcrCoaddExposureHandles, visitInfo)

Function Documentation

◆ _getImageOverlap()

_getImageOverlap ( record,
coaddWcs,
scienceFootprint,
coaddToScienceTransform,
scienceBox,
border )
protected
Return the region enclosing the overlap of the science image and one
input image of the coadd.

Note that there are three different WCS's involved here: the WCS of the
original image that was warped to contribute to the coadd, the coadd WCS,
and the current science image WCS that we are building a template for.

Parameters
----------
record : `lsst.afw.table.ExposureRecord`
    Input record of a coadd, with the input's WCS, bounding box and
    optional valid polygon.
coaddWcs : `lsst.afw.geom.SkyWcs`
    WCS of the coadd.
scienceFootprint : `lsst.images.Region`
    ``scienceBox`` in coadd pixels, grown by ``_FOOTPRINT_MARGIN``.
coaddToScienceTransform : `lsst.images.Transform`
    Transform from coadd pixels to science image pixels.
scienceBox : `lsst.images.Box`
    Bounding box of the science image.
border : `float`
    Width, in input pixels, of the border of the input that warping left
    out of the coadd.

Returns
-------
footprint : `lsst.images.Polygon` or `None`
    The part of ``scienceBox`` the input's warp covers, in science image
    pixels, or `None` if it covers none of it.

Definition at line 103 of file getTemplate.py.

◆ _pixelTransform()

_pixelTransform ( fromWcs,
toWcs )
protected
Return a chainable transformation between two pixel frames.

Parameters
----------
fromWcs, toWcs : `lsst.afw.geom.SkyWcs`
    WCSs of the input and output pixels.

Returns
-------
transform : `lsst.images.Transform`
    Transform from ``fromWcs`` pixels to ``toWcs`` pixels.

Definition at line 84 of file getTemplate.py.

◆ _selectDataRef()

_selectDataRef ( coaddRef,
tract,
patch )
protected

Definition at line 1571 of file getTemplate.py.

◆ _warpBorder()

_warpBorder ( kernelName)
protected
Return the width of the border of an image that warping leaves out.

A warped pixel is computed only where the whole kernel lies on the image.

Parameters
----------
kernelName : `str`
    Name of the warping kernel, as `lsst.afw.math.Warper` takes it.

Returns
-------
border : `float`
    Width of the border on each side, in pixels from the edge of the
    image's bounding box; 2.5 for ``lanczos3``.

Definition at line 156 of file getTemplate.py.

◆ _warpKernelSumSq()

_warpKernelSumSq ( kernelName,
nPhase = 100 )
protected
Compute the phase-averaged sum of squared values of a warping kernel.

Warping with a kernel normalized to unit sum multiplies the variance by
this sum, which is less than one. The power the warp took off the
diagonal became covariance between neighboring pixels, which a variance
plane cannot represent, so dividing by it restores the noise power: the
variance of a flux measured over a region and not a single pixel.

Parameters
----------
kernelName : `str`
    Name of the warping kernel, as `lsst.afw.math.Warper` takes it.
nPhase : `int`, optional
    Number of sub-pixel phases to average over.

Returns
-------
sumSq : `float`
    Sum of the squared 2-D kernel values, averaged over sub-pixel
    phase. Converges with large ``nPhase`` to 0.798 for ``lanczos3``,
    4/9 for ``bilinear``, and 1 for no interpolation.

Notes
-----
The kernels are separable and the phases of the two axes independent,
so this is the square of the 1-D average. The warper normalizes the
kernel to unit sum at each phase, which the analytic Lanczos integral
does not include, so the average is computed from the kernel itself.

Definition at line 177 of file getTemplate.py.

◆ checkPatchList()

checkPatchList ( self,
patchList )
Check that all of the DcrModel subfilters are present for each
patch.

Parameters
----------
patchList : `dict`
    Dict of the patches containing valid data for each tract.

Raises
------
RuntimeError
    If the number of exposures found for a patch does not match the
    number of subfilters.

Definition at line 1510 of file getTemplate.py.

◆ getDcrModel()

getDcrModel ( self,
patchList,
coaddRefs,
visitInfo )
Build DCR-matched coadds from a list of exposure references.

Parameters
----------
patchList : `dict`
    Dict of the patches containing valid data for each tract.
coaddRefs : `list` [`lsst.daf.butler.DeferredDatasetHandle`]
    Data references to `~lsst.afw.image.Exposure` representing
    DcrModels that overlap the detector.
visitInfo : `lsst.afw.image.VisitInfo`
    Metadata for the science image.

Returns
-------
coaddExposures : `list` [`lsst.afw.image.Exposure`]
    Coadd exposures that overlap the detector.

Definition at line 1534 of file getTemplate.py.

◆ setDefaults()

setDefaults ( self)

Definition at line 395 of file getTemplate.py.

Variable Documentation

◆ _FOOTPRINT_MARGIN

float lsst.ip.diffim.getTemplate._FOOTPRINT_MARGIN = 32.0
protected

Definition at line 75 of file getTemplate.py.

◆ _PSF_STAMP_SIGMAS

int lsst.ip.diffim.getTemplate._PSF_STAMP_SIGMAS = 5
protected

Definition at line 67 of file getTemplate.py.

◆ _UNKNOWN_INSTRUMENT

str lsst.ip.diffim.getTemplate._UNKNOWN_INSTRUMENT = "UNKNOWN"
protected

Definition at line 70 of file getTemplate.py.

◆ allowed

type lsst.ip.diffim.getTemplate.allowed
Initial value:
{
"legacy": "Write as a lsst.afw.image.ExposureF.",
"future": "Write as a lsst.images.DifferenceImage.",
},

Definition at line 378 of file getTemplate.py.

◆ coaddExposures

lsst.ip.diffim.getTemplate.coaddExposures = self.getDcrModel(patchList, dcrCoaddExposureHandles, visitInfo)

Definition at line 1507 of file getTemplate.py.

◆ dataId

lsst.ip.diffim.getTemplate.dataId = coaddRef.dataId

Definition at line 1479 of file getTemplate.py.

◆ dataIds

lsst.ip.diffim.getTemplate.dataIds = collections.defaultdict(list)

Definition at line 1476 of file getTemplate.py.

◆ default

str lsst.ip.diffim.getTemplate.default = "legacy",

Definition at line 384 of file getTemplate.py.

◆ detectorPolygon

lsst.ip.diffim.getTemplate.detectorPolygon = geom.Box2D(bbox)
numSubfilters = pexConfig.Field(
    doc="Number of subfilters in the DcrCoadd.",
    dtype=int,
    default=3,
)
effectiveWavelength = pexConfig.Field(
    doc="Effective wavelength of the filter in nm.",
    optional=False,
    dtype=float,
)
bandwidth = pexConfig.Field(
    doc="Bandwidth of the physical filter.",
    optional=False,
    dtype=float,
)

def validate(self):
    if self.effectiveWavelength is None or self.bandwidth is None:
        raise ValueError(
            "The effective wavelength and bandwidth of the physical filter "
            "must be set in the getTemplate config for DCR coadds. "
            "Required until transmission curves are used in DM-13668."
        )


class GetDcrTemplateTask(GetTemplateTask):
ConfigClass = GetDcrTemplateConfig
_DefaultName = "getDcrTemplate"

def runQuantum(self, butlerQC, inputRefs, outputRefs):
    inputs = butlerQC.get(inputRefs)
    detector = inputs.pop("detector")
    bbox = detector.getBBox()
    wcs = inputs.pop("wcs")
    dcrCoaddExposureHandles = inputs.pop("dcrCoadds")
    skymap = inputs.pop("skyMap")
    visitInfo = inputs.pop("visitInfo")
    # This task never converts its output, so the observation metadata
    # that the conversion needs is dropped here.
    inputs.pop("obs_info", None)

    # This should not happen with a properly configured execution context.
    assert not inputs, "runQuantum got more inputs than expected"

    results = self.getExposures(
        dcrCoaddExposureHandles, bbox, skymap, wcs, visitInfo
    )
    physical_filter = butlerQC.quantum.dataId["physical_filter"]
    outputs = self.run(
        coaddExposureHandles=results.coaddExposures,
        bbox=bbox,
        wcs=wcs,
        dataIds=results.dataIds,
        physical_filter=physical_filter,
        visit=outputRefs.template.dataId["visit"],
        instrument=butlerQC.quantum.dataId["instrument"],
    )
    butlerQC.put(outputs, outputRefs)

def getExposures(self, dcrCoaddExposureHandles, bbox, skymap, wcs, visitInfo):

Definition at line 1474 of file getTemplate.py.

◆ optional

bool lsst.ip.diffim.getTemplate.optional = False,

Definition at line 383 of file getTemplate.py.

◆ output_image_type

lsst.ip.diffim.getTemplate.output_image_type

Definition at line 240 of file getTemplate.py.

◆ overlappingArea

int lsst.ip.diffim.getTemplate.overlappingArea = 0

Definition at line 1475 of file getTemplate.py.

◆ patchBBox

lsst.ip.diffim.getTemplate.patchBBox = skymap[dataId["tract"]][dataId["patch"]].getOuterBBox()

Definition at line 1482 of file getTemplate.py.

◆ patchCorners

lsst.ip.diffim.getTemplate.patchCorners = patchWcs.pixelToSky(geom.Box2D(patchBBox).getCorners())

Definition at line 1483 of file getTemplate.py.

◆ patchList

lsst.ip.diffim.getTemplate.patchList = dict()

Definition at line 1477 of file getTemplate.py.

◆ patchPolygon

lsst.ip.diffim.getTemplate.patchPolygon = afwGeom.Polygon(wcs.skyToPixel(patchCorners))

Definition at line 1484 of file getTemplate.py.

◆ patchWcs

lsst.ip.diffim.getTemplate.patchWcs = skymap[dataId["tract"]].getWcs()

Definition at line 1481 of file getTemplate.py.

◆ raiseOnUndefinedMaskMap

lsst.ip.diffim.getTemplate.raiseOnUndefinedMaskMap
Initial value:
= pexConfig.Field(
dtype=bool,
default=False,
doc="Raise if the template has pixels set in a mask plane that"
" `lsst.images` does not map? If False, log a warning and drop that"
" plane from the output instead."
" Only used with output_image_type='future'.",
)

Definition at line 386 of file getTemplate.py.

◆ subfilter

lsst.ip.diffim.getTemplate.subfilter = dataId["subfilter"]

Definition at line 1480 of file getTemplate.py.