Skip to content

Commit

Permalink
isr: catch error from matplotlib
Browse files Browse the repository at this point in the history
makeRGB can fail with:
    SystemError: <built-in method flush of _io.BufferedWriter object at
    0x2b2a0081c938> returned a result with an error set
This unhelpful error comes from the bowels of matplotlib, so not much we
can do about it except keep it from being fatal.
  • Loading branch information
PaulPrice committed Jan 26, 2018
1 parent 6284f2b commit 974258f
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions python/lsst/obs/subaru/isr.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,10 +488,18 @@ def writeThumbnail(self, dataRef, dataset, exposure):
stats = afwMath.makeStatistics(binnedImage,
afwMath.MEDIAN | afwMath.STDEVCLIP | afwMath.MAX, statsCtrl)
low = stats.getValue(afwMath.MEDIAN) - self.config.thumbnailStdev*stats.getValue(afwMath.STDEVCLIP)
makeRGB(binnedImage, binnedImage, binnedImage, minimum=low, dataRange=self.config.thumbnailRange,
Q=self.config.thumbnailQ, fileName=filename,
saturatedBorderWidth=self.config.thumbnailSatBorder,
saturatedPixelValue=stats.getValue(afwMath.MAX))
try:
makeRGB(binnedImage, binnedImage, binnedImage, minimum=low, dataRange=self.config.thumbnailRange,
Q=self.config.thumbnailQ, fileName=filename,
saturatedBorderWidth=self.config.thumbnailSatBorder,
saturatedPixelValue=stats.getValue(afwMath.MAX))
except Exception as exc:
# makeRGB can fail with:
# SystemError: <built-in method flush of _io.BufferedWriter object at 0x2b2a0081c938>
# returned a result with an error set
# This unhelpful error comes from the bowels of matplotlib, so not much we can do about it
# except keep it from being fatal.
self.log.warn("Unable to write thumbnail for %s: %s", dataRef.dataId, exc)

def measureOverscan(self, ccdExposure, amp):
clipSigma = 3.0
Expand Down

0 comments on commit 974258f

Please sign in to comment.