diff options
author | dencheva <dencheva@stsci.edu> | 2011-08-09 18:53:02 -0400 |
---|---|---|
committer | dencheva <dencheva@stsci.edu> | 2011-08-09 18:53:02 -0400 |
commit | 8fa29488b0577ed97eeae6a93919401a1c4c7e10 (patch) | |
tree | 8851b6e35ed9a2ea48508cfe35565e9e2cd08ff0 | |
parent | 9c4332ed7c7c89dff99c719a0e8a0ffd7f504e7c (diff) | |
download | stwcs_hcf-8fa29488b0577ed97eeae6a93919401a1c4c7e10.tar.gz |
Added additional keywords to headers to support alternate WCSs and headerlets.
git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci_python/trunk/stwcs@13552 fe389314-cf27-0410-b35b-8c050e845b92
-rw-r--r-- | lib/stwcs/updatewcs/__init__.py | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/lib/stwcs/updatewcs/__init__.py b/lib/stwcs/updatewcs/__init__.py index 57e16b2..fb77b91 100644 --- a/lib/stwcs/updatewcs/__init__.py +++ b/lib/stwcs/updatewcs/__init__.py @@ -145,7 +145,12 @@ def makecorr(fname, allowed_corr): kw2update = corr_klass.updateWCS(ext_wcs, ref_wcs) for kw in kw2update: hdr.update(kw, kw2update[kw]) - + # give the primary WCS a WCSNAME value + idcname = f[0].header.get('IDCTAB', " ") + if idcname.strip() and 'idc.fits' in idcname: + wname = ''.join(['IDC_',idcname.split('_idc.fits')[0]]) + else: wname = " " + hdr.update('WCSNAME', wname) elif extname in ['err', 'dq', 'sdq', 'samp', 'time']: cextver = extn.header['extver'] @@ -181,8 +186,29 @@ def makecorr(fname, allowed_corr): comment="Version of STWCS used to updated the WCS",after=i) f[0].header.update(key='PYWCSVER', value=pywcsversion, comment="Version of PYWCS used to updated the WCS",after=i) + # add additional keywords to be used by headerlets + distname = construct_distname(f) + f[0].header.update('DISTNAME', distname) + idcname = f[0].header.get('IDCTAB', " ") + f[0].header.update('SIPNAME', idcname) f.close() +def construct_distname(fobj): + idcname = fobj[0].header.get('IDCTAB', " ") + if idcname.strip() and 'fits' in idcname: + idcname = idcname.split('.fits')[0] + + npolname = fobj[0].header.get('NPOLFILE', " ") + if npolname.strip() and '.fits' in npolname: + npolname = npolname.split('.fits')[0] + + d2imname = fobj[0].header.get('D2IMFILE', " ") + if d2imname.strip() and '.fits' in d2imname: + d2imname = d2imname.split('.fits')[0] + + distname = idcname.strip().join(npolname.strip()).join(d2imname.strip()) + return distname + def copyWCS(w, ehdr): """ This is a convenience function to copy a WCS object |