在Python中使用H5T_ARRAY [英] using H5T_ARRAY in Python
本文介绍了在Python中使用H5T_ARRAY的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用Python在H5T_COMPOUND结构内使用H5T_ARRAY.基本上,我正在编写hdf5文件,如果使用H5Dump打开它,结构将如下所示.
I am trying to use H5T_ARRAY inside the H5T_COMPOUND structure using Python. Basically, I am writing hdf5 file and if you open it using H5Dump, the structure looks like this.
HDF5 "SO_64449277np.h5" {
GROUP "/" {
DATASET "Table3" {
DATATYPE H5T_COMPOUND {
H5T_COMPOUND {
H5T_STD_I16LE "id";
H5T_STD_I16LE "timestamp";
} "header";
H5T_COMPOUND {
H5T_IEEE_F32LE "latency";
H5T_STD_I16LE "segments_k";
H5T_COMPOUND {
H5T_STD_I16LE "segment_id";
H5T_IEEE_F32LE "segment_quality";
H5T_IEEE_F32LE "segment_length";
} "segments_k0";
H5T_COMPOUND {
H5T_STD_I16LE "segment_id";
H5T_IEEE_F32LE "segment_quality";
H5T_IEEE_F32LE "segment_length";
} "segments_k1";
.....
} "summary_data";
}
DATASPACE SIMPLE { ( 2 ) / ( H5S_UNLIMITED ) }
}
}
}
相反,我们的想法是拥有这个:
Instead, the idea is to have this:
HDF5 "SO_64449277np.h5" {
GROUP "/" {
DATASET "Table3" {
DATATYPE H5T_COMPOUND {
H5T_COMPOUND {
H5T_STD_I16LE "id";
H5T_STD_I16LE "timestamp";
} "header";
H5T_COMPOUND {
H5T_IEEE_F32LE "latency";
H5T_ARRAY {[70] H5T_COMPOUND {
H5T_STD_I16LE "segment_id";
H5T_IEEE_F32LE "segment_quality";
H5T_IEEE_F32LE "segment_length";
} } "segments_k";
} "summary_data";
}
DATASPACE SIMPLE { ( 2 ) / ( H5S_UNLIMITED ) }
}
}
}
谢谢!
推荐答案
Not sure how this is done with other libraries, but the above dataset compound layout may be created as follows with HDFql in Python:
# import HDFql package
import HDFql
# create an HDF5 file named 'SO_64449277np.h5'
HDFql.execute("CREATE FILE SO_64449277np.h5")
# create an HDF5 compound dataset named 'Table3' (in HDF5 file 'SO_64449277np.h5') with the wanted layout
HDFql.execute("CREATE DATASET SO_64449277np.h5 Table3 AS COMPOUND(header AS COMPOUND(id AS SMALLINT, timestamp AS SMALLINT), summary_data AS COMPOUND(latency AS FLOAT, segments_k AS COMPOUND(segment_id AS SMALLINT, segment_quality AS FLOAT, segment_length AS FLOAT)(70)))(2 TO UNLIMITED)")
查看HDFql 参考手册以获取更多信息和示例.
Check HDFql reference manual for additional information and examples.
这篇关于在Python中使用H5T_ARRAY的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文