Skip to content

Commit

Permalink
Ensure expected ImageSource values exist.
Browse files Browse the repository at this point in the history
  • Loading branch information
czwa committed Apr 20, 2020
1 parent 2347722 commit b5786d9
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions python/lsst/pipe/tasks/visualizeVisit.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ class ImageSource:
"""Source of images for makeImageFromCamera"""
def __init__(self, exposures):
self.exposures = exposures
self.isTrimmed = True
self.background = np.nan

def getCcdImage(self, detector, imageFactory, binSize):
"""Provide image of CCD to makeImageFromCamera
Expand All @@ -242,13 +244,22 @@ def getCcdImage(self, detector, imageFactory, binSize):
belongs to.
"""
detId = detector.getId()

if detId not in self.exposures:
dims = detector.getBBox().getDimensions()/binSize
image = imageFactory(*[int(xx) for xx in dims])
image.set(np.nan)
image.set(self.background)
else:
image = self.exposures[detector.getId()]
image = image.getImage()
if hasattr(image, "getMaskedImage"):
image = image.getMaskedImage()
if hasattr(image, "getMask"):
mask = image.getMask()
isBad = mask.getArray() & mask.getPlaneBitMask("NO_DATA") > 0
image = image.clone()
image.getImage().getArray()[isBad] = self.background
if hasattr(image, "getImage"):
image = image.getImage()

# afwMath.rotateImageBy90 checks NQuarter values,
# so we don't need to here.
Expand Down

0 comments on commit b5786d9

Please sign in to comment.