Hi, On 2 July 2011 17:07, jpaulini <[email protected]> wrote:
> files, but today I was so surprised that now they implemented a > different data format... > > Looking for some information on how to read the new data with python, > I only got that it uses HDF file format, but no more... > HDF is a very frequenty-encountered format, and as such, there are a few pythonic ways of reading it in (& saving it, I guess). It would appear that the format is HDF4. I am partial to GDAL through its python bindings, but it is a bit limited (if they pack in 1D arrays and stuff, GDAL will just ignore them). pydf <http://pysclint.sourceforge.net/pyhdf/> deals with all that stuff. Using gdal to read data into a numpy array (consider that all the products have the same spatial extent) is quite easy. Suppose you have a file called 3B42.110531.0.6A.HDF, you just then... from osgeo import gdal g = gdal.Open('HDF4_SDS:UNKNOWN:"3B42.110531.0.6A.HDF":0') precip = g.ReadAsArray() # precip is a 1440x400 array with the precipitation dataset g = gdal.Open('HDF4_SDS:UNKNOWN:"3B42.110531.0.6A.HDF":1') err= g.ReadAsArray() # err is a 1440x400 array with the relative error Hope that helps Jose
