summaryrefslogtreecommitdiff
path: root/wcsutil/__init__.py
diff options
context:
space:
mode:
authordencheva <dencheva@stsci.edu>2009-09-24 15:05:32 -0400
committerdencheva <dencheva@stsci.edu>2009-09-24 15:05:32 -0400
commitf95aaac222c61f886e27f7029ed592a76b31eeed (patch)
tree99d7e6b2cef65db92f52e1e7ffe82b08cbe5ce6e /wcsutil/__init__.py
parent18314675643b403b5655f3e6898c49db7e16695c (diff)
downloadstwcs_hcf-f95aaac222c61f886e27f7029ed592a76b31eeed.tar.gz
Added code which allows to create an HSTWCS object without the requirement to tie it to an instrument and detector (WCS headerlets). Also better handling of iraf type fits names
git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci_python/trunk/stwcs@8308 fe389314-cf27-0410-b35b-8c050e845b92
Diffstat (limited to 'wcsutil/__init__.py')
-rw-r--r--wcsutil/__init__.py25
1 files changed, 16 insertions, 9 deletions
diff --git a/wcsutil/__init__.py b/wcsutil/__init__.py
index a275a18..a7045c2 100644
--- a/wcsutil/__init__.py
+++ b/wcsutil/__init__.py
@@ -61,7 +61,7 @@ class HSTWCS(WCS):
if not isinstance(fobj, pyfits.HDUList):
phdu.close()
-
+ self.instrument ='DEFAULT'
self.setInstrSpecKw(hdr0, ehdr)
self.setPscale()
self.setOrient()
@@ -82,20 +82,27 @@ class HSTWCS(WCS):
if ext != None:
filename = f
- extnum = ext
+ if isinstance(ext,tuple):
+ if ext[0] == '':
+ extnum = ext[1] # handle ext=('',1)
+ else:
+ extnum = ext
+ else:
+ extnum = int(ext)
elif ext == None:
- filename, extname = fileutil.parseFilename(f)
- if extname == None:
- #data may be in the primary array
- extnum = 0
+ filename, ext = fileutil.parseFilename(f)
+ ext = fileutil.parseExtn(ext)
+ if ext[0] == '':
+ extnum = int(ext[1]) #handle ext=('',extnum)
else:
- extnum = fileutil.parseExtn(extname)
+ extnum = ext
phdu = pyfits.open(filename)
hdr0 = pyfits.getheader(filename)
try:
ehdr = pyfits.getheader(filename, ext=extnum)
- except IndexError:
- print 'Unable to get extension %d. /n' % ext
+ except (IndexError,KeyError):
+ print 'Unable to get extension.', extnum
+ raise
elif isinstance(f, pyfits.HDUList):
phdu = f