lsst.ip.diffim gc22169103f+f78dd39cfd
Loading...
Searching...
No Matches
lsst.ip.diffim.getTemplate Namespace Reference

Classes

class  GetTemplateConnections
class  GetTemplateTask
class  GetDcrTemplateConnections

Functions

 _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"
 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

◆ _selectDataRef()

_selectDataRef ( coaddRef,
tract,
patch )
protected

Definition at line 1387 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 70 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 1326 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 1350 of file getTemplate.py.

◆ setDefaults()

setDefaults ( self)

Definition at line 286 of file getTemplate.py.

Variable Documentation

◆ _PSF_STAMP_SIGMAS

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

Definition at line 60 of file getTemplate.py.

◆ _UNKNOWN_INSTRUMENT

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

Definition at line 63 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 269 of file getTemplate.py.

◆ coaddExposures

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

Definition at line 1323 of file getTemplate.py.

◆ dataId

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

Definition at line 1295 of file getTemplate.py.

◆ dataIds

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

Definition at line 1292 of file getTemplate.py.

◆ default

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

Definition at line 275 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 1290 of file getTemplate.py.

◆ optional

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

Definition at line 274 of file getTemplate.py.

◆ output_image_type

lsst.ip.diffim.getTemplate.output_image_type

Definition at line 133 of file getTemplate.py.

◆ overlappingArea

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

Definition at line 1291 of file getTemplate.py.

◆ patchBBox

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

Definition at line 1298 of file getTemplate.py.

◆ patchCorners

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

Definition at line 1299 of file getTemplate.py.

◆ patchList

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

Definition at line 1293 of file getTemplate.py.

◆ patchPolygon

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

Definition at line 1300 of file getTemplate.py.

◆ patchWcs

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

Definition at line 1297 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 277 of file getTemplate.py.

◆ subfilter

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

Definition at line 1296 of file getTemplate.py.