Software sometimes creates images that are labeled as FITS files but do not conform to the FITS standard. Even though images saved in these variant versions of FITS may contain perfectly valid image data, they may differ from the FITS standard sufficiently that software written to read conforming files cannot correctly read the variants.
FITS variants fall into three classes: those with nonconforming headers, those with nonconforming data arrays, and those in which the header and data arrays are not coordinated. Nonconforming headers contain nonstandard keywords or use standard keywords incorrectly. Nonconforming data arrays store data in a non-FITS format, or implement the FITS format incorrectly. Files with uncoordinated headers and data arrays have a conforming header and a conforming data array, but the header does not describe the data array correctly.
The FITS standard allows programmers to create and use new keywords. However, it also specifies that additions to FITS may not override or replace the FITS standard. A case in point might be creating a keyword that invalidates the FITS standard data array.
As an example, imagine that you find a novel keyword DATATYPE in the header of a file. The value for DATATYPE is unsigned, and the data array does in fact consist of unsigned integers. Even though the DATATYPE keyword might make sense to you, it specifies a type of array data that does not conform to the FITS standard. Because this file does not conform to the FITS standard, the value of the first keyword, SIMPLE, should be the value false, or F.
The data format specified by the FITS standard can be inconvenient for programmers. FITS requires twos-complement signed integers with the most significant byte first. Computers that use Intel CPUs place the least significant byte first, so each time a FITS file is read from disk or saved to disk, the byte order must be swapped. (Byte swapping is the same as swapping the digits in decimal numbers, that is, 81 becomes 18.) By accident or by choice, the programmer may decide to skip byte swapping. When software expecting a conforming FITS file reads these images, however, the result appears unrecognizable as an image.
Another way in which the FITS format makes life difficult for programmers is that FITS specifies signed 16-bit integers. This poses no problem with 10-bit, 12-bit, 14-bit, and 15-bit data because the array values are always less than the largest twos-complement signed integer, 32,767. With 16-bit data, however, the lowest pixel value in the image is usually 0, and the highest value is 65,535. FITS provides a simple solution: subtract 32,768 from each pixel value as the image is saved, and place the BZERO keyword in the header with a value of 3 2 7 6 8 . 0. The FITS standard recommends this for storing 16-bit image data. However, programmers sometimes give in to the temptation to save the data as unsigned 16-bit integers, so that a pixel value of 0 is written as 0 0 0 0 hex, and a pixel value of 65,535 is written as FFFF hex. The result is a nonconforming FITS file.
Finally, it is possible to have a valid header and a valid data array that do not work together. Consider a file in which the data array consists of correctly written signed twos-complement 16-bit integers, but the header specifies BZERO =0.0 and BSCALE = 1.0. The image will appear completely black with just a few very bright stars showing. The data array consists of values from -32,768 to +32,767, but in order to scale it into the range of pixel values from 0 to 65,535, the header should specify that BZERO = 32768.0. When a valid header and a valid data array fail to coordinate, the image data stored in the file will not be read correctly.
Another variation on the theme is using valid keywords in a way that does not tell the software how to interpret the data array. Suppose that the DAT AM IN and DATAMAX keywords appear in the header, with DAT AM IN = -32768.0 and DATAMAX = 32767.0. The programmer probably hoped that the FITS reading program would deduce the necessary offset and scale the data array values correctly. But DAT AM IN and DATAMAX were not intended to function in this way; they specify only the range of pixel values that the image processing software will find in the data. They say nothing about how the data should be read or interpreted.
If a FITS file fails to load properly, check the header and data array. Make sure that the data array contains big-endian twos-complement signed integers, and that the header contains appropriate keywords.
The parameters to be deduced are the header length (usually 2880 bytes, or a multiple of 2880 bytes), the byte order, whether the data are signed or unsigned, and the offset to be added to the values found in the file. Usually it takes only three or four tries before a universal binary reader creates a reasonable approximation of the image stored in the file.
Was this article helpful?
Are You Frustrated Because Your Graphics Are Not Looking Professional? Have You Been Slaving Over Your Projects, But Find Yourself Not Getting What You Want From Your Generic Graphic Software? Well, youre about to learn some of the secrets and tips to enhance your images, photos and other projects that you are trying to create and make look professional.