[AstroPy] unexpected pyfits behavior float32 converted to float64
Erik Bray
embray at stsci.edu
Wed May 9 13:41:42 EDT 2012
On 05/09/2012 12:38 PM, Phil Hodge wrote:
> Erik,
>
> 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.
>
> Phil
Okay, that makes sense. I didn't realize a 32-bit int was so poorly
represented by a single float.
I think that if nothing else the PyFITS documentation should be updated
to clarify this point.
Erik
More information about the AstroPy
mailing list