LSST Applications g04a91732dc+146a938ab0,g07dc498a13+80b84b0d75,g0fba68d861+4c4f3dcb5c,g1409bbee79+80b84b0d75,g1a7e361dbc+80b84b0d75,g1fd858c14a+f6e422e056,g20f46db602+333b6c0f32,g35bb328faa+fcb1d3bbc8,g42c1b31a95+a1301e4c20,g4d2262a081+f1facf12e5,g4d39ba7253+9b833be27e,g4e0f332c67+5d362be553,g53246c7159+fcb1d3bbc8,g60b5630c4e+9b833be27e,g78460c75b0+2f9a1b4bcd,g786e29fd12+cf7ec2a62a,g7b71ed6315+fcb1d3bbc8,g8852436030+790117df0f,g89139ef638+80b84b0d75,g8d6b6b353c+9b833be27e,g9125e01d80+fcb1d3bbc8,g989de1cb63+80b84b0d75,g9f33ca652e+9c6b68d7f3,ga9baa6287d+9b833be27e,gaaedd4e678+80b84b0d75,gabe3b4be73+1e0a283bba,gb1101e3267+9f3571abad,gb58c049af0+f03b321e39,gb90eeb9370+691e4ab549,gc741bbaa4f+2bcd3860df,gcf25f946ba+790117df0f,gd315a588df+5b65d88fe4,gd6cbbdb0b4+c8606af20c,gd9a9a58781+fcb1d3bbc8,gde0f65d7ad+ee6a3faa19,ge278dab8ac+932305ba37,ge82c20c137+76d20ab76d,gee8db133a9+2a6ae0040b,w.2025.10
LSST Data Management Base Package
Loading...
Searching...
No Matches
lsst.pipe.tasks.coaddBase Namespace Reference

Classes

class  CoaddBaseConfig
 
class  CoaddBaseTask
 

Functions

 makeSkyInfo (skyMap, tractId, patchId)
 
 reorderAndPadList (inputList, inputKeys, outputKeys, padWith=None)
 
 subBBoxIter (bbox, subregionSize)
 
None growValidPolygons (coaddInputs, int growBy)
 
 removeMaskPlanes (afwImage.Mask mask, Iterable mask_planes, Logger|None logger=None)
 
list[tuple[int, int]] setRejectedMaskMapping (StatisticsControl statsCtrl)
 

Function Documentation

◆ growValidPolygons()

None lsst.pipe.tasks.coaddBase.growValidPolygons ( coaddInputs,
int growBy )
Grow coaddInputs' ccds' ValidPolygons in place.

Either modify each ccd's validPolygon in place, or if CoaddInputs
does not have a validPolygon, create one from its bbox.

Parameters
----------
coaddInputs : `lsst.afw.image.coaddInputs`
    CoaddInputs object containing the ccds to grow the valid polygons of.
growBy : `int`
    The value to grow the valid polygons by.

Notes
-----
Negative values for ``growBy`` can shrink the polygons.

Definition at line 244 of file coaddBase.py.

244def growValidPolygons(coaddInputs, growBy: int) -> None:
245 """Grow coaddInputs' ccds' ValidPolygons in place.
246
247 Either modify each ccd's validPolygon in place, or if CoaddInputs
248 does not have a validPolygon, create one from its bbox.
249
250 Parameters
251 ----------
252 coaddInputs : `lsst.afw.image.coaddInputs`
253 CoaddInputs object containing the ccds to grow the valid polygons of.
254 growBy : `int`
255 The value to grow the valid polygons by.
256
257 Notes
258 -----
259 Negative values for ``growBy`` can shrink the polygons.
260 """
261 for ccd in coaddInputs.ccds:
262 polyOrig = ccd.getValidPolygon()
263 validPolyBBox = polyOrig.getBBox() if polyOrig else ccd.getBBox()
264 validPolyBBox.grow(growBy)
265 if polyOrig:
266 validPolygon = polyOrig.intersectionSingle(validPolyBBox)
267 else:
268 validPolygon = Polygon(geom.Box2D(validPolyBBox))
269
270 ccd.validPolygon = validPolygon
271
272
A floating-point coordinate rectangle geometry.
Definition Box.h:413

◆ makeSkyInfo()

lsst.pipe.tasks.coaddBase.makeSkyInfo ( skyMap,
tractId,
patchId )
Constructs SkyInfo used by coaddition tasks for multiple
patchId formats.

Parameters
----------
skyMap : `lsst.skyMap.SkyMap`
    Sky map.
tractId : `int`
    The ID of the tract.
