[AstroPy] unexpected pyfits behavior float32 converted to float64

Phil Hodge hodge at stsci.edu
Wed May 9 12:38:59 EDT 2012


On 05/09/2012 11:49 AM, Erik Bray wrote:
> As a followup: I did a little more digging on this issue, and found out
> that despite the deceptive documentation, this has actually been the
> behavior of PyFITS for quite a long time:
> If the raw data is 16-bit ints they are scaled up to 32-bit floats.  And
> if they're 32-bit ints (or 64-bit I think) they're scaled to 64-bit
> floats.  I think this is so that one can generally expect the size of
> their data to double when reading scaled data.

No, this is so you don't lose any precision.  A 32-bit float has 
something like 22 bits of precision, which is fine for a 16-bit integer, 
but you would lose around 10 bits if you converted a 32-bit integer to 
32-bit float.


More information about the AstroPy mailing list