在python中使用h5py读取或写入复合数据类型

时间:2015-07-08 20:51:17

标签: hdf5 h5py

我想在一些C ++,matlab和python代码中使用hdf5文件。 我的h5文件在C ++和matlab中运行良好,但无法用h5py读取。

h5py是否支持H5T_STD_B64LE等数据类型? 谢谢!

In [2]: f = h5py.File('art.mips.log.h5', 'r')

In [3]: f.keys()
Out[3]: [u'mem']

In [4]: f['mem']
Out[4]: <repr(<h5py._hl.dataset.Dataset at 0x29f70d0>) failed: TypeError: No NumPy equivalent for TypeBitfieldID exists>

hdf5文件格式如下:

$ h5dump -H art.mips.log.h5  
HDF5 "art.mips.log.h5" { GROUP "/" {    DATASET "mem" {
      DATATYPE  H5T_COMPOUND {
         H5T_STD_B64LE "clock";
         H5T_STD_B32LE "addr";
         H5T_STD_B32LE "operation";
         H5T_ARRAY { [16] H5T_STD_B32LE } "data";
      }
      DATASPACE  SIMPLE { ( 68614468 ) / ( H5S_UNLIMITED ) }
      ATTRIBUTE "CLASS" {
         DATATYPE  H5T_STRING {
            STRSIZE 6;
            STRPAD H5T_STR_NULLTERM;
            CSET H5T_CSET_ASCII;
            CTYPE H5T_C_S1;
         }
         DATASPACE  SCALAR
      }
      ATTRIBUTE "FIELD_0_NAME" {
         DATATYPE  H5T_STRING {
            STRSIZE 6;
            STRPAD H5T_STR_NULLTERM;
            CSET H5T_CSET_ASCII;
            CTYPE H5T_C_S1;
         }
         DATASPACE  SCALAR
      }
      ATTRIBUTE "FIELD_1_NAME" {
         DATATYPE  H5T_STRING {
            STRSIZE 5;
            STRPAD H5T_STR_NULLTERM;
            CSET H5T_CSET_ASCII;
            CTYPE H5T_C_S1;
         }
         DATASPACE  SCALAR
      }
      ATTRIBUTE "FIELD_2_NAME" {
         DATATYPE  H5T_STRING {
            STRSIZE 10;
            STRPAD H5T_STR_NULLTERM;
            CSET H5T_CSET_ASCII;
            CTYPE H5T_C_S1;
         }
         DATASPACE  SCALAR
      }
      ATTRIBUTE "FIELD_3_NAME" {
         DATATYPE  H5T_STRING {
            STRSIZE 5;
            STRPAD H5T_STR_NULLTERM;
            CSET H5T_CSET_ASCII;
            CTYPE H5T_C_S1;
         }
         DATASPACE  SCALAR
      }
      ATTRIBUTE "TITLE" {
         DATATYPE  H5T_STRING {
            STRSIZE 4;
            STRPAD H5T_STR_NULLTERM;
            CSET H5T_CSET_ASCII;
            CTYPE H5T_C_S1;
         }
         DATASPACE  SCALAR
      }
      ATTRIBUTE "VERSION" {
         DATATYPE  H5T_STRING {
            STRSIZE 4;
            STRPAD H5T_STR_NULLTERM;
            CSET H5T_CSET_ASCII;
            CTYPE H5T_C_S1;
         }
         DATASPACE  SCALAR
      }
   }
}
}

0 个答案:

没有答案