From eeed20569c1f1b264dac31337cf5639249cf911a Mon Sep 17 00:00:00 2001 From: Tim Jenness Date: Fri, 5 Jul 2024 11:24:09 -0700 Subject: [PATCH] Set python logging for obs packages Although this command seems to be gen2 butler at the moment. --- bin.src/showCamera.py | 8 ++++---- python/lsst/afw/cameraGeom/utils.py | 4 ++-- python/lsst/afw/image/_image/_fitsIoWithOptions.py | 1 + 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/bin.src/showCamera.py b/bin.src/showCamera.py index 85f8721d5c..927a216337 100755 --- a/bin.src/showCamera.py +++ b/bin.src/showCamera.py @@ -20,11 +20,11 @@ # the GNU General Public License along with this program. If not, # see . # +import logging import sys import matplotlib.pyplot as plt import lsst.afw.cameraGeom.utils as cameraGeomUtils -from lsst.log import Log if __name__ == '__main__': import argparse @@ -64,10 +64,10 @@ print("Unable to find mapper {mapperName} in {obsPackageName}", file=sys.stderr) sys.exit(1) # - # Control verbosity from butler + # Control verbosity from obs packages # - log = Log.getLogger("CameraMapper") - log.setLevel(Log.FATAL) + log = logging.getLogger("lsst.obs") + log.setLevel(logging.FATAL) # # And finally find the camera # diff --git a/python/lsst/afw/cameraGeom/utils.py b/python/lsst/afw/cameraGeom/utils.py index 46f2d8e3b0..4296bc6e4c 100644 --- a/python/lsst/afw/cameraGeom/utils.py +++ b/python/lsst/afw/cameraGeom/utils.py @@ -499,7 +499,7 @@ def getCcdImage(self, ccd, imageFactory=afwImage.ImageF, binSize=1, asMaskedImag if self.callback: try: im = self.callback(im, ccd, imageSource=self) - except Exception as e: + except Exception: if self.verbose: log.exception("callback failed.") im = imageFactory(*bbox.getDimensions()) @@ -917,7 +917,7 @@ def makeImageFromCamera(camera, detectorNameList=None, background=numpy.nan, buf imView = camIm.Factory(camIm, bbox, afwImage.LOCAL) try: imView[:] = im - except pexExceptions.LengthError as e: + except pexExceptions.LengthError: log.exception("Unable to fit image for detector \"%s\" into image of camera.", det.getName()) return camIm diff --git a/python/lsst/afw/image/_image/_fitsIoWithOptions.py b/python/lsst/afw/image/_image/_fitsIoWithOptions.py index 509a7761f0..e70858e7ac 100644 --- a/python/lsst/afw/image/_image/_fitsIoWithOptions.py +++ b/python/lsst/afw/image/_image/_fitsIoWithOptions.py @@ -29,6 +29,7 @@ _LOG = logging.getLogger("lsst.afw.image") + # This must be added to a class as a *classmethod*, for example: # # @continueclass