[AstroPy] unexpected pyfits behavior float32 converted to float64

Jim Vickroy jim.vickroy at noaa.gov
Wed May 9 10:18:46 EDT 2012


On 5/8/2012 9:05 PM, Michael Droettboom wrote:
> It actually appears that this is converting 32-bit integers to 64-bit 
> floats.  Does the file have BZERO or BSCALE specified?  If so, it is 
> normal behavior to convert to 64-bit floats so that user code doesn't 
> have to deal with offset and scaling issues.
>
> Mike

Thanks Mike.

The FITS files do have BZERO and BSCALE defined.  My mistake (twice) 
saying 32-bit float since BITPIX=+32.  I was expecting conversion to 
32-bit floats.  Since converting 32-bit integers to 64-bit floats is the 
standard Pyfits behavior, I will perform the conversion explicitly 
(numpy astype).

-- jv





>
> On 05/08/2012 02:14 PM, Jim Vickroy wrote:
>> On 5/8/2012 11:11 AM, Philip Tait wrote:
>>> Isn't this a known issue, fixed in 3.0.7?
>>
>> Thanks for the quick reply.  It is embarrassing to post a problem and 
>> not be using the latest release.  So I've downloaded/installed 
>> 3.0.7.  Unfortunately, the same behavior persists (i.e., unwanted, 
>> silent conversion from 32 to 64 bit floats) as illustrated below:
>>
>> >>> import os
>> >>> import sys
>> >>> import pyfits
>> >>> sys.version
>> '2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)]'
>> >>> pyfits.__version__
>> '3.0.7'
>> >>> path = ...
>> >>> HDUs = pyfits.open (path,mode='readonly')
>> >>> HDUs['primary'].header['bitpix']
>> 32
>> >>> HDUs['primary'].data.dtype
>> dtype('float64')
>> >>> HDUs['primary'].header['bitpix']
>> -64
>> >>>
>>
>> Is this a bug that should be reported?
>>
>> Thanks,
>> -- jv
>>
>>
>>
>>
>>
>>
>>>
>>>
>>>
>>> -- Sent from my HP Pre3
>>>
>>> ------------------------------------------------------------------------
>>> On May 8, 2012 6:59, Jim Vickroy <jim.vickroy at noaa.gov> wrote:
>>>
>>> Hi Pyfits users,
>>>
>>> Consider:
>>>
>>> >>> import pyfits
>>> >>> pyfits.__version__
>>> '3.0.5'
>>> >>> path = ...
>>> >>> HDUs = pyfits.open (path,mode='readonly')
>>> >>> HDUs['primary'].header['bitpix']
>>> 32
>>> >>> HDUs['primary'].data.dtype
>>> dtype('float64')
>>> >>> HDUs['primary'].header['bitpix']
>>> -64
>>> >>>
>>>
>>> Why is the conversion from 32 to 64 bit floats silently occurring? How
>>> can I prevent it?
>>>
>>> Thanks,
>>> -- jv
>>>
>>> _______________________________________________
>>> AstroPy mailing list
>>> AstroPy at scipy.org
>>> http://mail.scipy.org/mailman/listinfo/astropy
>>
>>
>>
>> _______________________________________________
>> AstroPy mailing list
>> AstroPy at scipy.org
>> http://mail.scipy.org/mailman/listinfo/astropy
>
>
>
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> http://mail.scipy.org/mailman/listinfo/astropy

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20120509/ce7fb303/attachment.html>


More information about the AstroPy mailing list