Skip to content

Commit

Permalink
Handle exception caused by a single constant pixel value.
Browse files Browse the repository at this point in the history
  • Loading branch information
czwa committed Sep 26, 2022
1 parent 6bae470 commit 605069c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion python/lsst/cp/pipe/defects.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from lsst.geom import Box2I, Point2I
from lsst.meas.algorithms import SourceDetectionTask
from lsst.ip.isr import Defects, countMaskedPixels
from lsst.pex.exceptions import InvalidParameterError

from ._lookupStaticCalibration import lookupStaticCalibration

Expand Down Expand Up @@ -246,7 +247,15 @@ def findHotAndColdPixels(self, exp, nSigma):

threshold = afwDetection.createThreshold(nSig, 'stdev', polarity=polarity)

footprintSet = afwDetection.FootprintSet(ampImg, threshold)
try:
footprintSet = afwDetection.FootprintSet(ampImg, threshold)
except InvalidParameterError:
# This occurs if the image sigma value is 0.0.
# Let's mask the whole area.
minValue = np.min(ampImg.image.array) - 1.0
threshold = afwDetection.createThreshold(minValue, 'value', polarity=True)
footprintSet = afwDetection.FootprintSet(ampImg, threshold)

footprintSet.setMask(maskedIm.mask, ("DETECTED" if polarity else "DETECTED_NEGATIVE"))

if mergedSet is None:
Expand Down

0 comments on commit 605069c

Please sign in to comment.