GetTemplateTask#
- class lsst.ip.diffim.GetTemplateTask(*args, **kwargs)#
Bases:
PipelineTaskMethods Summary
checkHighVariance(template)Set a mask plane for regions with unusually high variance.
convert_outputs_to_future(template, ...)Convert a template image to DifferenceImage format.
getExposures(coaddExposureHandles, bbox, ...)Return a data structure containing the coadds that overlap the specified bbox projected onto the sky, and a corresponding data structure of their dataIds.
run(*, coaddExposureHandles, bbox, wcs, ...)Warp coadds from multiple tracts and patches to form a template to subtract from a science image.
runQuantum(butlerQC, inputRefs, outputRefs)Do butler IO and transform to provide in memory objects for tasks
runmethod.Methods Documentation
- checkHighVariance(template)#
Set a mask plane for regions with unusually high variance.
Parameters#
- template
lsst.afw.image.Exposure The warped template exposure, which will be modified in place.
- template
- convert_outputs_to_future(template, coadd_refs, detector, exposureRecord)#
Convert a template image to DifferenceImage format.
This replaces
templatewith anlsst.images.DifferenceImageinstance and records the coadds contributed to it, along with the instrument they were made from. The Gaussian PSF set byrunis converted to anlsst.images.psfs.GaussianPointSpreadFunction.Parameters#
- template
lsst.afw.image.Exposure Template to convert. Its detector is replaced with
detectorand its mask is modified in place.- coadd_refs
list[lsst.daf.butler.DatasetRef] References to the coadds that may have gone into the template. May be a superset of the coadds that were used; supplies the dataset id and RUN collection recorded for each coadd that was.
- detector
lsst.afw.cameraGeom.Detector Detector of the science image that the template was built for.
- exposureRecord
lsst.daf.butler.DimensionRecord The
exposurerecord of the observation the template was built for, which supplies the observation metadata recorded on the output.
Returns#
- convertedTemplate
lsst.images.DifferenceImage The converted image.
Raises#
- RuntimeError
Raised if the template has pixels set in a mask plane that
lsst.images.get_legacy_template_mask_planesdoes not map andconfig.raiseOnUndefinedMaskMapis True, or ifcoadd_refsspans more than one skymap.
- template
- getExposures(coaddExposureHandles, bbox, skymap, wcs)#
Return a data structure containing the coadds that overlap the specified bbox projected onto the sky, and a corresponding data structure of their dataIds. These are the appropriate inputs to this task’s
runmethod.The spatial index in the butler registry has generous padding and often supplies patches near, but not directly overlapping the desired region. This method filters the inputs so that
rundoes not have to read in all possibly-matching coadd exposures.Parameters#
- coaddExposureHandles
iterable[lsst.daf.butler.DeferredDatasetHandleoflsst.afw.image.Exposure] Dataset handles to exposures that might overlap the desired region.
- bbox
lsst.geom.Box2I Template bounding box of the pixel geometry onto which the coaddExposures will be resampled.
- skymap
lsst.skymap.SkyMap Geometry of the tracts and patches the coadds are defined on.
- wcs
lsst.afw.geom.SkyWcs Template WCS onto which the coadds will be resampled.
Returns#
- result
lsst.pipe.base.Struct A struct with attributes:
coaddExposuresDict of coadd exposures that overlap the projected bbox, indexed on tract id (
dict[int,list[lsst.daf.butler.DeferredDatasetHandleoflsst.afw.image.Exposure] ]).dataIdsDict of data IDs of the coadd exposures that overlap the projected bbox, indexed on tract id (
dict[int,list [`lsst.daf.butler.DataCoordinate] ]).
Raises#
- NoWorkFound
Raised if no patches overlap the input detector bbox, or the input WCS is None.
- coaddExposureHandles
- run(*, coaddExposureHandles, bbox, wcs, dataIds, physical_filter, visit=None, instrument=None)#
Warp coadds from multiple tracts and patches to form a template to subtract from a science image.
Tract and patch overlap regions are combined by a variance-weighted average, and the variance planes are combined with the same weights, not added in quadrature; the overlap regions are not statistically independent, because they’re derived from the same original data. The PSF of the template is a Gaussian with the same width as the CoaddPsf evaluated at the center of the detector.
The template is built from coadds of one instrument: the science image’s
instrumentif any coadd was made from it, and otherwise the one that most of the coadds were made from. Coadds made from another instrument are dropped, and so are coadds that record no instrument unless none of the coadds records one.Parameters#
- coaddExposureHandles
dict[int,listof [lsst.daf.butler.DeferredDatasetHandleoflsst.afw.image.Exposure]] Coadds to be mosaicked, indexed on tract id.
- bbox
lsst.geom.Box2I Input Bounding box of the detector geometry onto which to resample the
coaddExposureHandles. The output template bbox will be grown bytemplateBorderSize.- wcs
lsst.afw.geom.SkyWcs Template WCS onto which to resample the
coaddExposureHandles.- dataIds
dict[int,list[lsst.daf.butler.DataCoordinate]] Record of the tract and patch of each coaddExposure, indexed on tract id.
- physical_filter
str Physical filter of the science image.
- visit
int, optional If supplied, over-write the visit ID in the template’s visitInfo so that downstream source injection tasks can link the template and science image for the visit.
- instrument
str, optional Instrument of the science image. Coadds made from it are used in preference to coadds from any other instrument.
Returns#
- result
lsst.pipe.base.Struct A struct with attributes:
templateA template coadd exposure assembled out of patches, with pixels in nJy. Its PSF is a Gaussian approximation to the CoaddPsf of its inputs (
lsst.afw.image.ExposureF).
Raises#
- NoWorkFound
If no coadds are found with sufficient un-masked pixels.
- RuntimeError
If the template is not known to be from the science image’s instrument and no coadd records the plate scale of its input images, so the template variance cannot be corrected.
- coaddExposureHandles
- runQuantum(butlerQC, inputRefs, outputRefs)#
Do butler IO and transform to provide in memory objects for tasks
runmethod.Parameters#
- butlerQC
QuantumContext A butler which is specialized to operate in the context of a
lsst.daf.butler.Quantum.- inputRefs
InputQuantizedConnection Datastructure whose attribute names are the names that identify connections defined in corresponding
PipelineTaskConnectionsclass. The values of these attributes are thelsst.daf.butler.DatasetRefobjects associated with the defined input/prerequisite connections.- outputRefs
OutputQuantizedConnection Datastructure whose attribute names are the names that identify connections defined in corresponding
PipelineTaskConnectionsclass. The values of these attributes are thelsst.daf.butler.DatasetRefobjects associated with the defined output connections.
- butlerQC