From 1b0cbea198f629cedec54109589cb9c452687a7b Mon Sep 17 00:00:00 2001 From: John Franklin Crenshaw Date: Sun, 27 Oct 2024 14:30:33 -0700 Subject: [PATCH] Fixed bug where original mask bits aren't persisted in stamps. --- python/lsst/ts/wep/task/cutOutDonutsBase.py | 5 ++++- python/lsst/ts/wep/task/donutStamp.py | 10 ++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/python/lsst/ts/wep/task/cutOutDonutsBase.py b/python/lsst/ts/wep/task/cutOutDonutsBase.py index 937e7e15..06417537 100644 --- a/python/lsst/ts/wep/task/cutOutDonutsBase.py +++ b/python/lsst/ts/wep/task/cutOutDonutsBase.py @@ -343,7 +343,6 @@ def calculateSN(self, stamp): A dictionary of calculated quantities """ - stamp.makeMask(self.instConfigFile, self.opticalModel) imageArray = stamp.stamp_im.image.array mask = stamp.stamp_im.mask varianceArray = stamp.stamp_im.variance.array @@ -437,6 +436,7 @@ def calculateSN(self, stamp): "ttl_noise_bkgnd_variance": ttlNoiseBkgndVariance, "ttl_noise_donut_variance": ttlNoiseDonutVariance, } + return snDict def filterBadRecentering(self, xShifts, yShifts): @@ -672,6 +672,9 @@ def cutOutStamps(self, exposure, donutCatalog, defocalType, cameraName): archive_element=linear_wcs, ) + # Create image mask + donutStamp.makeMask(self.instConfigFile, self.opticalModel) + # Calculate the S/N per stamp snQuant.append(self.calculateSN(donutStamp)) diff --git a/python/lsst/ts/wep/task/donutStamp.py b/python/lsst/ts/wep/task/donutStamp.py index 352c9ff3..9cd08295 100644 --- a/python/lsst/ts/wep/task/donutStamp.py +++ b/python/lsst/ts/wep/task/donutStamp.py @@ -301,12 +301,7 @@ def makeMask( ): """Create the mask for the image. - Note the mask is returned in the original coordinate system of the info - that came from the butler (i.e. the DVCS, and the CWFSs are rotated - with respect to the science sensors). See sitcomtn-003.lsst.io for more - information. - - Also note that technically the image masks depend on the optical + Note that technically the image masks depend on the optical aberrations, but this function assumes the aberrations are zero. Parameters @@ -363,6 +358,9 @@ def makeMask( nRot = int(eulerZ // 90) stampMask = np.rot90(stampMask, -nRot) + # Add back to the original mask + stampMask += self.stamp_im.mask.array + # Save mask self.stamp_im.setMask(afwImage.Mask(stampMask.copy()))