3

So I'm currently working on a project that has me read an hdf4 file and extract the data to make a plot. I'm having an issue reading the file in python. I have downloaded both hdf4 and pyhdf and have tried to read my file, but I'm having no luck. It allows me to create an SD instance, but when I try to use the attribute or datasets function, I get a return of an empty dictionary.

Now I thought it might be a problem with my data file, so I checked it in Matlab and it is able to read all of the SDS and vdata sets from the function. Am I missing a package in python or some magical way of unzipping my file, thus making it unable to read?

Here's the code

>>> from numpy import *
>>> from pyhdf.SD import SD,SDS 
>>> data = SD('file name',READ.SDS)

returns

>>> data.attributes()
{}
>>> data.datasets() 
{}

(I didn't type out my hdf file because it's a waste, but I did use the ishdf function on it, and it does indeed confirm that my file is valid hdf)

embert
  • 7,336
  • 10
  • 49
  • 78

1 Answers1

0

If you've copied that code straight from Canopy, then hopefully your problems are down to a simple typo: replace READ.SDS with SDS.READ

Stephan
  • 2,863
  • 1
  • 17
  • 14