28from .selectImages
import PsfWcsSelectImagesTask
29from .coaddInputRecorder
import CoaddInputRecorderTask
31__all__ = [
"CoaddBaseTask",
"getSkyInfo",
"makeSkyInfo"]
35 """!Configuration parameters for CoaddBaseTask
37 @anchor CoaddBaseConfig_
39 @brief Configuration parameters shared between MakeCoaddTempExp
and AssembleCoadd
41 coaddName = pexConfig.Field(
42 doc="Coadd name: typically one of deep or goodSeeing.",
46 select = pexConfig.ConfigurableField(
47 doc=
"Image selection subtask.",
48 target=PsfWcsSelectImagesTask,
50 badMaskPlanes = pexConfig.ListField(
52 doc=
"Mask planes that, if set, the associated pixel should not be included in the coaddTempExp.",
55 inputRecorder = pexConfig.ConfigurableField(
56 doc=
"Subtask that helps fill CoaddInputs catalogs added to the final Exposure",
57 target=CoaddInputRecorderTask
59 doPsfMatch = pexConfig.Field(
61 doc=
"Match to modelPsf? Deprecated. Sets makePsfMatched=True, makeDirect=False",
64 modelPsf = measAlg.GaussianPsfFactory.makeField(doc=
"Model Psf factory")
65 doApplyExternalPhotoCalib = pexConfig.Field(
68 doc=(
"Whether to apply external photometric calibration via an "
69 "`lsst.afw.image.PhotoCalib` object. Uses the "
70 "`externalPhotoCalibName` field to determine which calibration "
73 useGlobalExternalPhotoCalib = pexConfig.Field(
76 doc=(
"When using doApplyExternalPhotoCalib, use 'global' calibrations "
77 "that are not run per-tract. When False, use per-tract photometric "
80 externalPhotoCalibName = pexConfig.ChoiceField(
83 doc=(
"Type of external PhotoCalib if `doApplyExternalPhotoCalib` is True. "
84 "This field is only used for Gen2 middleware."),
87 "jointcal":
"Use jointcal_photoCalib",
88 "fgcm":
"Use fgcm_photoCalib",
89 "fgcm_tract":
"Use fgcm_tract_photoCalib"
91 deprecated=
"This configuration is no longer used, and will be removed after v25.0",
93 doApplyExternalSkyWcs = pexConfig.Field(
96 doc=(
"Whether to apply external astrometric calibration via an "
97 "`lsst.afw.geom.SkyWcs` object. Uses `externalSkyWcsName` "
98 "field to determine which calibration to load.")
100 useGlobalExternalSkyWcs = pexConfig.Field(
103 doc=(
"When using doApplyExternalSkyWcs, use 'global' calibrations "
104 "that are not run per-tract. When False, use per-tract wcs "
107 externalSkyWcsName = pexConfig.ChoiceField(
110 doc=(
"Type of external SkyWcs if `doApplyExternalSkyWcs` is True. "
111 "This field is only used for Gen2 middleware."),
114 "jointcal":
"Use jointcal_wcs"
116 deprecated=
"This configuration is no longer used, and will be removed after v25.0",
118 includeCalibVar = pexConfig.Field(
120 doc=
"Add photometric calibration variance to warp variance plane.",
123 matchingKernelSize = pexConfig.Field(
125 doc=
"Size in pixels of matching kernel. Must be odd.",
127 check=
lambda x: x % 2 == 1
132 """!Base class for coaddition.
134 Subclasses must specify _DefaultName
136 ConfigClass = CoaddBaseConfig
140 self.makeSubtask(
"select")
141 self.makeSubtask(
"inputRecorder")
145 @brief Use
@ref coaddBase::getSkyInfo
"getSkyInfo" to
return the skyMap,
146 tract
and patch information, wcs
and the outer bbox
149 @param[
in] patchRef data reference
for sky map. Must include keys
"tract" and "patch"
151 @return pipe_base Struct containing:
153 - tractInfo: information
for chosen tract of sky map
154 - patchInfo: information about chosen patch of tract
156 - bbox: outer bbox of patch,
as an geom Box2I
158 return getSkyInfo(coaddName=self.config.coaddName, patchRef=patchRef)
161 """Return warp name for given warpType and task config
166 Either 'direct' or 'psfMatched'
170 WarpDatasetName : `string`
172 return self.config.coaddName +
"Coadd_" + warpType +
"Warp"
176 @brief Convenience method to provide the bitmask
from the mask plane names
178 return afwImage.Mask.getPlaneBitMask(self.config.badMaskPlanes)
183 @brief Return the SkyMap, tract
and patch information, wcs,
and outer bbox of the patch to be coadded.
185 @param[
in] coaddName coadd name; typically one of deep
or goodSeeing
186 @param[
in] patchRef data reference
for sky map. Must include keys
"tract" and "patch"
188 @return pipe_base Struct containing:
190 - tractInfo: information
for chosen tract of sky map
191 - patchInfo: information about chosen patch of tract
193 - bbox: outer bbox of patch,
as an geom Box2I
195 skyMap = patchRef.get(coaddName + "Coadd_skyMap")
196 return makeSkyInfo(skyMap, patchRef.dataId[
"tract"], patchRef.dataId[
"patch"])
199def makeSkyInfo(skyMap, tractId, patchId):
200 """Return SkyInfo Struct
202 Constructs SkyInfo used by coaddition tasks for multiple
207 skyMap : `lsst.skyMap.SkyMap`
209 patchId : str
or int
or tuple of int
210 Either Gen2-style comma delimited string (e.g.
'4,5'),
211 tuple of integers (e.g (4, 5), Gen3-style integer.
213 tractInfo = skyMap[tractId]
215 if isinstance(patchId, str)
and ',' in patchId:
217 patchIndex = tuple(int(i)
for i
in patchId.split(
","))
221 patchInfo = tractInfo.getPatchInfo(patchIndex)
223 return pipeBase.Struct(
227 wcs=tractInfo.getWcs(),
228 bbox=patchInfo.getOuterBBox(),
232def scaleVariance(maskedImage, maskPlanes, log=None):
234 @brief Scale the variance
in a maskedImage
236 The variance plane
in a convolved
or warped image (
or a coadd derived
237 from warped images) does
not accurately reflect the noise properties of
238 the image because variance has been lost to covariance. This function
239 attempts to correct
for this by scaling the variance plane to match
240 the observed variance
in the image. This
is not perfect (because we
're
241 not tracking the covariance) but it
's simple and is often good enough.
243 @deprecated Use the ScaleVarianceTask instead.
245 @param maskedImage MaskedImage to operate on; variance will be scaled
246 @param maskPlanes List of mask planes
for pixels to reject
247 @param log Log
for reporting the renormalization factor;
or None
248 @return renormalisation factor
250 config = ScaleVarianceTask.ConfigClass()
251 config.maskPlanes = maskPlanes
252 task = ScaleVarianceTask(config=config, name="scaleVariance", log=log)
253 return task.run(maskedImage)
256def reorderAndPadList(inputList, inputKeys, outputKeys, padWith=None):
257 """Match the order of one list to another, padding if necessary
262 List to be reordered and padded. Elements can be any type.
264 Iterable of values to be compared
with outputKeys.
265 Length must match `inputList`
266 outputKeys : iterable
267 Iterable of values to be compared
with inputKeys.
269 Any value to be inserted where inputKey
not in outputKeys
274 Copy of inputList reordered per outputKeys
and padded
with `padWith`
275 so that the length matches length of outputKeys.
280 outputList.append(inputList[inputKeys.index(d)])
282 outputList.append(padWith)
Configuration parameters for CoaddBaseTask.
Base class for coaddition.
def getTempExpDatasetName(self, warpType="direct")
def __init__(self, **kwargs)
def getSkyInfo(self, patchRef)
Use getSkyInfo to return the skyMap, tract and patch information, wcs and the outer bbox of the patch...
def getBadPixelMask(self)
Convenience method to provide the bitmask from the mask plane names.
def getSkyInfo(coaddName, patchRef)
Return the SkyMap, tract and patch information, wcs, and outer bbox of the patch to be coadded.