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/npol.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/npol.py')
-rw-r--r-- | updatewcs/npol.py | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/updatewcs/npol.py b/updatewcs/npol.py index fb2c128..62c44bd 100644 --- a/updatewcs/npol.py +++ b/updatewcs/npol.py @@ -5,6 +5,9 @@ from pytools import fileutil import utils import numpy as np +import logging, time +logger = logging.getLogger('stwcs.updatewcs.npol') + class NPOLCorr(object): """ Defines a Lookup table prior distortion correction as per WCS paper IV. @@ -38,7 +41,13 @@ class NPOLCorr(object): Science file, for which a distortion correction in a NPOLFILE is available """ - assert isinstance(fobj, pyfits.HDUList) + logger.info("\n\tStarting CompSIP: %s" %time.asctime()) + try: + assert isinstance(fobj, pyfits.HDUList) + except AssertionError: + logger.exception('\n\tInput must be a pyfits.HDUList object') + raise + cls.applyNPOLCorr(fobj) nplfile = fobj[0].header['NPOLFILE'] @@ -107,7 +116,7 @@ class NPOLCorr(object): continue if ename == 'WCSDVARR': wcsd[fobj[e].header['EXTVER']] = e - + logger.debug("A map of WSCDVARR externsions %s" % wcsd) return wcsd getWCSIndex = classmethod(getWCSIndex) @@ -188,12 +197,13 @@ class NPOLCorr(object): ocy11 = header['OCY11'] coeffs = np.array([[ocx11, ocx10], [ocy11,ocy10]], dtype=np.float32) except KeyError: - print 'First order IDCTAB coefficients are not available.\n' - print 'Cannot convert SIP to IDC coefficients.\n' + logger.exception('\n\tFirst order IDCTAB coefficients are not available. \n\ + Cannot convert SIP to IDC coefficients.') return None try: idcscale = header['IDCSCALE'] except KeyError: + logger.exception("IDCSCALE not found in header - setting it to 1.") idcscale = 1 return np.linalg.inv(coeffs/idcscale) @@ -220,13 +230,11 @@ class NPOLCorr(object): """ npl = pyfits.open(npolfile) for ext in npl: - #for i in range(len(dgf)): try: nplextname = ext.header['EXTNAME'] nplextver = ext.header['EXTVER'] except KeyError: continue - #dgccdchip = ext.header.get('CCDCHIP', 0) nplccdchip = cls.get_ccdchip(npl, extname=nplextname, extver=nplextver) if nplextname == npl_extname and nplccdchip == ccdchip: npol_header = ext.header |