22__all__ = [
"CoaddBaseTask",
"makeSkyInfo"]
26import lsst.pipe.base
as pipeBase
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? Sets makePsfMatched=True, makeDirect=False",
61 deprecated=
"This field is no longer used. Will be removed after v27.",
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
137 ConfigClass = CoaddBaseConfig
141 self.makeSubtask(
"select")
142 self.makeSubtask(
"inputRecorder")
145 """Return warp name for given warpType and task config
150 Either 'direct' or 'psfMatched'.
154 WarpDatasetName : `str`
156 return self.config.coaddName +
"Coadd_" + warpType +
"Warp"
159 """Convenience method to provide the bitmask from the mask plane names
161 return afwImage.Mask.getPlaneBitMask(self.config.badMaskPlanes)
164def makeSkyInfo(skyMap, tractId, patchId):
165 """Constructs SkyInfo used by coaddition tasks for multiple
170 skyMap : `lsst.skyMap.SkyMap`
174 patchId : `str` or `int`
or `tuple` of `int`
175 Either Gen2-style comma delimited string (e.g.
'4,5'),
176 tuple of integers (e.g (4, 5), Gen3-style integer.
180 makeSkyInfo : `lsst.pipe.base.Struct`
181 pipe_base Struct
with attributes:
184 Sky map (`lsst.skyMap.SkyMap`).
186 Information
for chosen tract of sky map (`lsst.skyMap.TractInfo`).
188 Information about chosen patch of tract (`lsst.skyMap.PatchInfo`).
190 WCS of tract (`lsst.afw.image.SkyWcs`).
192 Outer bbox of patch,
as an geom Box2I (`lsst.afw.geom.Box2I`).
194 tractInfo = skyMap[tractId]
196 if isinstance(patchId, str)
and ',' in patchId:
198 patchIndex = tuple(int(i)
for i
in patchId.split(
","))
202 patchInfo = tractInfo.getPatchInfo(patchIndex)
204 return pipeBase.Struct(
208 wcs=tractInfo.getWcs(),
209 bbox=patchInfo.getOuterBBox(),
213def scaleVariance(maskedImage, maskPlanes, log=None):
214 """Scale the variance in a maskedImage
216 This is deprecated. Use the ScaleVarianceTask instead.
221 MaskedImage to operate on; variance will be scaled.
223 List of mask planes
for pixels to reject.
225 Log
for reporting the renormalization factor;
or None.
230 Renormalization factor.
234 The variance plane
in a convolved
or warped image (
or a coadd derived
235 from warped images) does
not accurately reflect the noise properties of
236 the image because variance has been lost to covariance. This function
237 attempts to correct
for this by scaling the variance plane to match
238 the observed variance
in the image. This
is not perfect (because we
're
239 not tracking the covariance) but it
's simple and is often good enough.
241 config = ScaleVarianceTask.ConfigClass()
242 config.maskPlanes = maskPlanes
243 task = ScaleVarianceTask(config=config, name="scaleVariance", log=log)
244 return task.run(maskedImage)
247def reorderAndPadList(inputList, inputKeys, outputKeys, padWith=None):
248 """Match the order of one list to another, padding if necessary
253 List to be reordered and padded. Elements can be any type.
254 inputKeys : `iterable`
255 Iterable of values to be compared
with outputKeys. Length must match `inputList`.
256 outputKeys : `iterable`
257 Iterable of values to be compared
with inputKeys.
259 Any value to be inserted where inputKey
not in outputKeys.
264 Copy of inputList reordered per outputKeys
and padded
with `padWith`
265 so that the length matches length of outputKeys.
270 outputList.append(inputList[inputKeys.index(d)])
272 outputList.append(padWith)
def getTempExpDatasetName(self, warpType="direct")
def __init__(self, **kwargs)
def getBadPixelMask(self)