problem accessing HDF file attributes with pyhdf

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

problem accessing HDF file attributes with pyhdf

Catherine Moroney

I want to read in a list of attributes from an HDF file using pyhdf,  
and am
having problems.

See the attached code snippet for details:

 >>> from pyhdf.SD import *
 >>> hfile = SD("MISR_AM1_AGP_P129_F01_24.hdf", SDC.READ)
 >>> print hfile.Path_number
 >>> att = hfile.attr("Path_number")
 >>> print att.get()
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "build/bdist.linux-x86_64/egg/pyhdf/", line 1200, in get
   File "build/bdist.linux-x86_64/egg/pyhdf/", line 1437, in  
   File "build/bdist.linux-x86_64/egg/pyhdf/", line 3123, in  
AttributeError: attribute not found

I am attempting to read in an attribute called "Path_number".  If I  
access it
directly using "hfile.Path_number" then that works, but using the  
doesn't work.

I am copying a list of file attributes from one hdf file to another, so
being able to access the attributes directly using the "set()" and  
methods would be much more convenient.

Can somebody point out to me what I'm doing wrong?

I'm using pyhdf-0.8.3-py2.5-linux-x86_64.


Enthought-Dev mailing list
[hidden email]