STScI Logo

COS
trl.py

Download trl.py

trl.py is a Python program to read one or more trailer files in FITS format and write the text to corresponding ASCII files.

The source file trl.py can be executed from the Unix command line, or it can be imported in a Python session. To run it from Unix, specify one or more trailer file names on the command line. Command-line arguments "-v" (verbose) and "-q" (quiet) may be given, preceding any trailer file name. The names may be given explicitly, or a wildcard may be used. If a name with a wildcard is enclosed in quotes, the wildcard will be expanded by trl.py; if quotes are not used, the wildcard will be expanded by Unix, generating a possibly long command line. The disadvantage of letting Unix expand the name is that the resulting command line may exceed the limit allowed by the operating system.

To run this program from Python, import trl and execute convertToAscii for each trailer file to be converted, e.g.:

% python
import trl
trl.convertToAscii("labq01i5q_trl.fits", "labq01i5q.tra")

When executing trl.py from Unix, the name of an input FITS file is expected to be of the form rootname_trl.fits, and the name of the output ASCII file will be rootname.tra. The input file name may include a directory (but not using an environment variable), and the output will be written to the same directory. When running from a Python session, the input and output file names are given explicitly and do not have to follow that pattern, and the input and output names may include different directory names.

If trl.py is downloaded from the COS web site, the file may not have execute permission by default. In order to execute the file from the Unix command line, you can change the permission explicitly, e.g. chmod 755 trl.py.

Download trl.py