TN 0004: FITS file format for TASS images

Author: Jure Skvarc
Address: jure.skvarc@ijs.si
Date: 951102
Revision: #0 
Keywords: FITS, image

This is a description of the FITS file format for TASS images. It is based on a description of FITS file format found in [1] and on a debate which was going on in TASS discussion group [2]. Note that the FITS file header presented here is an example of keywords and not of their values, except for few keywords which describe the structure of the file and for which these values should be accepted.

GENERAL INFORMATION ABOUT FITS FILE FORMAT

FITS stands for Flexible Image Transport System and was developed by astronomers for an easy exchange of the astronomical data regardless of the computer hardware and the operating system used by parties which exchange this data. By data we mostly mean images made by different astronomical instruments such as optical and radio telescopes, spectrometers, etc. However, it is possible to include any data in other formats, such as different tables.

FITS file consists of one or more of so-called HDU's (Header and Data Units). In the header there is a description of the content which follows it. The header consists of a number of lines of ASCII text formatted by specific rules. First eight characters define a keyword. If the keyword is less than eight characters long it is followed by spaces up to 8th character in the line. Then follows '=' character and then the value of the keyword. Value can be numerical (integer or floating point), logical (T or F) or character string contained in ''. Numerical and logical values must end in column 30 of the line. After the value there can be a comment. The lenght of each line is exactly 80 characters. Due to historical reasons (connected to block sizes of digital tapes in the late 70's) the total header length must be multiple of 2880 bytes. If we run out of keywords before that, the remainder is padded by space characters.

The number of keywords in a header is arbitrary and most of them can be in any order. There is only a small set of required keywords which must exist in every FITS file. Although users can define their own keywords, there exists a number of reserved keywords which already have defined meaning and should not be used for other purposes.

After the header come actual data in a format defined by the header. They usually represent an image which can be coded in either integer or floating point format.

READING AND WRITING OF FITS FILES

It is not difficult to read and write simple FITS files, especially if they are exchanged only in a limited circle of users. However, for real flexibility it is advisible to use a FITSIO library [3]. It can be found by WWW at http://heasarc.gsfc.nasa.gov/docs/software/fitsio/fitsio.html

or ftp at ftp://legacy.gsfc.nasa.gov/software/fitsio

This package can be compiled for UNIX, VMS, MAC and DOS computers and needs a Fortran or an f2c compiler.

TASS FITS IMAGE FILES

By TASS image files we define files which contain already processed images of a single camera. Dimensions of the image should be 'reasonable' for handling by computers typically owned by amateurs (at the end of 1995). In practice, this means that there should not be more than one million pixels per image. As the depth of pixel is 16 bits, this would mean file size of 2 MB. Files have three HDUs - the first contains the image with a subtracted dark image and with flat field correction. Keywords in the first HDU are divided into two sections: One required for the TASS project and the other which contains useful information which is not crucial for the further evaluation of the image. The second HDU contains an image extension with dark frame and in the third there is a flat field. Both are here only for information since the image is already corrected. In the present hardware design we have a drift scan device and therefore it suffices to have only one line of information for dark frame and flat field. For some future design it may be necessary to have full-size flat and dark fields.

DESCRIPTION OF KEYWORDS

SIMPLE - This is a required keyword and it must have a value of T, otherwise the file is not considered to be a FITS file.

BITPIX - Required keyword, according to resolution of the A/D converter the value should be 16.

NAXIS - Required keyword, the value is 2

NAXISn - where n is 1 or 2, are also required keywords. Their values will depend on the resolution of the CCD chip.

CTYPEn - Name of the physical coordinate, in the drift scan mode it will always be declination ('DEC') for n = 1 and right ascension ('RA') for n = 2.

CRPIXn - Location of the reference pixel along axis n. In principle it can have any value (even negative or fractional) but it is wise to use the value of 1 for both coordinates.

CRVALn - The value (coordinate) of the reference pixel in decimal degrees for both axis.

CDELTn - Difference of coordinate values between reference pixel and its neighbour.

CROTAn - Rotation of coordinate axis of the image from the actual coordinate axis used in CTYPEn keyword. It should be 0.0.

BSCALE - Scale factor between values in a FITS file and actual values. This value should be 1.0.

BZERO - Offset value for conversion from FITS file and true values. The formula is

	true = (FITS value) * BSCALE + BZERO.  
Value of BZERO will probably be 32768.

OBJECT - Coordinates of the first pixel of the image. This is the same information as in CVAL1 and CVAL2. See the example for format.

SIZE - Size of the image. See the example.

DATE-OBS - Date of the start of aqusition.

TIME - Time of the start of acquisition.

EXPOSURE - Exposure time in seconds.

LATITUDE, LONGITUD - Coordinates of the observing site. This may be quite important in a case of detection of some object which is near Earth.

