I have started to use some calibration and stacking sw that uses FIT files with 32bit float array values.
Raw CCD data are 16-bit unsigned integers and hence should be stored in that format. An image calibration routine should use raw data, so it is at least surprising that a calibration software requires floating point data.
1) When PI writes a 32bit float, the bzero and bscale tags are not included in the FITs header.
Section 5.3 of the
FITS standard document version 3.0 (page 14):
5.3. IEEE-754 Floating point
Transmission of 32- and 64-bit floating-point data within the
FITS format shall use the ANSI/IEEE-754 standard (IEEE
1985). BITPIX = -32 and BITPIX = -64 signify 32- and 64-
bit IEEE floating-point numbers, respectively; the absolute value
of BITPIX is used for computing the sizes of data structures. The
full IEEE set of number forms is allowed for FITS interchange,
including all special values.
The BLANK keyword should not be used when
BITPIX = -32 or -64; rather, the IEEE NaN should be
used to represent an undefined value. Use of the BSCALE and
BZERO keywords is not recommended.
Appendix E has additional details on the IEEE format.Any competent FITS reader software should be able to correctly read and interpret a FITS file with no BSCALE and BZERO keywords, using the default values of these keywords (1.0 and 0.0, respectively). These keywords are not mandatory; its use is only necessary to store unsigned integer data (the well-known
BSCALE/BZERO trick) since the FITS standard does not support unsigned integers natively, but it is explicitly discouraged for floating point data by the standard.
2) PI is scaling or normalizing the original data to the [0..1] range.
Not actually. Rescaling only takes place when a floating point FITS or TIFF file is being loaded and PixInsight does not know the actual range of pixel values to which the data are referred. In other words, PixInsight has to know which values correspond to the
no signal and
full signal states (usually corresponding to the black and white pixel value interpretations, respectively, in all supported color spaces). This is necessary to correctly interpret any image in PixInsight. In absence of a known data range, the only way to interpret an image is by assuming that min=black (or perhaps 0=black if min >= 0) and max=white, where min and max are the minimum and maximum values present in the data array.
Unfortunately, the TIFF and FITS standards do not provide a standard way to define the numeric range to which pixel values are referred in a floating point image (see the text marked as green in section 5.3 above). With integer data there are (almost) no problems, since integers are naturally bounded by their bit sizes. However, real numbers allow for arbitrary ranges, and here is where the craziness begins. Basically each application uses its own, usually undocumented and sometimes inconsistent range to store floating point images, and this is the cause of most of the existing problems to transport floating point data between applications.
PixInsight is very different from most applications in this regard, for the following reasons:
- PixInsight
always uses the same numeric range to store floating point pixel data: the [0,1] range, where 0=black and 1=white. This feature is publicly documented and used consistently.
- PixInsight is extremely flexible to import floating point data in virtually any possible range. A custom
default floating point input range can be defined with the FITS and TIFF format preferences dialogs, available from the Format Explorer window. The default input range of floating point data is [0,1], but it can be changed to meet the ranges used by alien data; for example [0.0,65535.0] is used by some well-known software packages.
- The ImageCalibration, StarAlignment, ImageIntegration and HDRComposition tools support a set of
format hints (small words that change the behavior of a format support module) that allow you to load floating point FITS and TIFF files with arbitrary ranges, orientations, data formats, format features, etc. This has been a further step to provide the necessary flexibility to load data produced by virtually
any application.
3) PI is scaling the original data so that in PI min gets reset to 0 and the max to 65535 (from image statistics). PI seems to be scaling the data using the min of the original data as the zero point and the max of the original data as the range high end. "Bzero" and "bscale" are 0 and 1 in the original fits file before opening in PI with "bitpix" set to -32 (i presume this means 32bit float).
I have already answered most of these questions in the preceding paragraphs. The BZERO and BSCALE keywords don't define the range of floating point data, so PixInsight does not rely on them for this purpose. You
can load the original data without problems in PixInsight if you know the range to which they are referred (the black and white points). Once you know it, you can enter the corresponding default input range values in the FITS Format Preferences dialog, or use format hints in specific tools, as appropriate.