diff options
author | embray <embray@stsci.edu> | 2011-04-11 17:14:25 -0400 |
---|---|---|
committer | embray <embray@stsci.edu> | 2011-04-11 17:14:25 -0400 |
commit | bcfef1cb19777e406fa620a497e76fd5096aa7c2 (patch) | |
tree | 397cc549b17d9ca1668a77c09ba4fe854005432d /wcsutil/headerlet.py | |
parent | 04efb06273ad81aa7b8bfe015a610078fe9a9273 (diff) | |
download | stwcs_hcf-bcfef1cb19777e406fa620a497e76fd5096aa7c2.tar.gz |
Fixes `applyHeaderlet` and `Headerlet.apply()` use the hdrname keyword arg
sensibly. It allows users to specify a name for the headerlet generated from
a file, but if hdrname is not specified a sensible default is still used.
Removed support for the destim arg from `applyHeaderlet()`, as it was not used
anywhere.
git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci_python/trunk/stwcs@12446 fe389314-cf27-0410-b35b-8c050e845b92
Diffstat (limited to 'wcsutil/headerlet.py')
-rw-r--r-- | wcsutil/headerlet.py | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/wcsutil/headerlet.py b/wcsutil/headerlet.py index e3804ea..236fb92 100644 --- a/wcsutil/headerlet.py +++ b/wcsutil/headerlet.py @@ -271,8 +271,8 @@ def createHeaderlet(fname, hdrname, destim=None, output=None, verbose=False): fobj.close() return Headerlet(hdul) -def applyHeaderlet(hdrfile, destfile, destim=None, hdrname=None, - createheaderlet=True, verbose=False): +def applyHeaderlet(hdrfile, destfile, createheaderlet=True, hdrname=None, + verbose=False): """ Apply headerlet 'hdrfile' to a science observation 'destfile' @@ -281,20 +281,14 @@ def applyHeaderlet(hdrfile, destfile, destim=None, hdrname=None, hdrfile: string Headerlet file destfile: string - File name of science observation wyhose WCS solution willbe updated - destim: string or None (default) - ROOTNAME of destfile (default) - This string will be written as the DESTIM keyword in the headerlet, - created from the old WCS solution - Normally it should be None, unless the science file is missing the - ROOTNAME kw, in which case the name of the file (stripped of .fits) - should be specified. - hdrname: string or None (default) - will be the value of the HDRNAME keyword in the headerlet. - It's not required if createheaderlet is False + File name of science observation whose WCS solution will be updated createheaderlet: boolean True (default): before updating, create a headerlet with the WCS old solution. + hdrname: string or None (default) + will be the value of the HDRNAME keyword in the headerlet generated + for the old WCS solution. If not specified, a sensible default + will be used. Not required if createheaderlet is False verbose: False or a python logging level (one of 'INFO', 'DEBUG' logging levels) (an integer representing a logging level) @@ -302,8 +296,7 @@ def applyHeaderlet(hdrfile, destfile, destim=None, hdrname=None, logger.info("Starting applyHeaderlet: %s" % time.asctime()) hlet = Headerlet(hdrfile) - hlet.apply(destfile, destim=destim, hdrname=hdrname, - createheaderlet=createheaderlet) + hlet.apply(destfile, createheaderlet=createheaderlet, hdrname=hdrname) def updateRefFiles(source, dest): """ @@ -407,7 +400,7 @@ class Headerlet(pyfits.HDUList): self.d2imerr = 0 self.axiscorr = 1 - def apply(self, dest, createheaderlet=True): + def apply(self, dest, createheaderlet=True, hdrname=None): """ Apply this headerlet to a file. """ @@ -437,7 +430,8 @@ class Headerlet(pyfits.HDUList): # Create a headerlet for the original WCS data in the file, # create an HDU from the original headerlet, and append it to # the file - hdrname = fobj[0].header['ROOTNAME'] + '_orig' + if not hdrname: + hdrname = fobj[0].header['ROOTNAME'] + '_orig' orig_hlt = createHeaderlet(fobj, hdrname) orig_hlt_hdu = HeaderletHDU.fromheaderlet(orig_hlt) |