IRAF Newsletter -- Number 14 -- April 1998

[ Previous ] [ Next ] [ Table of Contents ] [ Search this issue ]

IRAF FITS Image Kernel

IRAF has a facility called the "image kernel" which permits the high level imaging applications and the image i/o subsystem to access images of various actual types. The image kernel knows how to access an externally defined image type and provides methods for directly accessing such images within IRAF at runtime.

The IRAF FITS image kernel, now available within IRAF V2.11, allows applications that read and write images to directly access FITS image files. IRAF will read, modify, or create images in standard FITS format, operating upon either simple FITS files or individual images within multi-extension format FITS files (multiple images within the same file).

A FITS file consists of one or more FITS Units. A Unit is defined as either a Primary Header Unit (PHU or primary unit) or an Extension Header Unit (EHU or simply extension). A FITS file consists of a PHU and zero or more extensions. A FITS Unit always includes a header but may or may not include any data following the header. FITS potentially supports many different types of extensions. The FITS image kernel supports FITS multiple extension format (MEF) files but will handle only primary units or image extensions. Support for FITS tables within IRAF is provided by the TABLES external package from STScI, which supports both TABLE and BINTABLE extensions. Generic tools for handling FITS extensions within IRAF are available in the FTOOLS external package from HEASARC.

Accessing simple FITS images on disk is straightforward, and the syntax used is the same as for .imh files. But accessing MEF files is a bit more involved since there are multiple FITS images in each MEF file. The general syntax looks like


where any or all of the bracketed fields are optional.

The "root" part of the filename is the only part required to access a FITS image. The "extn" field is the file extension with a default value of "fits". Arbitrary FITS extensions consisting of 2 to 4 alphanumeric characters are permitted by modifying the IRAF environment variable "imextn", as in the example below (see an accompanying article in this Newsletter for more information about "imextn" and the related "imtype" environment variable).

The "extension_number" term needs to be specified if you want to access a particular image within the MEF file (if you don't specify which image you want to access it is an error). The brackets are required, and the numbering is zero for the PHU, 1 for the first extension, 2 for the second extension and so on. If the MEF file follows the recommended IRAF convention of a dataless PHU containing only header data and the first few extensions are images, then the images will be extensions "[1]", "[2]", "[3]", and so on.

The "kernel_section" term consists of a comma-delimited sequence of "keyword" or "keyword=value" fields used to control how the specified extension is processed. A couple of important examples are "extname" and "extver": these parameters can be used to select individual image extensions by the value of the EXTNAME and EXTVER keywords in the FITS extension headers. If a kernel section is used then it is not necessary to give the "extension_number" field to identify the image extension. For example, to list the header of an image extension with name EXTNAME='spec23' the following command could be entered:

The "image_section" term of the image name is the familiar IRAF image section notation used to specify the section of the image that you wish to process, e.g., "[200:400,222:300]".

The FITS image kernel supports inheritance when dealing with multi-extension FITS files. If the keyword INHERIT=T is in the header of an image extension then (by default) the PHU keywords will be combined with the image extension header keywords when the image is accessed: the header you see will be a combination of the EHU and PHU keywords.

Multi-extension FITS files can be processed by any IRAF task that already supports images, but only one image extension can be processed at a time. For example, to list the headers of several image extensions in the MEF file called `spec' one would type

or one could create a list file "spec.lis" containing

and then enter

to list the headers of all the images listed in file "spec.lis".

Additional tools for manipulating MEF files are available in the external package fitsutil . This package is available in the IRAF network archive on in the iraf/extern directory. The tasks in this package will allow the user to list all the extensions in a MEF file, delete an extension, insert an extension in the middle of an MEF file or extract one or more extensions from an input file and append them to an output MEF file.

The IRAF FITS kernel adheres to the FITS standard as stated in A User's Guide for the Flexible Image Transport System (FITS) from the NASA/Science Office of Standards and Technology (NOST), dated September 29, 1995. This document is accessible via FTP at in the subdirectory fits . Or you can visit the FITS Support Office Web site at . Another very useful source of information on FITS is .

Further details about the FITS image kernel and its implementation in IRAF V2.11 are given in the new FITS Kernel User's Guide which can be found on in the file iraf/docs/ .

Nelson Zarate

[ Previous ] [Next ] [ Table of Contents ] [ Search this issue ]

IRAF Group, National Optical Astronomy Observatories, P.O. Box 26732, Tucson, AZ 85726, Phone: (520) 318-8160, FAX: (520) 318-8360, Email

Posted: 07May1998