Table Of Contents

Previous topic

MAKEWCS

Next topic

Association File Interpretation

This Page

Conversion Utilities

Convertwaiveredfits

convertwaiveredfits: Convert a waivered FITS file to various other formats.

License:
 http://www.stsci.edu/resources/software_hardware/pyraf/LICENSE
Syntax From the command line:
 convertwaiveredfits.py [-hm] [-o <outputFileName>,...] FILE ...

Convert the waivered FITS files (FILEs) to various formats. The default conversion format is multi-extension FITS.

Options:
 
-h, --help print this help message and exit
-v, --verbose turn on verbose output
-m, --multiExtensionConversion
 convert to multi-extension FITS format (Default)
-o, --outputFileName
 comma separated list of output file specifications one per input FILE Default: input file specification with the last character of the base name changed to h in multi-extension FITS format

Examples

Conversion of a WFPC2 waivered FITS file obtained from the HST archive:

convertwaiveredfits u9zh010bm_c0f.fits 

This will convert the waivered FITS file u9zh010bm_c0f.fits to multi-extension FITS format and generate the output file u9zh010bm_c0h.fits.

Conversion of multiple FITS files can be done using:

convertwaiveredfits -o out1.fits,out2.fits
                     u9zh010bm_c0f.fits u9zh010bm_c1f.fits

This will convert the waivered FITS files u9zh010bm_c0f.fits and u9zh010bm_c1f.fits to multi-extension FITS format and generate the output files out1.fits and out2.fits

Python Syntax:
 

You can run this code interactively from within Python using the syntax:

>>> from pytools import convertwaiveredfits
>>> fobj = convertwaiveredfits.convertwaiveredfits(waiveredObject, 
>>>                    outputFileName=None, 
>>>                    forceFileOutput=False, 
>>>                    convertTo='multiExtension', 
>>>                    verbose=False)

The returned object fobj is a PyFITS object using the multi-extension FITS format.

Parameters

waiveredObject: obj
input object representing a waivered FITS file; either a pyfits.HDUList object, a file object, or a file specification
outputFileName : string
file specification for the output file Default: None - do not generate an output file
forceFileOutput: boolean

force the generation of an output file when the outputFileName parameter is None; the output file specification will be the same as the input file specification with the last character of the base name replaced with the character h in multi-extension FITS format.

Default: False

convertTo: string
target conversion type Default: ‘multiExtension’
verbose: boolean
provide verbose output Default: False

Returns

hduList
pyfits.HDUList (PyFITS multi-extension FITS object) containing converted output

Examples

>>> import convertwaiveredfits
>>> hdulist = convertwaiveredfits.convertwaiveredfits('u9zh010bm_c0f.fits',
                                         forceFileOutput=True)

this will convert the waivered FITS file u9zh010bm_c0f.fits to multi-extension FITS format and write the output to the file u9zh010bm_c0h.fits; the returned HDUList is in multi-extension FITS format

>>> import convertwaiveredfits
>>> inFile = open('u9zh010bm_c0f.fits',mode='rb')
>>> hdulist = convertwaiveredfits.convertwaiveredfits(inFile,
                                                  'out.fits')

this will convert the waivered FITS file u9zh010bm_c0f.fits to multi-extension FITS format and write the output to the file out.fits; the returned HDUList is in multi-extension FITS format

>>> import pyfits
>>> import convertwaiveredfits
>>> inHdul = pyfits.open('u9zh010bm_c0f.fits')
>>> hdulist = convertwaiveredfits.convertwaiveredfits(inHdul)

this will convert the waivered FITS file u9zh010bm_c0f.fits to multi-extension FITS format; no output file is generated; the returned HDUList is in multi-extension format

pytools.convertwaiveredfits.convertwaiveredfits(waiveredObject, outputFileName=None, forceFileOutput=False, convertTo='multiExtension', verbose=False)

Convert the input waivered FITS object to various formats. The default conversion format is multi-extension FITS. Generate an output file in the desired format if requested.

Parameters:

waiveredObject input object representing a waivered FITS file;
either a pyfits.HDUList object, a file object, or a file specification
outputFileName file specification for the output file
Default: None - do not generate an output file
forceFileOutput force the generation of an output file when the

outputFileName parameter is None; the output file specification will be the same as the input file specification with the last character of the base name replaced with the character h in multi-extension FITS format.

Default: False

convertTo target conversion type
Default: ‘multiExtension’
verbose provide verbose output
Default: False

Returns:

hdul an HDUList object in the requested format.

Exceptions:

ValueError Conversion type is unknown
pytools.convertwaiveredfits.main()
pytools.convertwaiveredfits.toMultiExtensionFits(waiveredObject, multiExtensionFileName=None, forceFileOutput=False, verbose=False)

Convert the input waivered FITS object to a multi-extension FITS HDUList object. Generate an output multi-extension FITS file if requested.

Parameters:

waiveredObject input object representing a waivered FITS file;
either a pyfits.HDUList object, a file object, or a file specification
outputFileName file specification for the output file
Default: None - do not generate an output file
forceFileOutput force the generation of an output file when the
outputFileName parameter is None; the output file specification will be the same as the input file specification with the last character of the base name replaced with the character ‘h’. Default: False
verbose provide verbose output
Default: False

