From 0c69f81c515b080bfa80a1ffd6a5af2275067259 Mon Sep 17 00:00:00 2001 From: dencheva Date: Fri, 3 Jun 2011 18:54:49 +0000 Subject: Headerlet.apply was not removing kw with reference files from the primary header which resulted in kw duplication after the headerlet was applied. Added code which cleans the primary header before applying the headerlet. git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci_python/trunk/stwcs@13052 fe389314-cf27-0410-b35b-8c050e845b92 --- wcsutil/headerlet.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'wcsutil') diff --git a/wcsutil/headerlet.py b/wcsutil/headerlet.py index 856be86..a30f06b 100644 --- a/wcsutil/headerlet.py +++ b/wcsutil/headerlet.py @@ -598,7 +598,8 @@ class Headerlet(pyfits.HDUList): del dest[idx].header.ascard['VAFACTOR'] except KeyError: pass - + + self._removeRefFiles(dest[0]) self._removeAltWCS(dest, ext=range(numext)) numwdvarr = countExtn(dest, 'WCSDVARR') numd2im = countExtn(dest, 'D2IMARR') @@ -606,7 +607,18 @@ class Headerlet(pyfits.HDUList): del dest[('WCSDVARR', idx)] for idx in range(1, numd2im + 1): del dest[('D2IMARR', idx)] - + + def _removeRefFiles(self, phdu): + """ + phdu: Primary HDU + """ + refkw = ['IDCTAB', 'NPOLFILE', 'D2IMFILE'] + for kw in refkw: + try: + del phdu.header.ascard[kw] + except KeyError: + pass + def _removeSIP(self, ext): """ Remove the SIP distortion of a FITS extension -- cgit