next up previous contents FITSIO Home
Next: 1.4 Basic Conventions used Up: 1. Introduction to FITSIO Previous: 1.2 Sources of information   Contents

1.3 A FITS Primer

This section gives a brief overview of the structure of FITS files. Users should refer to the extensive documentation available from the NOST, as described above, for more detailed information on FITS formats.

A FITS file consists of one or more Header + Data Units (HDUs), where the first required HDU is called the Primary HDU, or Primary Array. Other optional HDUs may follow the primary, and are called Extensions. There are currently 4 common types of HDUs:

In every case the HDU consists of an ASCII Header Unit followed by an optional Data Unit. For historical reasons, each Header or Data unit must be an exact multiple of 2880 8-bit bytes long. Any unused space is padded with fill characters (ASCII blanks or NULs depending on the type of unit).

Each Header Unit consists of any number of 80-character keyword `card images' which have the general form:

   KEYNAME =  value  / comment string

The keyword names are a maximum of 8 characters long, and only uppercase letters, the digits 0-9, the hyphen, and the underscore character are allowed. The keyword name is (usually) followed by an equal sign and a space character in columns 9 - 10 of the record, followed by the value of the keyword which may be either an integer, a floating point number, a character string (enclosed in single quotes), or a boolian value (T or F). There are many rules governing the exact format of a keyword record (see the NOST FITS Standard) so it is better to rely on standard interface software like FITSIO to correctly construct or to parse the keyword records rather than try to deal with them from scratch. The last keyword in the header is always the `END' keyword, with no value or comment fields.

Each Header Unit begins with a number of required keywords, depending on the type of Extension. These required keywords specify the size and format of the following Data Unit. Other optional keywords may be provided to describe other aspects of the data, such as the units or scaling values. Other COMMENT or HISTORY keywords may also be added to further document the data file.

The optional Data Unit immediately follows the last 2880-byte block in the Header Unit. Some HDUs do not have a Data Unit and only consist of the Header Unit.

If there is more than one HDU in the FITS file, then the Header Unit of the next HDU immediately follows the last 2880-byte block of the previous Data Unit (or Header Unit if there is no Data Unit).


next up previous contents FITSIO Home
Next: 1.4 Basic Conventions used Up: 1. Introduction to FITSIO Previous: 1.2 Sources of information   Contents