From c58735cfd7b383612abf9684c8ace58413269124 Mon Sep 17 00:00:00 2001 From: hack Date: Wed, 11 Apr 2012 21:18:59 +0000 Subject: Based on a report by Andy, a bug was fixed in the headerlet code that had resulted in duplication of entries in the WCSCORR table when updating an image with a headerlet. The 'attach_to_file' method of the Headerlet class was modified to only update the WCSCORR table upon request, as it gets called by other routines which are already updating WCSCORR. git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci_python/trunk/stwcs@16151 fe389314-cf27-0410-b35b-8c050e845b92 --- lib/stwcs/wcsutil/headerlet.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib/stwcs/wcsutil/headerlet.py') diff --git a/lib/stwcs/wcsutil/headerlet.py b/lib/stwcs/wcsutil/headerlet.py index baf7481..fe26393 100644 --- a/lib/stwcs/wcsutil/headerlet.py +++ b/lib/stwcs/wcsutil/headerlet.py @@ -1286,7 +1286,7 @@ def attach_headerlet(filename, hdrlet, logging=False, logmode='a'): """ hlet = Headerlet(hdrlet, logging=logging, logmode='a') - hlet.attach_to_file(filename) + hlet.attach_to_file(filename,archive=True) @with_logging @@ -2186,7 +2186,7 @@ class Headerlet(pyfits.HDUList): if close_dest: fobj.close() - def attach_to_file(self, fobj): + def attach_to_file(self, fobj, archive=False): """ Attach Headerlet as an HeaderletHDU to a science file @@ -2194,6 +2194,8 @@ class Headerlet(pyfits.HDUList): ---------- fobj: string, HDUList science file/HDUList to which the headerlet should be applied + archive: string + Specifies whether or not to update WCSCORR table when attaching Notes ----- @@ -2213,8 +2215,8 @@ class Headerlet(pyfits.HDUList): new_hlt = HeaderletHDU.fromheaderlet(self) new_hlt.header.update('extver', numhlt + 1) fobj.append(new_hlt) - - wcscorr.update_wcscorr(fobj, self, 'SIPWCS', active=False) + if archive: + wcscorr.update_wcscorr(fobj, self, 'SIPWCS', active=False) else: message = "Observation %s cannot be updated with headerlet" % (fname) -- cgit