22__all__ = [
"CoaddBaseTask",
"getSkyInfo",
"makeSkyInfo"]
30from .selectImages
import PsfWcsSelectImagesTask
31from .coaddInputRecorder
import CoaddInputRecorderTask
35 """Configuration parameters for CoaddBaseTask
37 Configuration parameters shared between MakeCoaddTempExp and AssembleCoadd
40 coaddName = pexConfig.Field(
41 doc="Coadd name: typically one of deep or goodSeeing.",
45 select = pexConfig.ConfigurableField(
46 doc=
"Image selection subtask.",
47 target=PsfWcsSelectImagesTask,
49 badMaskPlanes = pexConfig.ListField(
51 doc=
"Mask planes that, if set, the associated pixel should not be included in the coaddTempExp.",
54 inputRecorder = pexConfig.ConfigurableField(
55 doc=
"Subtask that helps fill CoaddInputs catalogs added to the final Exposure",
56 target=CoaddInputRecorderTask
58 doPsfMatch = pexConfig.Field(
60 doc=
"Match to modelPsf? Deprecated. Sets makePsfMatched=True, makeDirect=False",
63 modelPsf = measAlg.GaussianPsfFactory.makeField(doc=
"Model Psf factory")
64 doApplyExternalPhotoCalib = pexConfig.Field(
67 doc=(
"Whether to apply external photometric calibration via an "
68 "`lsst.afw.image.PhotoCalib` object. Uses the "
69 "`externalPhotoCalibName` field to determine which calibration "
72 useGlobalExternalPhotoCalib = pexConfig.Field(
75 doc=(
"When using doApplyExternalPhotoCalib, use 'global' calibrations "
76 "that are not run per-tract. When False, use per-tract photometric "
79 externalPhotoCalibName = pexConfig.ChoiceField(
82 doc=(
"Type of external PhotoCalib if `doApplyExternalPhotoCalib` is True. "
83 "This field is only used for Gen2 middleware."),
86 "jointcal":
"Use jointcal_photoCalib",
87 "fgcm":
"Use fgcm_photoCalib",
88 "fgcm_tract":
"Use fgcm_tract_photoCalib"
90 deprecated=
"This configuration is no longer used, and will be removed after v25.0",
92 doApplyExternalSkyWcs = pexConfig.Field(
95 doc=(
"Whether to apply external astrometric calibration via an "
96 "`lsst.afw.geom.SkyWcs` object. Uses `externalSkyWcsName` "
97 "field to determine which calibration to load.")
99 useGlobalExternalSkyWcs = pexConfig.Field(
102 doc=(
"When using doApplyExternalSkyWcs, use 'global' calibrations "
103 "that are not run per-tract. When False, use per-tract wcs "
106 externalSkyWcsName = pexConfig.ChoiceField(
109 doc=(
"Type of external SkyWcs if `doApplyExternalSkyWcs` is True. "
110 "This field is only used for Gen2 middleware."),
113 "jointcal":
"Use jointcal_wcs"
115 deprecated=
"This configuration is no longer used, and will be removed after v25.0",
117 includeCalibVar = pexConfig.Field(
119 doc=
"Add photometric calibration variance to warp variance plane.",
122 matchingKernelSize = pexConfig.Field(
124 doc=
"Size in pixels of matching kernel. Must be odd.",
126 check=
lambda x: x % 2 == 1
131 """Base class for coaddition.
133 Subclasses must specify _DefaultName
136 ConfigClass = CoaddBaseConfig
138 def __init__(self, **kwargs):
139 super().__init__(**kwargs)
140 self.makeSubtask(
"select")
141 self.makeSubtask(
"inputRecorder")
144 """Use getSkyinfo to return the skyMap, tract and patch information, wcs and the outer bbox
150 Data reference for sky map. Must include keys
"tract" and "patch".
154 getSkyInfo : `lsst.pipe.base.Struct`
155 Sky Info
as a struct
with attributes:
158 sky map (`lsst.skyMap.SkyMap`).
164 WCS of tract (`lsst.afw.image.SkyWcs`).
166 Outer bbox of patch,
as an geom Box2I (`lsst.afw.geom.Box2I`).
168 return getSkyInfo(coaddName=self.config.coaddName, patchRef=patchRef)
171 """Return warp name for given warpType and task config
176 Either 'direct' or 'psfMatched'.
180 WarpDatasetName : `str`
182 return self.config.coaddName +
"Coadd_" + warpType +
"Warp"
185 """Convenience method to provide the bitmask from the mask plane names
187 return afwImage.Mask.getPlaneBitMask(self.config.badMaskPlanes)
191 """Return the SkyMap, tract and patch information, wcs, and outer bbox of the patch to be coadded.
196 Coadd name; typically one of deep or goodSeeing.
198 Data reference
for sky map. Must include keys
"tract" and "patch".
202 makeSkyInfo : `lsst.pipe.base.Struct`
203 pipe_base Struct
with attributes:
206 Sky map (`lsst.skyMap.SkyMap`).
208 Information
for chosen tract of sky map (`lsst.skyMap.TractInfo`).
210 Information about chosen patch of tract (`lsst.skyMap.PatchInfo`).
212 WCS of tract (`lsst.afw.image.SkyWcs`).
214 Outer bbox of patch,
as an geom Box2I (`lsst.afw.geom.Box2I`).
216 skyMap = patchRef.get(coaddName + "Coadd_skyMap")
217 return makeSkyInfo(skyMap, patchRef.dataId[
"tract"], patchRef.dataId[
"patch"])
220def makeSkyInfo(skyMap, tractId, patchId):
221 """Constructs SkyInfo used by coaddition tasks for multiple
226 skyMap : `lsst.skyMap.SkyMap`
230 patchId : `str` or `int`
or `tuple` of `int`
231 Either Gen2-style comma delimited string (e.g.
'4,5'),
232 tuple of integers (e.g (4, 5), Gen3-style integer.
236 makeSkyInfo : `lsst.pipe.base.Struct`
237 pipe_base Struct
with attributes:
240 Sky map (`lsst.skyMap.SkyMap`).
242 Information
for chosen tract of sky map (`lsst.skyMap.TractInfo`).
244 Information about chosen patch of tract (`lsst.skyMap.PatchInfo`).
246 WCS of tract (`lsst.afw.image.SkyWcs`).
248 Outer bbox of patch,
as an geom Box2I (`lsst.afw.geom.Box2I`).
250 tractInfo = skyMap[tractId]
252 if isinstance(patchId, str)
and ',' in patchId:
254 patchIndex = tuple(int(i)
for i
in patchId.split(
","))
258 patchInfo = tractInfo.getPatchInfo(patchIndex)
260 return pipeBase.Struct(
264 wcs=tractInfo.getWcs(),
265 bbox=patchInfo.getOuterBBox(),
269def scaleVariance(maskedImage, maskPlanes, log=None):
270 """Scale the variance in a maskedImage
272 This is deprecated. Use the ScaleVarianceTask instead.
277 MaskedImage to operate on; variance will be scaled.
279 List of mask planes
for pixels to reject.
281 Log
for reporting the renormalization factor;
or None.
286 Renormalization factor.
290 The variance plane
in a convolved
or warped image (
or a coadd derived
291 from warped images) does
not accurately reflect the noise properties of
292 the image because variance has been lost to covariance. This function
293 attempts to correct
for this by scaling the variance plane to match
294 the observed variance
in the image. This
is not perfect (because we
're
295 not tracking the covariance) but it
's simple and is often good enough.
297 config = ScaleVarianceTask.ConfigClass()
298 config.maskPlanes = maskPlanes
300 return task.run(maskedImage)
303def reorderAndPadList(inputList, inputKeys, outputKeys, padWith=None):
304 """Match the order of one list to another, padding if necessary
309 List to be reordered and padded. Elements can be any type.
310 inputKeys : `iterable`
311 Iterable of values to be compared
with outputKeys. Length must match `inputList`.
312 outputKeys : `iterable`
313 Iterable of values to be compared
with inputKeys.
315 Any value to be inserted where inputKey
not in outputKeys.
320 Copy of inputList reordered per outputKeys
and padded
with `padWith`
321 so that the length matches length of outputKeys.
326 outputList.append(inputList[inputKeys.index(d)])
328 outputList.append(padWith)
A class to manipulate images, masks, and variance as a single object.
def getTempExpDatasetName(self, warpType="direct")
def getSkyInfo(self, patchRef)
def getBadPixelMask(self)
def getSkyInfo(coaddName, patchRef)