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? Sets makePsfMatched=True, makeDirect=False",
61 deprecated=
"This field is no longer used. Will be removed after v26.",
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 deprecated=
"Deprecated in favor of the 'visitSummary' connection. Will be removed after v26.",
75 useGlobalExternalPhotoCalib = pexConfig.Field(
78 doc=(
"When using doApplyExternalPhotoCalib, use 'global' calibrations "
79 "that are not run per-tract. When False, use per-tract photometric "
80 "calibration files."),
82 deprecated=
"Deprecated in favor of the 'visitSummary' connection. Will be removed after v26.",
84 doApplyExternalSkyWcs = pexConfig.Field(
87 doc=(
"Whether to apply external astrometric calibration via an "
88 "`lsst.afw.geom.SkyWcs` object. Uses `externalSkyWcsName` "
89 "field to determine which calibration to load."),
91 deprecated=
"Deprecated in favor of the 'visitSummary' connection. Will be removed after v26.",
93 useGlobalExternalSkyWcs = pexConfig.Field(
96 doc=(
"When using doApplyExternalSkyWcs, use 'global' calibrations "
97 "that are not run per-tract. When False, use per-tract wcs "
100 deprecated=
"Deprecated in favor of the 'visitSummary' connection. Will be removed after v26.",
102 includeCalibVar = pexConfig.Field(
104 doc=
"Add photometric calibration variance to warp variance plane.",
107 matchingKernelSize = pexConfig.Field(
109 doc=
"Size in pixels of matching kernel. Must be odd.",
111 check=
lambda x: x % 2 == 1
116 """Base class for coaddition.
118 Subclasses must specify _DefaultName
121 ConfigClass = CoaddBaseConfig
123 def __init__(self, **kwargs):
124 super().__init__(**kwargs)
125 self.makeSubtask(
"select")
126 self.makeSubtask(
"inputRecorder")
129 """Return warp name for given warpType and task config
134 Either 'direct' or 'psfMatched'.
138 WarpDatasetName : `str`
140 return self.config.coaddName +
"Coadd_" + warpType +
"Warp"
143 """Convenience method to provide the bitmask from the mask plane names
145 return afwImage.Mask.getPlaneBitMask(self.config.badMaskPlanes)
148def makeSkyInfo(skyMap, tractId, patchId):
149 """Constructs SkyInfo used by coaddition tasks for multiple
154 skyMap : `lsst.skyMap.SkyMap`
158 patchId : `str` or `int`
or `tuple` of `int`
159 Either Gen2-style comma delimited string (e.g.
'4,5'),
160 tuple of integers (e.g (4, 5), Gen3-style integer.
164 makeSkyInfo : `lsst.pipe.base.Struct`
165 pipe_base Struct
with attributes:
168 Sky map (`lsst.skyMap.SkyMap`).
170 Information
for chosen tract of sky map (`lsst.skyMap.TractInfo`).
172 Information about chosen patch of tract (`lsst.skyMap.PatchInfo`).
174 WCS of tract (`lsst.afw.image.SkyWcs`).
176 Outer bbox of patch,
as an geom Box2I (`lsst.afw.geom.Box2I`).
178 tractInfo = skyMap[tractId]
180 if isinstance(patchId, str)
and ',' in patchId:
182 patchIndex = tuple(int(i)
for i
in patchId.split(
","))
186 patchInfo = tractInfo.getPatchInfo(patchIndex)
188 return pipeBase.Struct(
192 wcs=tractInfo.getWcs(),
193 bbox=patchInfo.getOuterBBox(),
197def scaleVariance(maskedImage, maskPlanes, log=None):
198 """Scale the variance in a maskedImage
200 This is deprecated. Use the ScaleVarianceTask instead.
205 MaskedImage to operate on; variance will be scaled.
207 List of mask planes
for pixels to reject.
209 Log
for reporting the renormalization factor;
or None.
214 Renormalization factor.
218 The variance plane
in a convolved
or warped image (
or a coadd derived
219 from warped images) does
not accurately reflect the noise properties of
220 the image because variance has been lost to covariance. This function
221 attempts to correct
for this by scaling the variance plane to match
222 the observed variance
in the image. This
is not perfect (because we
're
223 not tracking the covariance) but it
's simple and is often good enough.
225 config = ScaleVarianceTask.ConfigClass()
226 config.maskPlanes = maskPlanes
228 return task.run(maskedImage)
231def reorderAndPadList(inputList, inputKeys, outputKeys, padWith=None):
232 """Match the order of one list to another, padding if necessary
237 List to be reordered and padded. Elements can be any type.
238 inputKeys : `iterable`
239 Iterable of values to be compared
with outputKeys. Length must match `inputList`.
240 outputKeys : `iterable`
241 Iterable of values to be compared
with inputKeys.
243 Any value to be inserted where inputKey
not in outputKeys.
248 Copy of inputList reordered per outputKeys
and padded
with `padWith`
249 so that the length matches length of outputKeys.
254 outputList.append(inputList[inputKeys.index(d)])
256 outputList.append(padWith)
A class to manipulate images, masks, and variance as a single object.
getTempExpDatasetName(self, warpType="direct")