summaryrefslogtreecommitdiff
path: root/hstwcs
diff options
context:
space:
mode:
Diffstat (limited to 'hstwcs')
-rw-r--r--hstwcs/__init__.py19
-rw-r--r--hstwcs/makewcs.py2
2 files changed, 9 insertions, 12 deletions
diff --git a/hstwcs/__init__.py b/hstwcs/__init__.py
index 84f6cec..dfb2e4b 100644
--- a/hstwcs/__init__.py
+++ b/hstwcs/__init__.py
@@ -75,20 +75,20 @@ def makecorr(fname, allowed_corr):
"""
f = pyfits.open(fname, mode='update')
- #Determine the reference chip and make a copy of its restored header.
+ #Determine the reference chip and create the reference HSTWCS object
nrefchip, nrefext = getNrefchip(f)
- primhdr = f[0].header
- ref_hdr = f[nrefext].header.copy()
- utils.write_archive(ref_hdr)
-
- for extn in f:
+ ref_wcs = HSTWCS(fobj=f, ext=nrefext)
+ ref_wcs.readModel(update=True,header=f[nrefext].header)
+ utils.write_archive(f[nrefext].header)
+
+ for i in range(len(f))[1:]:
# Perhaps all ext headers should be corrected (to be consistent)
+ extn = f[i]
if extn.header.has_key('extname') and extn.header['extname'].lower() == 'sci':
- ref_wcs = HSTWCS(primhdr, ref_hdr, fobj=f)
- ref_wcs.readModel(update=True, header=ref_hdr)
+ ref_wcs.restore(f[nrefext].header)
hdr = extn.header
- ext_wcs = HSTWCS(primhdr, hdr, fobj=f)
utils.write_archive(hdr)
+ ext_wcs = HSTWCS(fobj=f, ext=i)
ext_wcs.readModel(update=True,header=hdr)
for c in allowed_corr:
if c != 'DGEOCorr':
@@ -103,7 +103,6 @@ def makecorr(fname, allowed_corr):
f[1].header.update(kw, kw2update[kw])
f.close()
-
def getNrefchip(fobj):
"""
This handles the fact that WFPC2 subarray observations
diff --git a/hstwcs/makewcs.py b/hstwcs/makewcs.py
index 650d251..809daab 100644
--- a/hstwcs/makewcs.py
+++ b/hstwcs/makewcs.py
@@ -1,4 +1,3 @@
-#from .. mappings import DEGTORAD, RADTODEG
from updatewcs import DEGTORAD, RADTODEG
import numpy
from math import sin, sqrt, pow, cos, asin, atan2,pi
@@ -42,7 +41,6 @@ class MakeWCS(object):
cls.uprefwcs(ext_wcs, ref_wcs, rv23_corr, ltvoff, offshift)
cls.upextwcs(ext_wcs, ref_wcs, v23_corr, rv23_corr, ltvoff, offshift)
-
kw2update = {'CD1_1': ext_wcs.wcs.cd[0,0],
'CD1_2': ext_wcs.wcs.cd[0,1],