Skip to content

Commit 3759b03

Browse files
committed
Check for invalid pixels in coadd
1 parent 6f0c297 commit 3759b03

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

python/lsst/ip/diffim/getTemplate.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,9 @@ def getOverlappingExposures(self, inputs):
197197
if patchPolygon.intersection(detectorPolygon):
198198
overlappingArea += patchPolygon.intersectionSingle(detectorPolygon).calculateArea()
199199
self.log.info("Using template input tract=%s, patch=%s", dataId['tract'], dataId['patch'])
200-
coaddExposures[dataId['tract']].append(coaddRef.get())
200+
coaddPatch = coaddRef.get()
201+
self.checkPatch(coaddPatch, dataId)
202+
coaddExposures[dataId['tract']].append(coaddPatch)
201203
dataIds[dataId['tract']].append(dataId)
202204

203205
if not overlappingArea:
@@ -206,6 +208,34 @@ def getOverlappingExposures(self, inputs):
206208
return pipeBase.Struct(coaddExposures=coaddExposures,
207209
dataIds=dataIds)
208210

211+
def checkPatch(self, coaddPatch, dataId):
212+
"""Check for invalid pixels in the coadd and raise warning if value is
213+
non-zero.
214+
215+
Parameters
216+
----------
217+
coaddPatch: `dict` [`int`, `list` [`lsst.afw.image.Exposure`]]
218+
Coadd to be mosaicked, indexed on tract id.
219+
dataId: `dict` [`int`, `list` [`lsst.daf.butler.DataCoordinate`]]
220+
Record of the tract and patch of coaddPatch, indexed on
221+
tract id.
222+
223+
Raises
224+
------
225+
Warning
226+
If invalid pixels are found in the coadd.
227+
"""
228+
bad = np.logical_not(np.isfinite(coaddPatch.image.array))
229+
y, x = np.nonzero(bad)
230+
badN = len(np.nonzero(bad)[0])
231+
if badN > 0:
232+
self.log.warning(
233+
"%s invalid pixels in coadd using input tract=%s, patch=%s",
234+
badN,
235+
dataId["tract"],
236+
dataId["patch"],
237+
)
238+
209239
@timeMethod
210240
def run(self, coaddExposures, bbox, wcs, dataIds, physical_filter):
211241
"""Warp coadds from multiple tracts and patches to form a template to

0 commit comments

Comments
 (0)