@@ -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