summaryrefslogtreecommitdiff
path: root/hstwcs
diff options
context:
space:
mode:
Diffstat (limited to 'hstwcs')
-rw-r--r--hstwcs/__init__.py7
-rw-r--r--hstwcs/apply_corrections.py2
-rw-r--r--hstwcs/det2im.py19
3 files changed, 21 insertions, 7 deletions
diff --git a/hstwcs/__init__.py b/hstwcs/__init__.py
index 7de38fe..bf47cdc 100644
--- a/hstwcs/__init__.py
+++ b/hstwcs/__init__.py
@@ -81,11 +81,8 @@ def makecorr(fname, allowed_corr):
utils.write_archive(f[nrefext].header)
if 'DET2IMCorr' in allowed_corr:
- kw2update = det2im.DET2IMCorr.updateWCS(f)
- for kw in kw2update:
- #these kw are written to the primary header
- f[0].header.update(kw, kw2update[kw])
-
+ det2im.DET2IMCorr.updateWCS(f)
+
for i in range(len(f))[1:]:
# Perhaps all ext headers should be corrected (to be consistent)
extn = f[i]
diff --git a/hstwcs/apply_corrections.py b/hstwcs/apply_corrections.py
index c54725c..88d997e 100644
--- a/hstwcs/apply_corrections.py
+++ b/hstwcs/apply_corrections.py
@@ -159,7 +159,7 @@ def applyD2ImCorr(fname, d2imcorr):
return applyD2IMCorr
try:
# get DGEOEXT kw from first extension header
- fd2imext = pyfits.getval(fname, 'D2IMEXT', ext=0)
+ fd2imext = pyfits.getval(fname, 'D2IMEXT', ext=1)
fd2imext = fileutil.osfn(fd2imext)
if fd2imext and fileutil.findFile(fd2imext):
if fd2im0 != fd2imext:
diff --git a/hstwcs/det2im.py b/hstwcs/det2im.py
index 164eff6..90c9f28 100644
--- a/hstwcs/det2im.py
+++ b/hstwcs/det2im.py
@@ -20,7 +20,7 @@ class DET2IMCorr(object):
else:
new_kw = {'D2IMEXT': d2imfile, 'AXISCORR': axiscorr, 'D2IMERR': d2imerr}
cls.applyDet2ImCorr(fobj, axiscorr)
- return new_kw
+ cls.updatehdr(fobj, new_kw)
updateWCS = classmethod(updateWCS)
@@ -135,4 +135,21 @@ class DET2IMCorr(object):
return hdr
createDet2ImHdr = classmethod(createDet2ImHdr)
+
+ def updatehdr(cls, fobj, kwdict):
+ """
+ Update extension headers to keep record of the files used for the
+ detector to image correction.
+ """
+ for ext in fobj:
+ try:
+ extname = ext.header['EXTNAME'].lower()
+ except KeyError:
+ continue
+ if extname == 'sci':
+ for kw in kwdict:
+ ext.header.update(kw, kwdict[kw])
+ else:
+ continue
+ updatehdr = classmethod(updatehdr)
\ No newline at end of file