diff options
author | dencheva <dencheva@stsci.edu> | 2013-04-11 17:17:57 -0400 |
---|---|---|
committer | dencheva <dencheva@stsci.edu> | 2013-04-11 17:17:57 -0400 |
commit | 17348f6a47aef2c9fcbaf437df7e92d3b7c6827d (patch) | |
tree | 9819d719311de191c525095ef9f9a2f4f92f5b8a /lib/stwcs/wcsutil/headerlet.py | |
parent | 8c0c74c5ee527f7d028a6b6574100ecaf4b11235 (diff) | |
download | stwcs_hcf-17348f6a47aef2c9fcbaf437df7e92d3b7c6827d.tar.gz |
When creating a WCS object with NPOl or D2IM correction Pywcs does not keep track of DPi.EXTVER of the lookup table. In order to recover this information a create_headerlet looks at the header of the science file. However, in the case of a science file with 'old style' D2IM format these keywords are not used , so when writing out headerlets for such file, create_headerlet converts them to the 'new style' and makes up the values for the D2IMi.EXTVER keywords.
git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stwcs/trunk@24211 fe389314-cf27-0410-b35b-8c050e845b92
Diffstat (limited to 'lib/stwcs/wcsutil/headerlet.py')
-rw-r--r-- | lib/stwcs/wcsutil/headerlet.py | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/lib/stwcs/wcsutil/headerlet.py b/lib/stwcs/wcsutil/headerlet.py index 808d4be..3a3bf64 100644 --- a/lib/stwcs/wcsutil/headerlet.py +++ b/lib/stwcs/wcsutil/headerlet.py @@ -999,6 +999,13 @@ def create_headerlet(filename, sciext='SCI', hdrname=None, destim=None, author, descrip, history) hdul.append(phdu) wcsdvarr_extns = [] + """ + nd2i is a counter for d2i extensions to be used when the science file + has an old d2i correction format. The old format did not write EXTVER + kw for the d2i correction in the science header bu tthe new format expects + them. + """ + nd2i_extver = 1 for ext in sciext: wkeys = altwcs.wcskeys(fobj, ext=ext) if wcskey != ' ': @@ -1031,10 +1038,18 @@ def create_headerlet(filename, sciext='SCI', hdrname=None, destim=None, pass whdul[0].header.extend(fobj[ext].header.cards['D2IMERR*']) if 'D2IM1.EXTVER' in whdul[0].header: - whdul[0].header['D2IM1.EXTVER'] = fobj[ext].header['D2IM1.EXTVER'] + try: + whdul[0].header['D2IM1.EXTVER'] = fobj[ext].header['D2IM1.EXTVER'] + except KeyError: + whdul[0].header['D2IM1.EXTVER'] = nd2i_extver + nd2i_extver += 1 if 'D2IM2.EXTVER' in whdul[0].header: - whdul[0].header['D2IM2.EXTVER'] = fobj[ext].header['D2IM2.EXTVER'] - + try: + whdul[0].header['D2IM2.EXTVER'] = fobj[ext].header['D2IM2.EXTVER'] + except KeyError: + whdul[0].header['D2IM2.EXTVER'] = nd2i_extver + nd2i_extver += 1 + if hwcs.cpdis1 or hwcs.cpdis2: whdul[0].header.extend(fobj[ext].header.cards['CPERR*']) try: @@ -1063,11 +1078,11 @@ def create_headerlet(filename, sciext='SCI', hdrname=None, destim=None, if hwcs.det2im1: whdu = whdul[('D2IMARR', 1)].copy() - whdu.update_ext_version(fobj[ext].header['D2IM1.EXTVER']) + whdu.update_ext_version(ihdu.header['D2IM1.EXTVER']) hdul.append(whdu) if hwcs.det2im2: whdu = whdul[('D2IMARR', 2)].copy() - whdu.update_ext_version(fobj[ext].header['D2IM2.EXTVER']) + whdu.update_ext_version(ihdu.header['D2IM2.EXTVER']) hdul.append(whdu) |