summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordencheva <dencheva@stsci.edu>2011-06-03 14:20:12 -0400
committerdencheva <dencheva@stsci.edu>2011-06-03 14:20:12 -0400
commit52bb48686b1d02c0de422ddf6faa8be8b8c8c78f (patch)
tree1a58eb9c826da9c7506d3d16302c4a1a2bdd006a
parent34d481a4b7572525320db4fbe3eb29a357dc2b56 (diff)
downloadstwcs_hcf-52bb48686b1d02c0de422ddf6faa8be8b8c8c78f.tar.gz
Added a boolena keyword parameter 'createsummary' to Headerlet.apply to allow applying a headerlet without creating and updating a wcscorr table. May be useful not only for testing ...
git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci_python/trunk/stwcs@13051 fe389314-cf27-0410-b35b-8c050e845b92
-rw-r--r--wcsutil/headerlet.py25
1 files changed, 15 insertions, 10 deletions
diff --git a/wcsutil/headerlet.py b/wcsutil/headerlet.py
index f4c4691..856be86 100644
--- a/wcsutil/headerlet.py
+++ b/wcsutil/headerlet.py
@@ -427,7 +427,7 @@ class Headerlet(pyfits.HDUList):
self.d2imerr = 0
self.axiscorr = 1
- def apply(self, dest, createheaderlet=True, hdrname=None, attach=True):
+ def apply(self, dest, createheaderlet=True, hdrname=None, attach=True, createsummary=True):
"""
Apply this headerlet to a file.
@@ -444,6 +444,9 @@ class Headerlet(pyfits.HDUList):
By default the headerlet being applied will be attached
as an extension to the science file. Set 'attach' to False
to disable this.
+ createsummary: boolean, default: True
+ Set this to False to disable creating and updating of wcscorr table.
+ This is used primarily for testing.
"""
self.hverify()
if self.verify_dest(dest):
@@ -456,14 +459,15 @@ class Headerlet(pyfits.HDUList):
# Create the WCSCORR HDU/table from the existing WCS keywords if
# necessary
- try:
- # TODO: in the pyfits refactoring branch if will be easier to
- # test whether an HDUList contains a certain extension HDU
- # without relying on try/except
- wcscorr_table = fobj['WCSCORR']
- except KeyError:
- # The WCSCORR table needs to be created
- wcscorr.init_wcscorr(fobj)
+ if createsummary:
+ try:
+ # TODO: in the pyfits refactoring branch if will be easier to
+ # test whether an HDUList contains a certain extension HDU
+ # without relying on try/except
+ wcscorr_table = fobj['WCSCORR']
+ except KeyError:
+ # The WCSCORR table needs to be created
+ wcscorr.init_wcscorr(fobj)
orig_hlt_hdu = None
numhlt = countExtn(fobj, 'HDRLET')
@@ -515,7 +519,8 @@ class Headerlet(pyfits.HDUList):
fobj.append(self[('D2IMARR', idx)].copy())
# Update the WCSCORR table with new rows from the headerlet's WCSs
- wcscorr.update_wcscorr(fobj, self, 'SIPWCS')
+ if createsummary:
+ wcscorr.update_wcscorr(fobj, self, 'SIPWCS')
# Append the original headerlet
if createheaderlet and orig_hlt_hdu: