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(