FTOOLS and HEADAS Filename Syntax

All of the ftools and HEADAS tasks support CFITSIO's extended file name syntax when specifying the names of input or output data files. The first section of this document describes the features of the syntax when specifying the name of a new data file that is to be created by a task, and the second section describes the features of the file syntax that apply when opening an existing data file.

A. WHEN CREATING A NEW FILE

1. Overwriting, or 'Clobbering' an Existing File

Most tasks will exit with an error if asked to create a new file that already exists, unless one of the following conditions is met:
 

2. Compressed Output Files

To save disk space, the output data file may be written in a compressed format. Two different types of compression algorithms are supported:
 

3. Using a Template to Create a New FITS File

The structure of any new FITS file that is to be created may be defined in an ASCII template file. If the name of the template file is appended to the name of the FITS file itself, enclosed in parenthesis (e.g., 'newfile.fits(template.txt)' ) then CFITSIO will create a FITS file with that structure before opening it for the application to use. The template file basically defines the dimensions and data type of the primary array and any IMAGE extensions, and the names and data types of the columns in any ASCII or binary table extensions. The template file can also be used to define any optional keywords that should be written in any of the HDU headers. The image pixel values and table entry values are all initialized to zero. The application program can then write actual data into the HDUs. See the 'template' help file for a complete description of the template file syntax.

Applications programs usually must be specifically designed to support the use templates when creating new FITS files. Most of the existing ftools and HEADAS tasks do not support templates. One exception, however, is the fttemplate (or ftemplate) task which uses a template to create a new file.

4. Creating a Temporary Scratch File in Memory

It is sometimes useful to create a temporary output file when testing an application program. If the name of the file to be created is specified as "mem:" or "mem://" then CFITSIO will create the file in memory where it will persist only until the program closes the file. Use of this "mem:" output file usually enables the program to run faster, and of course the output file does not use up any disk space.

B. WHEN OPENING AN EXISTING FILE

1. Basic Types of Input Data Files

The following types of data files may be opened by any ftools or HEADAS task:
 

2. Extension Specifier

In many cases the ftools or HEADAS application program must be told which particular extension (also known as 'HDU') within the input data file that should be opened and operated on. This is done by specifying the extension name (as given by the EXTNAME or HDUNAME header keyword) or the extension number (where the primary array is number 0) in square brackets following the file name (e.g., 'myfile.fits[events]' means open the 'EVENTS' extension, or 'myfile.fits[1]' means open the first extension following the primary array in the file). Alternatively, one may specify the extension number following a 'plus sign' (e.g., 'myfile.fits+1'). One can also specify the 'version' number of the desired extension and the type of extension (Image, Binary table, or ASCII table) to uniquely identify the HDU, if more than on HDU in the file has the same EXTNAME value (e.g., 'myfile.fits[events,2,binary]'). The extension type my be abbreviated with the letters 'i', 'b', or 'a'.

If an explicit extension name or number is not specified as part of the input file name then many of the newer ftools and HEADAS tools will automatically attempt to open the first 'interesting' table or image in the FITS file. If the application is expecting to open a FITS table, then it will move to the first table extension in the file that is not a Good Time Interval (GTI) table. If the application is expecting to open an image, it will open the first image HDU that it finds that is not a null image (with zero dimensions). Some of the older ftools tasks were not designed to use this feature, and hence will simply open the primary array in the input file if no extension is specified.

3. Virtual File Filtering

A variety of different types of filtering operations may be specified when opening a file. CFITSIO performs the filtering operations and creates a virtual file (usually in memory) which the application program then reads. The filtering specifications are appended to the root file name and enclosed in square brackets. These filters provide very powerful data manipulation and editing capabilities to all of the ftools and HEADAS tasks.

The virtual file filters are described in the following separate help files:

EXAMPLES

When creating a new output file:

When opening an existing file:

SEE ALSO

imfilter, pixfilter, colfilter, rowfilter, binfilter, calc_express, tilecompression