From 8cbc50fe21cfb148e9ef48b4d1700bbdd2af1d63 Mon Sep 17 00:00:00 2001 From: embray Date: Wed, 22 Feb 2012 18:17:23 +0000 Subject: Should fix most problems in stwcs due to pyfits Header updates. The main issue that caused incompatibility is that slices of headers (including by wildcard patterns) now returns a new Header rather than a list of cards. git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci_python/trunk/stwcs@15198 fe389314-cf27-0410-b35b-8c050e845b92 --- lib/stwcs/wcsutil/getinput.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'lib/stwcs/wcsutil/getinput.py') diff --git a/lib/stwcs/wcsutil/getinput.py b/lib/stwcs/wcsutil/getinput.py index 2f64f46..bfe4234 100644 --- a/lib/stwcs/wcsutil/getinput.py +++ b/lib/stwcs/wcsutil/getinput.py @@ -21,12 +21,11 @@ def parseSingleInput(f=None, ext=None): else: extnum = ext phdu = pyfits.open(filename) - hdr0 = pyfits.getheader(filename) + hdr0 = phdu[0].header try: - ehdr = pyfits.getheader(filename, ext=extnum) - except (IndexError,KeyError): - print 'Unable to get extension.', extnum - raise + ehdr = phdu[extnum].header + except (IndexError, KeyError), e: + raise e.__class__('Unable to get extension %s.' % extnum) elif isinstance(f, pyfits.HDUList): phdu = f @@ -37,9 +36,10 @@ def parseSingleInput(f=None, ext=None): ehdr = f[extnum].header hdr0 = f[0].header filename = hdr0.get('FILENAME', "") - + else: - raise ValueError('Input must be a file name string or a pyfits file object') + raise ValueError('Input must be a file name string or a pyfits file ' + 'object') return filename, hdr0, ehdr, phdu @@ -59,4 +59,4 @@ def parseMultipleInput(input): return input else: filelist = input[:] - return filelist \ No newline at end of file + return filelist -- cgit