[AstroPy] pyfits: reading fits data problem

Malte Tewes malte.tewes@epfl...
Tue May 26 07:57:56 CDT 2009


Hi Guillaume,

I can reproduce the error on my side. I would say that the problem is  
your FITS file -- indeed it does not validate on this webpage :
http://fits.gsfc.nasa.gov/fits_verify.html


Cheers,
Malte


On 26 May 2009, at 11:47, Guillaume Blanc wrote:

> Hi,
>
> I'm new to python and I'm trying to use pyfits, to read some table
> data, but if it's work fine on test files, it doesn't work on my file,
> and I don't understand why, since I can read it using fv. Pyfits gives
> me an error (see below).
> Any help would be appreciated. Many thanks in advance.
>
> Guillaume
>
>
> Here is the python file:
> -----------------
> import pyfits
> import numpy
> hdulist = pyfits.open('spec10.fits')
> print hdulist.info()
> print "HEADER = ", hdulist[0].header
> scidata = hdulist[0].data
> print "DATA = " , scidata
> ---------------
>
> Below is the output; file spec10.fits can be downloaded from: http://snovae.free.fr/ftp/spec10.fits
> Note that I don't understand the first warning, since file size is
> 123840 bytes. I don't understand either the error on hdulist.data...
>
> ---------------
> % python plotspec.py
> Warning: File may have been truncated: actual file length (123840) is
> smaller than the expected size (184320)
> Filename: spec10.fits
> No.    Name         Type      Cards   Dimensions   Format
> 0    PRIMARY     PrimaryHDU      15  (4975, 3)     int32
> None
> HEADER =  SIMPLE  =                    T /
>
> BITPIX  =                   32 /
>
> NAXIS   =                    2 /
>
> NAXIS1  =                 4975 /
>
> NAXIS2  =                    3 /
>
> BSCALE  =   6.240186520248E-07 /
>
> BZERO   =       79.45127590903 /
>
> DATE    = '18/05/09 10:45:08 ' /
>
> CRVAL1  =       3.544000040919 /
>
> CD1_1   =   9.999998959014E-05 /
>
> Z       =       2.532511414828 /
>
> MAG_G   =       21.39270563646 /
>
> DECDEG  =       888.0000000000 /
>
> RADEG   =       1878.000000000 /
>
> COMMENT  Mock Horizon spectrum
>
> 14925 items requested but only 0 read
> Traceback (most recent call last):
> File "plotspec.py", line 10, in <module>
>   scidata = hdulist[0].data
> File "/Library/Frameworks/Python.framework/Versions/2.5.2001/lib/
> python2.5/site-packages/pyfits/NP_pyfits.py", line 3189, in  
> __getattr__
>   raw_data.shape=dims
> ValueError: total size of new array must be unchanged
> ---------------------------
>
> _______________________________________________
> AstroPy mailing list
> AstroPy@scipy.org
> http://mail.scipy.org/mailman/listinfo/astropy






More information about the AstroPy mailing list