summaryrefslogtreecommitdiff
path: root/lib/stwcs/wcsutil
diff options
context:
space:
mode:
Diffstat (limited to 'lib/stwcs/wcsutil')
-rw-r--r--lib/stwcs/wcsutil/headerlet.py11
-rw-r--r--lib/stwcs/wcsutil/wcscorr.py4
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/stwcs/wcsutil/headerlet.py b/lib/stwcs/wcsutil/headerlet.py
index 0cad22a..c2abad0 100644
--- a/lib/stwcs/wcsutil/headerlet.py
+++ b/lib/stwcs/wcsutil/headerlet.py
@@ -193,7 +193,6 @@ def get_header_kw_vals(hdr, kwname, kwval, default=0):
kwval = default
return kwval
-
@with_logging
def find_headerlet_HDUs(fobj, hdrext=None, hdrname=None, distname=None,
strict=True, logging=False, logmode='w'):
@@ -776,6 +775,7 @@ def write_headerlet(filename, hdrname, output=None, sciext='SCI',
wcscorr.update_wcscorr(fobj, source=hdrletobj,
extname='SIPWCS', wcs_id=wname)
+ utils.updateNEXTENDKw(fobj)
fobj.flush()
else:
message = """
@@ -1313,6 +1313,7 @@ def _delete_single_headerlet(filename, hdrname=None, hdrext=None, distname=None,
for hdrind in hdrlet_ind:
del fobj[hdrind]
+ utils.updateNEXTENDKw(fobj)
# Update file object with changes
fobj.flush()
# close file, if was opened by this function
@@ -1506,6 +1507,7 @@ def restore_from_headerlet(filename, hdrname=None, hdrext=None, archive=True,
#
hdrlet.apply_as_primary(fobj, attach=False, archive=archive, force=force)
+ utils.updateNEXTENDKw(fobj)
fobj.flush()
if close_fobj:
fobj.close()
@@ -1618,6 +1620,7 @@ def restore_all_with_distname(filename, distname, primary, archive=True,
hdrlet.apply_as_alternate(fobj, attach=False,
wcsname=hdrlet[0].header['wcsname'])
+ utils.updateNEXTENDKw(fobj)
fobj.flush()
if close_fobj:
fobj.close()
@@ -1743,6 +1746,7 @@ def archive_as_headerlet(filename, hdrname, sciext='SCI',
fobj.append(hlt_hdu)
+ utils.updateNEXTENDKw(fobj)
fobj.flush()
else:
message = """
@@ -2051,6 +2055,7 @@ class Headerlet(pyfits.HDUList):
if attach:
# Finally, append an HDU for this headerlet
self.attach_to_file(fobj)
+ utils.updateNEXTENDKw(fobj)
if close_dest:
fobj.close()
@@ -2143,6 +2148,7 @@ class Headerlet(pyfits.HDUList):
if attach:
self.attach_to_file(fobj)
+ utils.updateNEXTENDKw(fobj)
if close_dest:
fobj.close()
@@ -2176,6 +2182,7 @@ class Headerlet(pyfits.HDUList):
new_hlt = HeaderletHDU.fromheaderlet(self)
new_hlt.header.update('extver', numhlt + 1)
fobj.append(new_hlt)
+ utils.updateNEXTENDKw(fobj)
else:
message = "Headerlet %s cannot be attached to" % (self.hdrname)
message += "observation %s" % (fname)
@@ -2310,7 +2317,7 @@ class Headerlet(pyfits.HDUList):
Distortion model in headerlet not the same as destination model
Headerlet model : %s
Destination model: %s
- """ % (self[0].header['DISTNAME'], dname)
+ """ % (self[0].header['DISTNAME'], dmodel)
logger.critical(message)
return False
else:
diff --git a/lib/stwcs/wcsutil/wcscorr.py b/lib/stwcs/wcsutil/wcscorr.py
index ac2484b..af04591 100644
--- a/lib/stwcs/wcsutil/wcscorr.py
+++ b/lib/stwcs/wcsutil/wcscorr.py
@@ -175,6 +175,8 @@ def init_wcscorr(input, force=False):
# force an update now
# set the verify flag to 'warn' so that it will always succeed, but still
# tell the user if PyFITS detects any problems with the file as a whole
+ utils.updateNEXTENDKw(fimg)
+
fimg.flush('warn')
if need_to_close:
@@ -470,6 +472,8 @@ def restore_file_from_wcscorr(image, id='OPUS', wcskey=''):
pkey = key[:7]+wcskey
fimg[0].header.update(pkey,wcs_table.data.field(key)[erow])
+ utils.updateNEXTENDKw(fimg)
+
# close the image now that the update has been completed.
if close_image:
fimg.close()