From: Chao Y. <cha...@gm...> - 2012-06-02 09:36:21
|
Dear all, I tried to use pytalbes to read a hdf file, but I got error: I searched a little bit online, there might be cases you have more than 2 file handlers for the same file and they are opened for both read and write, you'll probably have this error. But it's not my case that I open it only for the first time. From the error message, it seems that there is no root group. In [1]: h5file=tables.openFile('LISOTD_HRMC_V2.3.2011.hdf','r') --------------------------------------------------------------------------- HDF5ExtError Traceback (most recent call last) /home/chaoyue/Downloads/LISOTD/<ipython-input-1-b53d861308cf> in <module>() ----> 1 h5file=tables.openFile('LISOTD_HRMC_V2.3.2011.hdf','r') /usr/local/lib/python2.7/dist-packages/tables/file.pyc in openFile(filename, mode, title, rootUEP, filters, **kwargs) 256 return filehandle 257 # Finally, create the File instance, and return it --> 258 return File(filename, mode, title, rootUEP, filters, **kwargs) 259 260 /usr/local/lib/python2.7/dist-packages/tables/file.pyc in __init__(self, filename, mode, title, rootUEP, filters, **kwargs) 565 566 # Get the root group from this file --> 567 self.root = root = self.__getRootGroup(rootUEP, title, filters) 568 # Complete the creation of the root node 569 # (see the explanation in ``RootGroup.__init__()``. /usr/local/lib/python2.7/dist-packages/tables/file.pyc in __getRootGroup(self, rootUEP, title, filters) 614 # Create new attributes for the root Group instance and 615 # create the object tree --> 616 return RootGroup(self, rootUEP, title=title, new=new, filters=filters) 617 618 /usr/local/lib/python2.7/dist-packages/tables/group.pyc in __init__(self, ptFile, name, title, new, filters) 1155 self._g_new(ptFile, name, init=True) 1156 # Open the node and get its object ID. -> 1157 self._v_objectID = self._g_open() 1158 1159 # Set disk attributes and read children names. /usr/local/lib/python2.7/dist-packages/tables/hdf5Extension.so in tables.hdf5Extension.Group._g_open (tables/hdf5Extension.c:5521)() HDF5ExtError: Can't open the group: '/'. If I open the file with this command, it gave no error: In [2]: h5file=tables.openFile('LISOTD_HRMC_V2.3.2011.hdf',mode='r') But when I try to print the file information, I get: In [3]: print h5file Exception tables.exceptions.HDF5ExtError: HDF5ExtError('Problems closing the Group /',) in ignored --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) /home/chaoyue/Downloads/LISOTD/<ipython-input-3-64c76de88957> in <module>() ----> 1 print h5file /usr/local/lib/python2.7/dist-packages/tables/file.pyc in __str__(self) 2197 # Print all the nodes (Group and Leaf objects) on object tree 2198 date = time.asctime(time.localtime(os.stat(self.filename)[8])) -> 2199 astring = self.filename + ' (File) ' + repr(self.title) + '\n' 2200 # astring += 'rootUEP :=' + repr(self.rootUEP) + '; ' 2201 # astring += 'format_version := ' + self.format_version + '\n' /usr/local/lib/python2.7/dist-packages/tables/file.pyc in _gettitle(self) 474 475 def _gettitle(self): --> 476 return self.root._v_title 477 def _settitle(self, title): 478 self.root._v_title = title AttributeError: 'File' object has no attribute 'root' I have not too much experience handling HDF data but it's the second time I have this problem. In both cases the data are downloaded from official release of research data so I think it's unlikely that the data itself are badly produced. But if anyone has any interest trying to have a look of the issue, the data is at: ftp://ghrc.nsstc.nasa.gov/pub/lis/climatology/HRMC/data/ The ftp is anonymous and the data released by NASA. thanks for any help in advance, best regards, Chao -- *********************************************************************************** Chao YUE Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL) UMR 1572 CEA-CNRS-UVSQ Batiment 712 - Pe 119 91191 GIF Sur YVETTE Cedex Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16 ************************************************************************************ |
From: Chao Y. <cha...@gm...> - 2012-06-02 09:56:02
|
if I use gdalinfo to check the file: chaoyue@chaoyue-Aspire-4750:~/Downloads/LISOTD$ gdalinfo LISOTD_HRMC_V2.3.2011.hdf Driver: HDF4/Hierarchical Data Format Release 4 Files: LISOTD_HRMC_V2.3.2011.hdf Size is 512, 512 Coordinate System is `' Subdatasets: SUBDATASET_1_NAME=HDF4_SDS:UNKNOWN:"LISOTD_HRMC_V2.3.2011.hdf":0 SUBDATASET_1_DESC=[360x720x12] HRMC_COM_FR (32-bit floating-point) SUBDATASET_2_NAME=HDF4_SDS:UNKNOWN:"LISOTD_HRMC_V2.3.2011.hdf":4 SUBDATASET_2_DESC=[360x720x12] HRSC_COM_FR (32-bit floating-point) Corner Coordinates: Upper Left ( 0.0, 0.0) Lower Left ( 0.0, 512.0) Upper Right ( 512.0, 0.0) Lower Right ( 512.0, 512.0) Center ( 256.0, 256.0) Chao 2012/6/2 Chao YUE <cha...@gm...> > Dear all, > > I tried to use pytalbes to read a hdf file, but I got error: > I searched a little bit online, there might be cases you have more than 2 > file handlers for the same file and they are opened for both read and > write, you'll probably have this error. > But it's not my case that I open it only for the first time. From the > error message, it seems that there is no root group. > > In [1]: h5file=tables.openFile('LISOTD_HRMC_V2.3.2011.hdf','r') > --------------------------------------------------------------------------- > HDF5ExtError Traceback (most recent call last) > /home/chaoyue/Downloads/LISOTD/<ipython-input-1-b53d861308cf> in <module>() > ----> 1 h5file=tables.openFile('LISOTD_HRMC_V2.3.2011.hdf','r') > > /usr/local/lib/python2.7/dist-packages/tables/file.pyc in > openFile(filename, mode, title, rootUEP, filters, **kwargs) > 256 return filehandle > 257 # Finally, create the File instance, and return it > > --> 258 return File(filename, mode, title, rootUEP, filters, **kwargs) > 259 > 260 > > /usr/local/lib/python2.7/dist-packages/tables/file.pyc in __init__(self, > filename, mode, title, rootUEP, filters, **kwargs) > 565 > 566 # Get the root group from this file > > --> 567 self.root = root = self.__getRootGroup(rootUEP, title, > filters) > 568 # Complete the creation of the root node > > 569 # (see the explanation in ``RootGroup.__init__()``. > > > /usr/local/lib/python2.7/dist-packages/tables/file.pyc in > __getRootGroup(self, rootUEP, title, filters) > 614 # Create new attributes for the root Group instance and > > 615 # create the object tree > > --> 616 return RootGroup(self, rootUEP, title=title, new=new, > filters=filters) > 617 > 618 > > /usr/local/lib/python2.7/dist-packages/tables/group.pyc in __init__(self, > ptFile, name, title, new, filters) > 1155 self._g_new(ptFile, name, init=True) > 1156 # Open the node and get its object ID. > > -> 1157 self._v_objectID = self._g_open() > 1158 > 1159 # Set disk attributes and read children names. > > > /usr/local/lib/python2.7/dist-packages/tables/hdf5Extension.so in > tables.hdf5Extension.Group._g_open (tables/hdf5Extension.c:5521)() > > HDF5ExtError: Can't open the group: '/'. > > If I open the file with this command, it gave no error: > > In [2]: h5file=tables.openFile('LISOTD_HRMC_V2.3.2011.hdf',mode='r') > > But when I try to print the file information, I get: > > In [3]: print h5file > Exception tables.exceptions.HDF5ExtError: HDF5ExtError('Problems closing > the Group /',) in ignored > --------------------------------------------------------------------------- > AttributeError Traceback (most recent call last) > /home/chaoyue/Downloads/LISOTD/<ipython-input-3-64c76de88957> in <module>() > ----> 1 print h5file > > /usr/local/lib/python2.7/dist-packages/tables/file.pyc in __str__(self) > 2197 # Print all the nodes (Group and Leaf objects) on object > tree > > 2198 date = > time.asctime(time.localtime(os.stat(self.filename)[8])) > -> 2199 astring = self.filename + ' (File) ' + repr(self.title) + > '\n' > 2200 # astring += 'rootUEP :=' + repr(self.rootUEP) + '; ' > > 2201 # astring += 'format_version := ' + self.format_version + > '\n' > > > /usr/local/lib/python2.7/dist-packages/tables/file.pyc in _gettitle(self) > 474 > 475 def _gettitle(self): > --> 476 return self.root._v_title > 477 def _settitle(self, title): > 478 self.root._v_title = title > > AttributeError: 'File' object has no attribute 'root' > > I have not too much experience handling HDF data but it's the second time > I have this problem. > In both cases the data are downloaded from official release of research > data so I think it's unlikely that the data itself are badly produced. > But if anyone has any interest trying to have a look of the issue, the > data is at: > ftp://ghrc.nsstc.nasa.gov/pub/lis/climatology/HRMC/data/ > > The ftp is anonymous and the data released by NASA. > > thanks for any help in advance, > > best regards, > > Chao > > -- > > *********************************************************************************** > Chao YUE > Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL) > UMR 1572 CEA-CNRS-UVSQ > Batiment 712 - Pe 119 > 91191 GIF Sur YVETTE Cedex > Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16 > > ************************************************************************************ > > -- *********************************************************************************** Chao YUE Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL) UMR 1572 CEA-CNRS-UVSQ Batiment 712 - Pe 119 91191 GIF Sur YVETTE Cedex Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16 ************************************************************************************ |
From: Francesc A. <fa...@py...> - 2012-06-02 09:58:43
|
Hi Chao, On 6/2/12 11:55 AM, Chao YUE wrote: > if I use gdalinfo to check the file: > chaoyue@chaoyue-Aspire-4750:~/Downloads/LISOTD$ gdalinfo > LISOTD_HRMC_V2.3.2011.hdf > Driver: HDF4/Hierarchical Data Format Release 4 [clip] This says that the file has HDF4 format, not HDF5. Please note that PyTables only can deal with HDF5 files. For HDF4 I'd rather use pyhdf: http://pysclint.sourceforge.net/pyhdf/ -- Francesc Alted |