summaryrefslogtreecommitdiff
path: root/lib/stwcs/updatewcs/det2im.py
diff options
context:
space:
mode:
authorembray <embray@stsci.edu>2012-02-22 13:17:23 -0500
committerembray <embray@stsci.edu>2012-02-22 13:17:23 -0500
commit8cbc50fe21cfb148e9ef48b4d1700bbdd2af1d63 (patch)
treecb4939bc290bb413bed4132a2a188a33fc18dd5e /lib/stwcs/updatewcs/det2im.py
parent3c9cc9b532095b83b3e66333ca74cd29e3ee56c6 (diff)
downloadstwcs_hcf-8cbc50fe21cfb148e9ef48b4d1700bbdd2af1d63.tar.gz
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
Diffstat (limited to 'lib/stwcs/updatewcs/det2im.py')
-rw-r--r--lib/stwcs/updatewcs/det2im.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/stwcs/updatewcs/det2im.py b/lib/stwcs/updatewcs/det2im.py
index b658d53..8235d83 100644
--- a/lib/stwcs/updatewcs/det2im.py
+++ b/lib/stwcs/updatewcs/det2im.py
@@ -126,8 +126,11 @@ class DET2IMCorr(object):
d2imfile = fileutil.osfn(fobj[0].header['D2IMFILE'])
axiscorr = cls.getAxisCorr(d2imfile)
sci_hdr = fobj[1].header
- data_shape = pyfits.getdata(d2imfile, ext=1).shape
- naxis = pyfits.getval(d2imfile, 'NAXIS', ext=1 )
+ d2im = pyfits.open(d2imfile)
+ data_shape = d2im[1].shape
+ naxis = d2im[1].header['NAXIS']
+ d2im_phdr = d2im[0].header
+ d2im.close()
kw = { 'NAXIS': 'Size of the axis',
'CRPIX': 'Coordinate system reference pixel',
@@ -170,24 +173,23 @@ class DET2IMCorr(object):
}
- cdl = pyfits.CardList()
+ cdl = []
for key in kw_comm0.keys():
- cdl.append(pyfits.Card(key=key, value=kw_val0[key], comment=kw_comm0[key]))
+ cdl.append((key, kw_val0[key], kw_comm0[key]))
for key in kw_comm1.keys():
- cdl.append(pyfits.Card(key=key, value=kw_val1[key], comment=kw_comm1[key]))
+ cdl.append((key, kw_val1[key], kw_comm1[key]))
# Now add keywords from NPOLFILE header to document source of calibration
# include all keywords after and including 'FILENAME' from header
- d2im_phdr = pyfits.getheader(d2imfile)
start_indx = -1
end_indx = 0
- for c,i in zip(d2im_phdr,range(len(d2im_phdr))):
+ for i, c in enumerate(d2im_phdr):
if c == 'FILENAME':
start_indx = i
if c == '': # remove blanks from end of header
end_indx = i+1
break
if start_indx >= 0:
- for card in d2im_phdr[start_indx:end_indx]:
+ for card in d2im_phdr.cards[start_indx:end_indx]:
cdl.append(card)
hdr = pyfits.Header(cards=cdl)