when you parse a float FITS file, do you look at all values to determine max and min?
We use the BZERO and BSCALE keywords. For floating point FITS files these keys are in fact mandatory, since they are the only way to know the actual data range in which stored pixel values are represented.
Please refer to this document:
http://archive.stsci.edu/fits/users_guide/node21.htmlThe standard says that when no BZERO or BSCALE keys are found, their values must be assumed to be 0 and 1, respectively.
Only if the BZERO and BSCALE values are bad, or if existing pixel values exceed the declared range, we take the existing extreme values in all channels of the image as a "last-chance range", which we map to the [0,1] range.
In your case, both files do provide standard BZERO=0 and BSCALE=1, so this is the range used by PixInsight to decode pixel values. If the actual values stored are outside the declared [0,1] range, then blame the guys who wrote the software that creates these files...
I set the datamax FITS field to 64K.0 but this did not change the behavior. Are you purposely ignoring that field?
We don't use the DATAMIN and DATAMAX keywords because they don't define the actual range of values. In plain words, DATAMIN does not represent black and DATAMAX does not represent white. These keywords are just informative values that can be used to know in advance which are the minimum and maximum values present in the file, but they don't add more information than what we can already know by reading all pixels.
BZERO and BSCALE are the only keywords that define how pixel values have to be mapped to the [0,1] range in a floating point FITS file.
You could overcome this problem by writing a PixInsight module to handle FITS file reading with low-level PCL routines, replacing the standard FITS support module. Although this is quite easy to do, in fact, have you considered writing the authors of the original software to see if they can fix this issue to write correct FITS files?
If you decide to write a specific module, I'll help you of course.
Luc suggested adding a 64K pixel in a corner to force the proper maximum of the file. Would that help?
Edited: I didn't understand this well. I see. You mean writing a 65535.0 pixel with the same software that creates the wrong image. Please try it; it indeed could solve the problem.
However I think you should contact the guys that wrote the original software.