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
Hello,

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
129
 >>> 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/SD.py", line 1200, in get
   File "build/bdist.linux-x86_64/egg/pyhdf/SD.py", line 1437, in  
__getattr__
   File "build/bdist.linux-x86_64/egg/pyhdf/SD.py", line 3123, in  
_getattr
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  
"att.get()"
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  
"get()"
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.

Thanks,

Catherine
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev