FITS Format Definition
A FITS format image consists of a human readable text format "header" followed by binary data for he pixels of the image. The header contains image documentation such as number of rows and columns, the data and time the image was taken, etc. The header is comprised of discrete header records that are each 80 bytes long and contain a specific piece of information such as the number of image rows. There must be an integral number of 80 byte header records in a FITS header, and the total header length must be an integral multiple of 36 records, or 2880 bytes. The END keyword line terminates the header and is followed by blank characters that pad the header to a multiple of 2880 bytes. The pixel data begins on the next 2880 byte boundary after the header. The complete file containing the header and pixel data must be padded with blank characters at its end in order to reach a size that is a multiple of 2880 bytes. These 2880 byte intervals are necessary for storing a FITS image on a blocked medium such as a magnetic tape. FITS also allows super blocks of multiples of 2880 bytes.
Each line of the header is called a header record, and has a length of 80 bytes. In the present documentation, a header record unit is often termed a keyword line. The FITS Standard refers to a header record as a card image, since FITS was developed when keypunched cards were used as a storage medium. A header record consists of the following components:
A keyword, starting in column 1, that identifies the information contained in the header record.
A value, sometimes called the keyword value, beginning in column 10.
An optional slash in column 32 that separates the value from an optional comment.
An optional comment starting in or after column 33 that describes the keyword.
There are other details relating to issues such as the range of columns used for specific types of keyword values, but these will not be addressed here. A typical header record looks similar to the following one:
NAXIS1 = 512 / number of image columns
Beyond the last non-blank character, the remainder of the 80-byte line is padded with blanks (ASCII code 32, or 20 hexadecimal). The format shown in this NAXIS header record is typical of all FITS keyword lines. The keyword name, including spaces, is exactly 8 bytes long and is left justified in the 80-byte header record. An equals sign, =, follows in the 9-th column and an optional slash may be placed in the 32nd column. Between these columns is placed the value of the keyword, in this example, the number 512. Notice that the value 512 is right justified with one blank space before. Right justification to column 30 is required for integer, real, and character keyword values, but is sometimes missed by software authors. Keywords that contain character string data must have a left justified character string enclosed within single quotation marks (') beginning after the ‘=’ sign. The string must also be padded to a minimum length of 8 characters between quotation marks. Character value keywords such as SIMPLE do not use quotation marks, but use a single character such as T (true) or F (false).
Some examples of proper FITS keyword format, omitting comments after the slash, are listed below.
SIMPLE = T NAXIS1 = 512 EXPTIME = 500.0 BSCALE = 1.512E16 / DATE-OBS= '1999-21-05T05:20:45.005' TIME-OBS= '05:20:45.005' / MIRATYPE= 'real ' / OBJECT = 'This string requires quotes.' HISTORY This string uses no quotes. COMMENT This string uses no quotes. |
The NAXIS1 keyword used in the example is an essential FITS keyword because it specifies the image dimension in the direction of the most rapidly varying subscript. The term most rapidly varying subscript is intended for those who write computer programs to read and write FITS format. For a 2-D image, the value of NAXIS1 corresponds to the number of columns in the image, which would be 512 columns in the example. The number of image dimensions is specified using the NAXIS keyword, and this would have a value of either 1 or 2 for MIRA compatible images. If the image has 2 dimensions, there must be an NAXIS2 keyword in the header.
The 5 essential keywords for any FITS format image are SIMPLE, BITPIX, NAXIS, NAXIS1, and END. The first four keywords define a basic image and the END keyword signifies the end of the header. Note that these 5 keywords total only 400 bytes of header. But since headers are padded to a multiple of 2880 bytes, in this case, the pixel data would start at byte offset 2880.