22__all__ = [
"CoaddBaseTask",
"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
140 self.makeSubtask(
"select")
141 self.makeSubtask(
"inputRecorder")
144 """Return warp name for given warpType and task config
149 Either 'direct' or 'psfMatched'.
153 WarpDatasetName : `str`
155 return self.config.coaddName +
"Coadd_" + warpType +
"Warp"
158 """Convenience method to provide the bitmask from the mask plane names
160 return afwImage.Mask.getPlaneBitMask(self.config.badMaskPlanes)
163def makeSkyInfo(skyMap, tractId, patchId):
164 """Constructs SkyInfo used by coaddition tasks for multiple
169 skyMap : `lsst.skyMap.SkyMap`
173 patchId : `str` or `int`
or `tuple` of `int`
174 Either Gen2-style comma delimited string (e.g.
'4,5'),
175 tuple of integers (e.g (4, 5), Gen3-style integer.
179 makeSkyInfo : `lsst.pipe.base.Struct`
180 pipe_base Struct
with attributes:
183 Sky map (`lsst.skyMap.SkyMap`).
185 Information
for chosen tract of sky map (`lsst.skyMap.TractInfo`).
187 Information about chosen patch of tract (`lsst.skyMap.PatchInfo`).
189 WCS of tract (`lsst.afw.image.SkyWcs`).
191 Outer bbox of patch,
as an geom Box2I (`lsst.afw.geom.Box2I`).
193 tractInfo = skyMap[tractId]
195 if isinstance(patchId, str)
and ',' in patchId:
197 patchIndex = tuple(int(i)
for i
in patchId.split(
","))
201 patchInfo = tractInfo.getPatchInfo(patchIndex)
203 return pipeBase.Struct(
207 wcs=tractInfo.getWcs(),
208 bbox=patchInfo.getOuterBBox(),
212def scaleVariance(maskedImage, maskPlanes, log=None):
213 """Scale the variance in a maskedImage
215 This is deprecated. Use the ScaleVarianceTask instead.
220 MaskedImage to operate on; variance will be scaled.
222 List of mask planes
for pixels to reject.
224 Log
for reporting the renormalization factor;
or None.
229 Renormalization factor.
233 The variance plane
in a convolved
or warped image (
or a coadd derived
234 from warped images) does
not accurately reflect the noise properties of
235 the image because variance has been lost to covariance. This function
236 attempts to correct
for this by scaling the variance plane to match
237 the observed variance
in the image. This
is not perfect (because we
're
238 not tracking the covariance) but it
's simple and is often good enough.
240 config = ScaleVarianceTask.ConfigClass()
241 config.maskPlanes = maskPlanes
242 task = ScaleVarianceTask(config=config, name="scaleVariance", log=log)
243 return task.run(maskedImage)
246def reorderAndPadList(inputList, inputKeys, outputKeys, padWith=None):
247 """Match the order of one list to another, padding if necessary
252 List to be reordered and padded. Elements can be any type.
253 inputKeys : `iterable`
254 Iterable of values to be compared
with outputKeys. Length must match `inputList`.
255 outputKeys : `iterable`
256 Iterable of values to be compared
with inputKeys.
258 Any value to be inserted where inputKey
not in outputKeys.
263 Copy of inputList reordered per outputKeys
and padded
with `padWith`
264 so that the length matches length of outputKeys.
269 outputList.append(inputList[inputKeys.index(d)])
271 outputList.append(padWith)
def getTempExpDatasetName(self, warpType="direct")
def __init__(self, **kwargs)
def getBadPixelMask(self)