From 20b1d5c07529b1782530ad091845bac150c00ed6 Mon Sep 17 00:00:00 2001 From: Yusra AlSayyad Date: Tue, 7 Oct 2025 07:26:34 -0700 Subject: [PATCH 1/3] Avoid divide by zero --- python/lsst/drp/tasks/assemble_coadd.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/python/lsst/drp/tasks/assemble_coadd.py b/python/lsst/drp/tasks/assemble_coadd.py index 491ce0f1..b123181c 100644 --- a/python/lsst/drp/tasks/assemble_coadd.py +++ b/python/lsst/drp/tasks/assemble_coadd.py @@ -614,11 +614,12 @@ def prepareInputs(self, refList, coadd_bbox, psfMatchedWarpRefList=None): maskedImage.getVariance(), maskedImage.getMask(), afwMath.MEANCLIP, statsCtrl ) meanVar, meanVarErr = statObj.getResult(afwMath.MEANCLIP) - weight = 1.0 / float(meanVar) - if not numpy.isfinite(weight): + if meanVar > 0.0 and numpy.isfinite(meanVar): + weight = 1.0 / float(meanVar) + self.log.info("Weight of %s %s = %0.3f", warpName, warpRef.dataId, weight) + else: self.log.warning("Non-finite weight for %s: skipping", warpRef.dataId) continue - self.log.info("Weight of %s %s = %0.3f", warpName, warpRef.dataId, weight) del maskedImage del warp From 7ed1645d4eae1f85fbbdf39ac21eef02d990adb3 Mon Sep 17 00:00:00 2001 From: Yusra AlSayyad Date: Tue, 7 Oct 2025 08:57:34 -0700 Subject: [PATCH 2/3] Add inline comment clarifying behavior of how warps with missing psf-matched warps are excluded in CompareWarp --- python/lsst/drp/tasks/assemble_coadd.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/python/lsst/drp/tasks/assemble_coadd.py b/python/lsst/drp/tasks/assemble_coadd.py index b123181c..88fa0752 100644 --- a/python/lsst/drp/tasks/assemble_coadd.py +++ b/python/lsst/drp/tasks/assemble_coadd.py @@ -1650,6 +1650,11 @@ def run( # Check and match the order of the supplementaryData # (PSF-matched) inputs to the order of the direct inputs, # so that the artifact mask is applied to the right warp + + # For any missing psfMatched warp refs replaced with None, + # findArtifacts() will produce a NO_DATA mask covering the entire bbox. + # As long as NO_DATA is in self.config.badMaskPlanes, these direct + # warps with missing psfMatched warps will not contribute to the coadd. dataIds = [ref.dataId for ref in warpRefList] psfMatchedDataIds = [ref.dataId for ref in supplementaryData.warpRefList] From e3e681dffa161241b134cd14ea48d10bb24244e5 Mon Sep 17 00:00:00 2001 From: Yusra AlSayyad Date: Tue, 7 Oct 2025 20:56:16 -0700 Subject: [PATCH 3/3] Skip detector if PhotoCalib does not have finite zeropoint --- python/lsst/drp/tasks/make_direct_warp.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/python/lsst/drp/tasks/make_direct_warp.py b/python/lsst/drp/tasks/make_direct_warp.py index 8cc8e7f0..bdd5735f 100644 --- a/python/lsst/drp/tasks/make_direct_warp.py +++ b/python/lsst/drp/tasks/make_direct_warp.py @@ -807,14 +807,20 @@ def _apply_all_calibrations( return False if self.config.useVisitSummaryPhotoCalib: - if photo_calib := row.getPhotoCalib(): - input_exposure.setPhotoCalib(photo_calib) - else: + photo_calib = row.getPhotoCalib() + if photo_calib is None: self.log.info( "No photometric calibration found in visit summary for detector = %s. Skipping it.", detector, ) return False + elif not np.isfinite(photo_calib.getInstFluxAtZeroMagnitude()): + self.log.info( + f"Invalid PhotoCalib found in visit summary for detector {detector}. Skipping it.", + ) + return False + else: + input_exposure.setPhotoCalib(photo_calib) if self.config.useVisitSummaryWcs: if wcs := row.getWcs():