diff options
author | dencheva <dencheva@stsci.edu> | 2011-03-11 12:33:17 -0500 |
---|---|---|
committer | dencheva <dencheva@stsci.edu> | 2011-03-11 12:33:17 -0500 |
commit | 02f39a3148c28efe169e035450a9fce319d0c412 (patch) | |
tree | 2949ca272831c63a038201c8764259c8805acbf8 /updatewcs/det2im.py | |
parent | 323fea9f61f6220ef4114158c4dd76636d91eab4 (diff) | |
download | stwcs_hcf-02f39a3148c28efe169e035450a9fce319d0c412.tar.gz |
Adding logging to updatewcs
git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci_python/trunk/stwcs@12183 fe389314-cf27-0410-b35b-8c050e845b92
Diffstat (limited to 'updatewcs/det2im.py')
-rw-r--r-- | updatewcs/det2im.py | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/updatewcs/det2im.py b/updatewcs/det2im.py index 6eb7fa7..b59ca17 100644 --- a/updatewcs/det2im.py +++ b/updatewcs/det2im.py @@ -1,9 +1,13 @@ from __future__ import division # confidence high +import time import pyfits from pytools import fileutil import utils +import logging +logger = logging.getLogger('stwcs.updatewcs.Det2IM') + class DET2IMCorr(object): """ Stores a small correction to the detector coordinates as a d2imarr @@ -44,7 +48,12 @@ class DET2IMCorr(object): Uses the file pointed to in the primary header keyword 'D2IMFILE' to create an extension with a detector to image correction. """ - assert isinstance(fobj, pyfits.HDUList) + logger.info("\n\tStarting Det2IM Correction: %s" % time.asctime()) + try: + assert isinstance(fobj, pyfits.HDUList) + except AssertionError: + logger.exception('\n\tInput must be a pyfits.HDUList object') + raise d2imfile = fileutil.osfn(fobj[0].header['D2IMFILE']) axiscorr = cls.getAxisCorr(d2imfile) @@ -64,13 +73,12 @@ class DET2IMCorr(object): if direction == 'DX': return 1 elif direction == 'DY': return 2 else: - print '\tDET2IM correction expects the reference file to have' - print '\tan EXTNAME keyword of value "DX" or "DY"' + logger.warning('\n\tDET2IM correction expects the reference file to have \ + an EXTNAME keyword of value "DX" or "DY", EXTNAMe %s detected' % direction) return None - except AttributeError: - print "\tAxis to which to apply the detector to image " - print "\tcorrection cannot be determined because the reference " - print "\tfile %s is missing a keyword EXTNAME" % refname + except KeyError: + logger.exception("\n\tD2IMFILE %s is missing EXTNAME keyword. Unable to determine axis \ + to which to apply the correction." % refname) direction = None return direction getAxisCorr = classmethod(getAxisCorr) |