从hdf文件获取列名(标题)

我想知道如何获得hdf文件的列名(看起来存储在hdf头文件中) 例如,一个文件可能具有名为[a,b,c,d]的列,而另一个文件具有列[a,b,c],而另一个文件具有列[b,e,r,z]; 我想找出哪些有哪些。 任何帮助将非常感谢!


为了在python之外执行此操作,可以通过h5dump --header my.hdf5东西使用h5dump --header my.hdf5

在python中,你可以使用h5py

作为一个例子,我可以访问我的HDF-EOS5文件的字段名称:

>>> import h5py
>>> f = h5py.File('/tmp/temp.hdf','r')
>>> f.keys()
[u'HDFEOS', u'HDFEOS INFORMATION']
>>> f.values()
[<HDF5 group "/HDFEOS" (2 members)>, <HDF5 group "/HDFEOS INFORMATION" (2 members)>]
>>> grpname = f.require_group('/HDFEOS')
>>> grpname.keys()
[u'ADDITIONAL', u'GRIDS']
>>> grpname.values()
[<HDF5 group "/HDFEOS/ADDITIONAL" (1 members)>, <HDF5 group "/HDFEOS/GRIDS" (9 members)>]
>>> subgrpname = grpname.require_group('/HDFEOS/GRIDS')
>>> subgrpname.keys()
[u'355nm_band', u'380nm_band', u'445nm_band', u'470nm_band', u'555nm_band', u'660nm_band', u'865nm_band', u'935nm_band', u'Ancillary']
>>> group_660 = subgrpname.require_group('660nm_band')
>>> group_660.keys()
[u'Data Fields']
>>> group_660.values()
[<HDF5 group "/HDFEOS/GRIDS/660nm_band/Data Fields" (20 members)>]
>>> fields_660 = group_660.require_group('Data Fields')
>>> fields_660.keys()
[u'AOLP_meridian', u'AOLP_scatter', u'DOLP', u'Glint_angle', u'I', u'I.mask', u'IPOL', u'Q.mask', u'Q_meridian', u'Q_scatter', u'RDQI', u'Scattering_angle', u'Sun_azimuth', u'Sun_zenith', u'Time_in_seconds_from_epoch', u'U.mask', u'U_meridian', u'U_scatter', u'View_azimuth', u'View_zenith']
>>> fields_660.values()
[<HDF5 dataset "AOLP_meridian": shape (3072, 3072), type "<f4">, <HDF5 dataset "AOLP_scatter": shape (3072, 3072), type "<f4">, <HDF5 dataset "DOLP": shape (3072, 3072), type "<f4">, <HDF5 dataset "Glint_angle": shape (3072, 3072), type "<f4">, <HDF5 dataset "I": shape (3072, 3072), type "<f4">, <HDF5 dataset "I.mask": shape (3072, 3072), type "<i4">, <HDF5 dataset "IPOL": shape (3072, 3072), type "<f4">, <HDF5 dataset "Q.mask": shape (3072, 3072), type "<i4">, <HDF5 dataset "Q_meridian": shape (3072, 3072), type "<f4">, <HDF5 dataset "Q_scatter": shape (3072, 3072), type "<f4">, <HDF5 dataset "RDQI": shape (3072, 3072), type "<f4">, <HDF5 dataset "Scattering_angle": shape (3072, 3072), type "<f4">, <HDF5 dataset "Sun_azimuth": shape (3072, 3072), type "<f4">, <HDF5 dataset "Sun_zenith": shape (3072, 3072), type "<f4">, <HDF5 dataset "Time_in_seconds_from_epoch": shape (3072, 3072), type "<f8">, <HDF5 dataset "U.mask": shape (3072, 3072), type "<i4">, <HDF5 dataset "U_meridian": shape (3072, 3072), type "<f4">, <HDF5 dataset "U_scatter": shape (3072, 3072), type "<f4">, <HDF5 dataset "View_azimuth": shape (3072, 3072), type "<f4">, <HDF5 dataset "View_zenith": shape (3072, 3072), type "<f4">]
链接地址: http://www.djcxy.com/p/80931.html

上一篇: Get column names (headers) from hdf file

下一篇: Serialize property name without quotes