I don't understand how DATAMIN and DATAMAX in the FITS header are derived from the data. When I look at the data table in FV, all the entries are positive integers, but the header entries for DATAMIN and DATAMAX are by definition double precision decimals. How to get from one to the other?
So far I have found the function getMinMax in indiccd.cpp which is simple enough routine for finding extreme values. So I guess the float values come from the function getFrameBuffer for which I have not yet seen the source but will look for. But until then, I'm wondering what could be the reason to use decimal fractions to represent extreme values of binary integers?
In theory, DATAMIN and DATAMAX represent the minimum and maximum physical values the sensor providing the data is able to store in the FITS file. There is a reference change (origin+scale) to process on the raw data to obtain the physical data.
My camera is a ZWO ASI290MM which should be producing 12 bit per pixel output. So, in analogy to DSLR output, I expected the FItS data to be an array of positive integers between 0 and 2^12-1 = 4095 with min and max nested between those extremes. But when I look at the data table of a photograph, FITS header attached, the values are all positive integers, *but* they are all even numbers and they top out at 5232. Min is around 160. Then the values for DATAMIN and DATAMAX are -898.34... and 5231.76.... I would like to understand how those numbers are obtained. It can't be a linear transformation a*x+b where a and b are scale and offset because any such number should be an integer if x is, so I guess there is some other algorithm.
You are right, a 12-bit sensor should provide a dynamic range of 2^12 values. ZWO is actually claiming a dynamic range that is sometimes higher than what the ADC provides thanks to internal enhancements. For instance, they claim to achieve 12.5 bits on some cameras, while the reported range is 12bits. As it happens, if you do DATAMAX-DATAMIN in your case, you end up with approximately 12.58 bits of dynamic range. You should probably direct these questions to the support at ZWO to get the full explanation.