EQUINOX - Epoch used for calculation of star coordinates. It should be 2000.0.

EXTEND - This keyword (with value T) is necessary in files which have extensions.

COMMENT, HISTORY - In FITS header, it is possible to have a number of comments and also description in some human language how was the file produced. These two keywords serve for this purpose. There is no need to use '=' character after them.

CCD_TEMP, TEMPERAT, PRESSURE, HUMIDITY, TELESCOP, INSTRUME, OBSERVER, ADDRESSn, EMAIL, PHONE and FAX are optional keywords which meanings is easy to guess. Also, see the example.

END - A required keyword. It must be present as the last keyword of every header and has no '=' character in 9th column.

XTENSION - This is a required keyword for the extension. Its value for dark and flat fields will be 'IMAGE'.

REFERENCES

[1] A User's Guide for the Flexible Image Transport System (FITS), version 3.1, NASA/Science Office of Standards and Technology, Code 633.2, NASA Goddard Space Flight Center, Greenbelt MD 20771, USA.

[2] Thanks to Chris Albertson and Norman Molhant for constructive suggestions in developing the FITS header for TASS project.

[3] FITSIO User's Guide - A Subroutine Interface to FITS Format Files, W.H. Pence, HEASARC, Code 668, Goddard Space Flight Center, Greenbelt MD 20771, USA.

AN EXAMPLE

Finally, here is an example of the FITS file header which should be used in TASS project for image files. Actual header begins with the line with keyword SIMPLE. Two lines with numbers are here just for the orientation.

0000000001111111111222222222233333333334444444444555555555566666666667777777777
1234567890123456789012345678901234567890123456789012345678901234567890123456789

SIMPLE  =                    T /  We have simple FITS format
BITPIX  =                   16 /  Number of bits per pixel
NAXIS   =                    2 /  2 D image
NAXIS1  =                  768 /  Physical coordinates of the chip
NAXIS2  =                  512 /         -  "  -
CTYPE1  = 'DEC'                / declination
CRPIX1  =                  1.0 / first pixel
CRVAL1  =          54.00116667 / 54 degrees 00 minutes 42 seconds
CDELT1  =            0.0038197 / arctan (9 um / 135 mm) in decimal degrees
CROTA1  =                  0.0 / no rotation
CTYPE2  = 'RA'                 / right ascension
CRPIX2  =                  1.0 / first exposed line
CRVAL2  =         16.270833333 / 01h05m05s in decimal degrees
CDELT2  =            0.0038197 / arctan (9 um / 135 mm) in decimal degrees
CROTA2  =                  0.0 / no rotation
BSCALE  =                  1.0 /
BZERO   =	       32768.0 / Maybe even 0 would be enough ?
OBJECT  = '01h05m05s+54d00m42s'/  Coordinates of the first pixel of the image
SIZE    = '2.8x3.2        '    /  Size of image in degrees
DATE-OBS= '13/01/96'           /
TIME    = '02:07:15'           /  Start of acquisition
EXPOSURE=                300.0 /  Duration of exposure
LATITUDE=               +46.00 /  Latitude of the location of the observing site 
LONGITUD=               -14.50 /  Longitude (both in decimal degrees)    
EQUINOX =               2000.0 /
EXTEND  =                    T /  We have also an extension
COMMENT  
COMMENT  Next come optional keywords
COMMENT  
CCD_TEMP=                253.0 /  CCD temperature: it should be in Kelvins
TEMPERAT=                283.2 /  Temperature of the air
PRESSURE=                100.0 /  Unit could be kPa
HUMIDITY=                 72.0 /  In percents
TELESCOP= 'Objective name/spec'/
INSTRUME= 'TASS camera'        /
OBSERVER= 'John Smith'         /
ADDRESS1= '    '               / 
ADDRESS2= '    '               / 
ADDRESS3= '    '               / 
ADDRESS4= '    '               / 
EMAIL   = '    '               /
PHONE   = '    '               /
FAX     = '    '               /
HISTORY  Description how
HISTORY  was this file
HISTORY  produced
COMMENT     We can also include an   
COMMENT     arbitrary number of other comments
COMMENT             ...
END

...  Here comes the corrected, flat-fielded image
...
...  On a location within file which is multiple of 2880 bytes we have an extension:

XTENSION= 'IMAGE'              /  So this is an image extension
BITPIX  =                   16 /  Number of bits is the same as before
NAXIS   =                    2 /
NAXIS1  =                  768 /  
NAXIS2  =                    1 /  
COMMENT Line in this extension is the dark line
END
...  dark line

XTENSION= 'IMAGE'              /  
BITPIX  =                   16 /  
NAXIS   =                    2 /
NAXIS1  =                  768 /  
NAXIS2  =                    1 /  
COMMENT Line in this extension is the flat line
END
...  flat line