Thread: Valid Fits File
View Single Post
  #2  
Old May 16th 06, 07:20 PM posted to sci.astro.ccd-imaging
external usenet poster
 
Posts: n/a
Default Valid Fits File

Kiran wrote:
I am looking for the code which creates a valid FITS file.The FITS
file should contain a valid header with header test data. The FITS file
should contain one valid image with a test pattern. This image should
be 128 pixels wide by 64 pixels high. Each pixel should be eight bits.
Pixel values in the first row should begin with 0 and increment by 1.
Pixel values in the second row should begin with 1 and increment by 1.
Pixel values in the third row should begin with 2 and increment by 1.
Etc.


Are you looking for existing code which will create such a file, or do
you want to write your own code using existing code as a guide? If the
latter, what language?

The byte-by-byte format of a FITS file isn't all that difficult to
understand. The length of the entire file is a multiple of 2880 bytes.
The simplest valid files will have a header, also a multiple of 2880
bytes, immediately followed by data, filled with nulls (00 hex or '\0')
at the end to make the data section also a multiple of 2880 bytes.

The header contains a multiple of 36 text lines, each line exactly 80
bytes (yes, 36 x 80 = 2880). Each line contains either
KEYWORD = VALUE
or
COMMENT whatever you want
or just blanks. The equals sign must be in column 9. There may also
be a slash and a comment after the value. The first keyword has to be
SIMPLE = T
After that will come keywords to define the data geometry: 2 dimensions,
128 wide, 64 high, 8 bits per pixel.
NAXIS = 2
NAXIS1 = 128
NAXIS2 = 64
BITPIX = 8

See http://fits.gsfc.nasa.gov/ for more. After that,
END
followed by blank lines to pad it out to 2880 bytes, then the data.

You'll have to make the data array yourself.

-- Bill Owen