From d81d96c29e0ea603ecc1023061dea0698f953544 Mon Sep 17 00:00:00 2001 From: Eli Rykoff Date: Wed, 11 Sep 2024 16:20:54 -0700 Subject: [PATCH] Fix protections against double-mask-growth. --- python/lsst/ip/isr/overscan.py | 4 ++-- tests/test_overscanCorrection.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/python/lsst/ip/isr/overscan.py b/python/lsst/ip/isr/overscan.py index 436c004c9..c5746c840 100644 --- a/python/lsst/ip/isr/overscan.py +++ b/python/lsst/ip/isr/overscan.py @@ -266,12 +266,12 @@ def correctOverscan(self, exposure, amp, imageBBox, overscanBBox, ) else: median = np.ma.median(np.ma.masked_where(overscanMask, overscanArray)) - bad = np.where(np.abs(overscanArray - median) > self.config.maxDeviation) + bad = np.where((np.abs(overscanArray - median) > self.config.maxDeviation) & (~overscanMask)) # Mark the bad pixels as BAD. overscanImage.mask.array[bad] = overscanImage.mask.getPlaneBitMask("BAD") # Check for completely masked row/column. - if maskedRowColumnGrowSize > 0: + if maskedRowColumnGrowSize > 0 and len(bad) > 0: if isTransposed: axis = 0 nComp = overscanArray.shape[0] diff --git a/tests/test_overscanCorrection.py b/tests/test_overscanCorrection.py index 53eb3f19b..02393ba72 100644 --- a/tests/test_overscanCorrection.py +++ b/tests/test_overscanCorrection.py @@ -543,6 +543,7 @@ def test_bleedParallelOverscanCorrection(self): configParallel = ipIsr.overscan.ParallelOverscanCorrectionTask.ConfigClass() configParallel.parallelOverscanMaskGrowSize = 1 + configParallel.parallelOverscanMaskedColumnGrowSize = 0 configParallel.fitType = fitType parallelOverscanTask = ipIsr.overscan.ParallelOverscanCorrectionTask(