diff options
author | embray <embray@stsci.edu> | 2011-04-13 12:46:32 -0400 |
---|---|---|
committer | embray <embray@stsci.edu> | 2011-04-13 12:46:32 -0400 |
commit | 1222f265a3f0db0e6612ff50711f834fbbd39b7b (patch) | |
tree | 1a9c5b5e845457f2bb342dc2113f12b4fa9bf34d | |
parent | 0942caae8190cd5fe1f1ee5182556a0ce0cd9357 (diff) | |
download | stwcs_hcf-1222f265a3f0db0e6612ff50711f834fbbd39b7b.tar.gz |
Turn out pyfits doesn't really do anything helpful to automatically manage extension version numbers (I should look into fixing that). This makes sure that each headerlet HDU appended to a file is given a sensible extension version by default.
git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci_python/trunk/stwcs@12459 fe389314-cf27-0410-b35b-8c050e845b92
-rw-r--r-- | wcsutil/headerlet.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/wcsutil/headerlet.py b/wcsutil/headerlet.py index 236fb92..d4e0320 100644 --- a/wcsutil/headerlet.py +++ b/wcsutil/headerlet.py @@ -426,6 +426,7 @@ class Headerlet(pyfits.HDUList): wcscorr.init_wcscorr(fobj) orig_hlt_hdu = None + numhlt = countExtn(fobj, 'HDRLET') if createheaderlet: # Create a headerlet for the original WCS data in the file, # create an HDU from the original headerlet, and append it to @@ -434,6 +435,8 @@ class Headerlet(pyfits.HDUList): hdrname = fobj[0].header['ROOTNAME'] + '_orig' orig_hlt = createHeaderlet(fobj, hdrname) orig_hlt_hdu = HeaderletHDU.fromheaderlet(orig_hlt) + orig_hlt_hdu.update_ext_version(numhlt + 1) + numhlt += 1 self._delDestWCS(fobj) updateRefFiles(self[0].header.ascard, fobj[0].header.ascard) @@ -479,7 +482,9 @@ class Headerlet(pyfits.HDUList): fobj.append(orig_hlt_hdu) # Finally, append an HDU for this headerlet - fobj.append(HeaderletHDU.fromheaderlet(self)) + new_hlt = HeaderletHDU.fromheaderlet(self) + new_hlt.update_ext_version(numhlt + 1) + fobj.append(new_hlt) if close_dest: fobj.close() |