patchId : `str` or `int` or `tuple` of `int`
    Either Gen2-style comma delimited string (e.g. '4,5'),
    tuple of integers (e.g (4, 5), Gen3-style integer.

Returns
-------
makeSkyInfo : `lsst.pipe.base.Struct`
    pipe_base Struct with attributes:

    ``skyMap``
        Sky map (`lsst.skyMap.SkyMap`).
    ``tractInfo``
        Information for chosen tract of sky map (`lsst.skyMap.TractInfo`).
    ``patchInfo``
        Information about chosen patch of tract (`lsst.skyMap.PatchInfo`).
    ``wcs``
        WCS of tract (`lsst.afw.image.SkyWcs`).
    ``bbox``
        Outer bbox of patch, as an geom Box2I (`lsst.afw.geom.Box2I`).

Definition at line 121 of file coaddBase.py.

121def makeSkyInfo(skyMap, tractId, patchId):
122 """Constructs SkyInfo used by coaddition tasks for multiple
123 patchId formats.
124
125 Parameters
126 ----------
127 skyMap : `lsst.skyMap.SkyMap`
128 Sky map.
129 tractId : `int`
130 The ID of the tract.
131 patchId : `str` or `int` or `tuple` of `int`
132 Either Gen2-style comma delimited string (e.g. '4,5'),
133 tuple of integers (e.g (4, 5), Gen3-style integer.
134
135 Returns
136 -------
137 makeSkyInfo : `lsst.pipe.base.Struct`
138 pipe_base Struct with attributes:
139
140 ``skyMap``
141 Sky map (`lsst.skyMap.SkyMap`).
142 ``tractInfo``
143 Information for chosen tract of sky map (`lsst.skyMap.TractInfo`).
144 ``patchInfo``
145 Information about chosen patch of tract (`lsst.skyMap.PatchInfo`).
146 ``wcs``
147 WCS of tract (`lsst.afw.image.SkyWcs`).
148 ``bbox``
149 Outer bbox of patch, as an geom Box2I (`lsst.afw.geom.Box2I`).
150 """
151 tractInfo = skyMap[tractId]
152
153 if isinstance(patchId, str) and ',' in patchId:
154 # patch format is "xIndex,yIndex"
155 patchIndex = tuple(int(i) for i in patchId.split(","))
156 else:
157 patchIndex = patchId
158
159 patchInfo = tractInfo.getPatchInfo(patchIndex)
160
161 return pipeBase.Struct(
162 skyMap=skyMap,
163 tractInfo=tractInfo,
164 patchInfo=patchInfo,
165 wcs=tractInfo.getWcs(),
166 bbox=patchInfo.getOuterBBox(),
167 )
168
169

◆ removeMaskPlanes()

lsst.pipe.tasks.coaddBase.removeMaskPlanes ( afwImage.Mask mask,
Iterable mask_planes,
Logger | None logger = None )
Unset the mask of an image for mask planes specified in the config.

Parameters
----------
mask : `lsst.afw.image.Mask`
    The mask to be modified.
mask_planes : `list`
    The list of mask planes to be removed.
logger : `logging.Logger`, optional
    Logger to log messages.

Definition at line 273 of file coaddBase.py.

275):
276 """Unset the mask of an image for mask planes specified in the config.
277
278 Parameters
279 ----------
280 mask : `lsst.afw.image.Mask`
281 The mask to be modified.
282 mask_planes : `list`
283 The list of mask planes to be removed.
284 logger : `logging.Logger`, optional
285 Logger to log messages.
286 """
287 for maskPlane in mask_planes:
288 try:
289 mask &= ~mask.getPlaneBitMask(maskPlane)
290 except InvalidParameterError:
291 if logger:
292 logger.warning(
293 "Unable to remove mask plane %s: no mask plane with that name was found.",
294 maskPlane,
295 )
296
297

◆ reorderAndPadList()

lsst.pipe.tasks.coaddBase.reorderAndPadList ( inputList,
inputKeys,
outputKeys,
padWith = None )
Match the order of one list to another, padding if necessary

Parameters
----------
inputList : `list`
    List to be reordered and padded. Elements can be any type.
inputKeys :  `iterable`
    Iterable of values to be compared with outputKeys. Length must match `inputList`.
outputKeys : `iterable`
    Iterable of values to be compared with inputKeys.
padWith : `Unknown`
    Any value to be inserted where inputKey not in outputKeys.

Returns
-------
outputList : `list`
    Copy of inputList reordered per outputKeys and padded with `padWith`
    so that the length matches length of outputKeys.

Definition at line 170 of file coaddBase.py.

170def reorderAndPadList(inputList, inputKeys, outputKeys, padWith=None):
171 """Match the order of one list to another, padding if necessary
172
173 Parameters
174 ----------
175 inputList : `list`
176 List to be reordered and padded. Elements can be any type.
177 inputKeys : `iterable`
178 Iterable of values to be compared with outputKeys. Length must match `inputList`.
179 outputKeys : `iterable`
180 Iterable of values to be compared with inputKeys.
181 padWith : `Unknown`
182 Any value to be inserted where inputKey not in outputKeys.
183
184 Returns
185 -------
186 outputList : `list`
187 Copy of inputList reordered per outputKeys and padded with `padWith`
188 so that the length matches length of outputKeys.
189 """
190 outputList = []
191 for d in outputKeys:
192 if d in inputKeys:
193 outputList.append(inputList[inputKeys.index(d)])
194 else:
195 outputList.append(padWith)
196 return outputList
197
198

◆ setRejectedMaskMapping()