Returns:

mhdul an HDUList object in multi-extension FITS format.

Exceptions:

TypeError Input object is not a HDUList, a file object or a
file name

ReadGEIS

readgeis: Read GEIS file and convert it to a FITS extension file.

License: http://www.stsci.edu/resources/software_hardware/pyraf/LICENSE

Usage:

readgeis.py [options] GEISname FITSname

GEISname is the input GEIS file in GEIS format, and FITSname is the output file in FITS format. GEISname can be a directory name. In this case, it will try to use all *.??h files as input file names.

If FITSname is omitted or is a directory name, this task will try to construct the output names from the input names, i.e.:

abc.xyh will have an output name of abc_xyf.fits

Options:
 
-h print the help (this text)
Example:
 

If used in Pythons script, a user can, e. g.:

>>> import readgeis
>>> hdulist = readgeis.readgeis(GEISFileName)
(do whatever with hdulist)
>>> hdulist.writeto(FITSFileName)

The most basic usage from the command line:

readgeis.py test1.hhh test1.fits

This command will convert the input GEIS file test1.hhh to a FITS file test1.fits.

From the command line:

readgeis.py .

this will convert all *.??h files in the current directory to FITS files (of corresponding names) and write them in the current directory.

Another example of usage from the command line:

readgeis.py "u*" "*"

this will convert all u*.??h files in the current directory to FITS files (of corresponding names) and write them in the current directory. Note that when using wild cards, it is necessary to put them in quotes.

pytools.readgeis.parse_path(f1, f2)

Parse two input arguments and return two lists of file names

pytools.readgeis.readgeis(input)

Input GEIS files “input” will be read and a HDUList object will be returned.

The user can use the writeto method to write the HDUList object to a FITS file.

pytools.readgeis.stsci(hdulist)

For STScI GEIS files, need to do extra steps.

pytools.readgeis.stsci2(hdulist, filename)

For STScI GEIS files, need to do extra steps.

Check_files

The check_files module provides functions to perform verification of input file formats for use in betadrizzle. This set of functions also includes format conversion functions to convert GEIS or waiver-FITS HST images into multi-extension FITS (MEF) files.

pytools.check_files.checkFiles(filelist, ivmlist=None)
  • Converts waiver fits sciece and data quality files to MEF format
  • Converts GEIS science and data quality files to MEF format
  • Checks for stis association tables and splits them into single imsets
  • Removes files with EXPTIME=0 and the corresponding ivm files
  • Removes files with NGOODPIX == 0 (to exclude saturated images)
  • Removes files with missing PA_V3 keyword

The list of science files should match the list of ivm files at the end.

pytools.check_files.checkNGOODPIX(filelist)

Only for ACS, and STIS, check NGOODPIX If all pixels are ‘bad’ on all chips, exclude this image from further processing. Similar checks requiring comparing ‘driz_sep_bits’ against WFPC2 c1f.fits arrays and NICMOS DQ arrays will need to be done separately (and later).

pytools.check_files.checkPA_V3(fnames)
pytools.check_files.checkPhotKeywords(filelist)

Insure that the SCI headers contains all the necessary photometry keywords, moving them into the extension header if necessary. This only moves keywords from the PRIMARY header if the keywords do not already exist in the SCI header.

pytools.check_files.checkStisFiles(filelist, ivmlist=None)
pytools.check_files.check_exptime(filelist)

Removes files with EXPTIME==0 from filelist.

pytools.check_files.convert2fits(sci_ivm)

Checks if a file is in WAIVER of GEIS format and converts it to MEF

pytools.check_files.countInput(input)
pytools.check_files.geis2mef(sciname, convert_dq=True)

Converts a GEIS science file and its corresponding data quality file (if present) to MEF format Writes out both files to disk. Returns the new name of the science image.

pytools.check_files.isSTISSpectroscopic(fname)
pytools.check_files.splitStis(stisfile, sci_count)
Purpose :
 Split a STIS association file into multiple imset MEF files.

Split the corresponding spt file if present into single spt files. If an spt file can’t be split or is missing a Warning is printed.

Returns :
 

names: list :

a list with the names of the new flt files.

pytools.check_files.stisExt2PrimKw(stisfiles)

Several kw which are usuall yin the primary header are in the extension header for STIS. They are copied to the primary header for convenience. List if kw: ‘DATE-OBS’, ‘EXPEND’, ‘EXPSTART’, ‘EXPTIME’

pytools.check_files.stisObsCount(input)

Input: A stis multiextension file Output: Number of stis science extensions in input

pytools.check_files.update_input(filelist, ivmlist=None, removed_files=None)

Removes files flagged to be removed from the input filelist. Removes the corresponding ivm files if present.

pytools.check_files.waiver2mef(sciname, newname=None, convert_dq=True)

Converts a GEIS science file and its corresponding data quality file (if present) to MEF format Writes out both files to disk. Returns the new name of the science image.