diff options
author | hack <hack@stsci.edu> | 2011-11-07 10:36:24 -0500 |
---|---|---|
committer | hack <hack@stsci.edu> | 2011-11-07 10:36:24 -0500 |
commit | d372728784f465dcd451fe9b690f8574f7ec77c2 (patch) | |
tree | f107bb7b4e8bf0fca52f690c7e7509a994db5f25 /lib/stwcs/wcsutil/headerlet.py | |
parent | e847331eced5109044af072a36921a9f776f5ded (diff) | |
download | stwcs_hcf-d372728784f465dcd451fe9b690f8574f7ec77c2.tar.gz |
This revision fixes a number of bugs; including:
- added a check to 'output' par value in TEAL interface to 'write_headerlet'
- implemented use of 'parseinput' in TEAL interface for 'write_headerlet'
- moved 'output' and 'clobber' parameters closer to top of par list in TEAL interface for 'write_headerlet'
- implemented use of 'parseinput' to interpret input filename(s) for 'write_headerlet' and 'extract_headerlet' providing support for additional input modes
- fixed logic problems with defining output filename in 'write_headerlet' and 'extract_headerlet'
git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci_python/trunk/stwcs@13964 fe389314-cf27-0410-b35b-8c050e845b92
Diffstat (limited to 'lib/stwcs/wcsutil/headerlet.py')
-rw-r--r-- | lib/stwcs/wcsutil/headerlet.py | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/lib/stwcs/wcsutil/headerlet.py b/lib/stwcs/wcsutil/headerlet.py index b7f0e29..0e15102 100644 --- a/lib/stwcs/wcsutil/headerlet.py +++ b/lib/stwcs/wcsutil/headerlet.py @@ -21,6 +21,7 @@ from stwcs.updatewcs import utils from stsci.tools.fileutil import countExtn from stsci.tools import fileutil as fu +from stsci.tools import parseinput #### Logging support functions module_logger = logging.getLogger('headerlet') @@ -577,8 +578,11 @@ def extract_headerlet(filename, output, extnum=None, hdrname=None, """ initLogging('extract_headerlet', verbose=verbose) - if isinstance(filename, pyfits.HDUList) or isinstance(filename,str): + if isinstance(filename, pyfits.HDUList): filename = [filename] + else: + filename,oname = parseinput.parseinput(filename) + for f in filename: fobj,fname,close_fobj = parseFilename(f) frootname = fu.buildNewRootname(fname) @@ -594,6 +598,9 @@ def extract_headerlet(filename, output, extnum=None, hdrname=None, hdrlet = hdrhdu.headerlet + if output is None: + output = frootname + if '.fits' in output: outname = output else: @@ -691,11 +698,11 @@ def write_headerlet(filename, hdrname, output=None, sciext='SCI', """ initLogging('write_headerlet') - if isinstance(filename, str) or isinstance(filename, pyfits.HDUList): - if ',' in filename: # string of comma-separated filenames - filename = filename.split(',') - else: - filename = [filename] + if isinstance(filename, pyfits.HDUList): + filename = [filename] + else: + filename,oname = parseinput.parseinput(filename) + for f in filename: if isinstance(f,str): fname = f @@ -777,9 +784,11 @@ def write_headerlet(filename, hdrname, output=None, sciext='SCI', frootname = fu.buildNewRootname(fname) if output is None: # Generate default filename for headerlet FITS file - outname = frootname - if '.fits' not in output: - outname = frootname+'_'+output+'_hlet.fits' + outname = '%s_hlet.fits'%(frootname) + else: + outname = output + if '.fits' not in outname: + outname = '%s_%s_hlet.fits'%(frootname,outname) # If user specifies an output filename for headerlet, write it out write_hdrlet = True |