summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhack <hack@stsci.edu>2013-08-27 13:43:15 -0400
committerhack <hack@stsci.edu>2013-08-27 13:43:15 -0400
commit9e0a421a1940d081192046938df10aee8aec6819 (patch)
treee0787c7bb983ed6e3a95f606a6be3af6b8e0f405
parent7ea629909b12dffd8b0833b7524bc51204dc1d31 (diff)
downloadstwcs_hcf-9e0a421a1940d081192046938df10aee8aec6819.tar.gz
The apply_as_primary() method of the Headerlet class was revised to look for the correct WCSDVARR (and D2IMARR) extensions from the headerlet. This finished the process where the PyWCS generated object was updated to include the image-specific EXTVER values for each of the WCSDVARR and D2IMARR extensions.
These changes were successfully tested (manually) on the regression test case where the problem was first reproduced after being alerted to this problem by Shireen when trying to document the apply_headerlet_as_primary() function. git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stwcs/trunk@26499 fe389314-cf27-0410-b35b-8c050e845b92
-rw-r--r--lib/stwcs/wcsutil/headerlet.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/stwcs/wcsutil/headerlet.py b/lib/stwcs/wcsutil/headerlet.py
index 969dc50..14e00c6 100644
--- a/lib/stwcs/wcsutil/headerlet.py
+++ b/lib/stwcs/wcsutil/headerlet.py
@@ -1870,6 +1870,8 @@ class Headerlet(pyfits.HDUList):
sipwcs = HSTWCS(self, ('SIPWCS', i))
idckw = sipwcs._idc2hdr()
priwcs = sipwcs.to_fits(relax=True)
+ numnpol = 1
+ numd2im = 1
if sipwcs.wcs.has_cd():
priwcs[0].header = altwcs.pc2cd(priwcs[0].header)
priwcs[0].header.extend(idckw)
@@ -1904,6 +1906,7 @@ class Headerlet(pyfits.HDUList):
if 'D2IM2.EXTVER' in priwcs[0].header:
priwcs[0].header['D2IM2.EXTVER'] = self[('SIPWCS', i)].header['D2IM2.EXTVER']
priwcs[('D2IMARR', 2)].header['EXTVER'] = self[('SIPWCS', i)].header['D2IM2.EXTVER']
+ numd2im = 2
if sipwcs.cpdis1 or sipwcs.cpdis2:
try:
@@ -1921,23 +1924,23 @@ class Headerlet(pyfits.HDUList):
if 'DP2.EXTVER' in priwcs[0].header:
priwcs[0].header['DP2.EXTVER'] = self[('SIPWCS', i)].header['DP2.EXTVER']
priwcs[('WCSDVARR', 2)].header['EXTVER'] = self[('SIPWCS', i)].header['DP2.EXTVER']
-
+ numnpol = 2
fobj[target_ext].header.extend(priwcs[0].header)
if sipwcs.cpdis1:
- whdu = priwcs[('WCSDVARR', 1)].copy()
+ whdu = priwcs[('WCSDVARR', (i-1)*numnpol+1)].copy()
whdu.update_ext_version(self[('SIPWCS', i)].header['DP1.EXTVER'])
fobj.append(whdu)
if sipwcs.cpdis2:
- whdu = priwcs[('WCSDVARR', 2)].copy()
+ whdu = priwcs[('WCSDVARR', i*numnpol)].copy()
whdu.update_ext_version(self[('SIPWCS', i)].header['DP2.EXTVER'])
fobj.append(whdu)
if sipwcs.det2im1: #or sipwcs.det2im2:
- whdu = priwcs[('D2IMARR', 1)].copy()
+ whdu = priwcs[('D2IMARR', (i-1)*numd2im+1)].copy()
whdu.update_ext_version(self[('SIPWCS', i)].header['D2IM1.EXTVER'])
fobj.append(whdu)
if sipwcs.det2im2:
- whdu = priwcs[('D2IMARR', 2)].copy()
+ whdu = priwcs[('D2IMARR', i*num2dim)].copy()
whdu.update_ext_version(self[('SIPWCS', i)].header['D2IM2.EXTVER'])
fobj.append(whdu)