list[tuple[int, int]] lsst.pipe.tasks.coaddBase.setRejectedMaskMapping ( StatisticsControl statsCtrl)
Map certain mask planes of the warps to new planes for the coadd.

If a pixel is rejected due to a mask value other than EDGE, NO_DATA,
or CLIPPED, set it to REJECTED on the coadd.
If a pixel is rejected due to EDGE, set the coadd pixel to SENSOR_EDGE.
If a pixel is rejected due to CLIPPED, set the coadd pixel to CLIPPED.

Parameters
----------
statsCtrl : `lsst.afw.math.StatisticsControl`
    Statistics control object for coadd.

Returns
-------
maskMap : `list` of `tuple` of `int`
    A list of mappings of mask planes of the warped exposures to
    mask planes of the coadd.

Definition at line 298 of file coaddBase.py.

298def setRejectedMaskMapping(statsCtrl: StatisticsControl) -> list[tuple[int, int]]:
299 """Map certain mask planes of the warps to new planes for the coadd.
300
301 If a pixel is rejected due to a mask value other than EDGE, NO_DATA,
302 or CLIPPED, set it to REJECTED on the coadd.
303 If a pixel is rejected due to EDGE, set the coadd pixel to SENSOR_EDGE.
304 If a pixel is rejected due to CLIPPED, set the coadd pixel to CLIPPED.
305
306 Parameters
307 ----------
308 statsCtrl : `lsst.afw.math.StatisticsControl`
309 Statistics control object for coadd.
310
311 Returns
312 -------
313 maskMap : `list` of `tuple` of `int`
314 A list of mappings of mask planes of the warped exposures to
315 mask planes of the coadd.
316 """
317 edge = 2 ** afwImage.Mask.addMaskPlane("EDGE")
318 noData = 2 ** afwImage.Mask.addMaskPlane("NO_DATA")
319 clipped = 2 ** afwImage.Mask.addMaskPlane("CLIPPED")
320 toReject = statsCtrl.getAndMask() & (~noData) & (~edge) & (~clipped)
321 maskMap = [
322 (toReject, 2 ** afwImage.Mask.addMaskPlane("REJECTED")),
323 (edge, 2 ** afwImage.Mask.addMaskPlane("SENSOR_EDGE")),
324 (clipped, clipped),
325 ]
326 return maskMap

◆ subBBoxIter()

lsst.pipe.tasks.coaddBase.subBBoxIter ( bbox,
subregionSize )
Iterate over subregions of a bbox.

Parameters
----------
bbox : `lsst.geom.Box2I`
    Bounding box over which to iterate.
subregionSize : `lsst.geom.Extent2I`
    Size of sub-bboxes.

Yields
------
subBBox : `lsst.geom.Box2I`
    Next sub-bounding box of size ``subregionSize`` or smaller; each ``subBBox``
    is contained within ``bbox``, so it may be smaller than ``subregionSize`` at
    the edges of ``bbox``, but it will never be empty.

Raises
------
RuntimeError
    Raised if any of the following occur:
    - The given bbox is empty.
    - The subregionSize is 0.

Definition at line 199 of file coaddBase.py.

199def subBBoxIter(bbox, subregionSize):
200 """Iterate over subregions of a bbox.
201
202 Parameters
203 ----------
204 bbox : `lsst.geom.Box2I`
205 Bounding box over which to iterate.
206 subregionSize : `lsst.geom.Extent2I`
207 Size of sub-bboxes.
208
209 Yields
210 ------
211 subBBox : `lsst.geom.Box2I`
212 Next sub-bounding box of size ``subregionSize`` or smaller; each ``subBBox``
213 is contained within ``bbox``, so it may be smaller than ``subregionSize`` at
214 the edges of ``bbox``, but it will never be empty.
215
216 Raises
217 ------
218 RuntimeError
219 Raised if any of the following occur:
220 - The given bbox is empty.
221 - The subregionSize is 0.
222 """
223 if bbox.isEmpty():
224 raise RuntimeError("bbox %s is empty" % (bbox,))
225 if subregionSize[0] < 1 or subregionSize[1] < 1:
226 raise RuntimeError("subregionSize %s must be nonzero" % (subregionSize,))
227
228 for rowShift in range(0, bbox.getHeight(), subregionSize[1]):
229 for colShift in range(0, bbox.getWidth(), subregionSize[0]):
230 subBBox = geom.Box2I(bbox.getMin() + geom.Extent2I(colShift, rowShift), subregionSize)
231 subBBox.clip(bbox)
232 if subBBox.isEmpty():
233 raise RuntimeError("Bug: empty bbox! bbox=%s, subregionSize=%s, "
234 "colShift=%s, rowShift=%s" %
235 (bbox, subregionSize, colShift, rowShift))
236 yield subBBox
237
238
239# Note that this is implemented as a free-floating function to enable reuse in
240# lsst.pipe.tasks.makeWarp and in lsst.drp.tasks.make_psf_matched_warp
241# without creating any relationships between the two classes.
242# This may be converted to a method after makeWarp.py is removed altogether in
243# DM-47916.
An integer coordinate rectangle.
Definition Box.h:55