thegooglecodearchive / healpy

Automatically exported from code.google.com/p/healpy
GNU General Public License v2.0
0 stars 0 forks source link

AttributeError: 'numpy.ndarray' object has no attribute 'field' #47

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I try to read a Healpix File (see header below)
using read_map. I hope this is the way of doing it.
But I get the following error message:

In [7]: fits1 = healpy.read_map('FERMI_file.fits')
NSIDE = 256
ORDERING = RING in fits file
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)

/Users/kneiske/PROGRAMME/PYTHON/FERMI/<ipython console> in <module>()

/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/he
alpy/fitsfunc.pyc in read_map(filename, field, dtype, nest, hdu, h)
    173 
    174     for ff in field:
--> 175         m=hdulist[hdu].data.field(ff).astype(dtype).ravel()
    176         if not pixelfunc.isnpixok(m.size) or (sz>0 and sz != m.size):
    177             print 'nside=%d, sz=%d, m.size=%d'%(nside,sz,m.size)

AttributeError: 'numpy.ndarray' object has no attribute 'field'

What steps will reproduce the problem?
1.IMPORT healpy
2.fits1 = healpy.read_map('FERMI_file.fits')
(3.)Header of FERMI_file.fits:
--------------
SIMPLE  =      T / Written by IDL:  Sun Oct 18 14:55:26 2009      
BITPIX  =     -32 / Number of bits per data pixel                  NAXIS   =    
   1 / Number of data axes                            NAXIS1  =        786432 / 

EXTEND  =      T /Extensions may be present                       DATE    = 
'2009-10-18T18:55:26' / Creation date         
COMMENT FITS (Flexible Image Transport System) format is defined in 'Astronomy  
COMMENT and Astrophysics', volume 376, page 359; bibcode 2001A&A...376..359H    
BUNIT   = 'counts/cm^2/s/sr'/                                               
FWHM    =   0.00000 / Target FWHM after smoothing [arcmin]           
FWHMINIT=     64.1669 / Original FWHM[arcmin]                         
PIXTYPE = 'HEALPIX '   / Pixel algorithm                                
ORDERING= 'RING    '  / Ordering scheme                                
NSIDE   =       256 / Resolution parameter                          
NPIX    =     786432 / # of pixels                                    
FIRSTPIX=      0 / First pixel (0 based)                          
LASTPIX =      786431 / Last pixel (0 based)                           
EMIN    =      0.500000 / Energy bin Emin [GeV]                          
EMAX    =    1.00000 / Energy bin Emax [GeV]                          
EMEAN   =   0.707107 / Mean energy of event in bin [GeV]              
PSCSUB  =   0 / Point sources subtracted?                      
HISTORY  Reprojected to HEALPIX CfA                   
END        

----------------------

What is the expected output? What do you see instead?
I would like to read file "FERMI_file.fits" which is a healpix file

What version of the product are you using? On what operating system?
Healpy 0.9.12

Please provide any additional information below.

Original issue reported on code.google.com by spiderta...@arcor.de on 23 Feb 2011 at 10:56

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
That should work... What version of pyfits are you using ?
Could you try this : 
>>> import pyfits
>>> hdulist = pyfits.open('FERMI_file.fits')
>>> print len(hdulist)
>>> print hdulist[1].data.field(0).size

Original comment by cyrille....@gmail.com on 1 Mar 2011 at 6:16