我在HDF5中使用Silo,在使用h5py访问某些元数据时遇到问题。它抛出了一些非常不寻常的HDF5结构,在这个结构中,它将一个DATATYPE
放在一个DATATYPE
内。以下是h5dump
的输出摘要:
DATATYPE "sigma_t" H5T_STD_I32LE;
ATTRIBUTE "silo" {
DATATYPE H5T_COMPOUND {
H5T_STRING {
STRSIZE 5;
STRPAD H5T_STR_NULLTERM;
CSET H5T_CSET_ASCII;
CTYPE H5T_C_S1;
} "meshid";
H5T_STRING {
STRSIZE 15;
STRPAD H5T_STR_NULLTERM;
CSET H5T_CSET_ASCII;
CTYPE H5T_C_S1;
} "value0";
H5T_STD_I32LE "ndims";
H5T_STD_I32LE "nvals";
H5T_STD_I32LE "nels";
H5T_IEEE_F32LE "time";
H5T_STD_I32LE "use_specmf";
H5T_STD_I32LE "centering";
H5T_ARRAY { [3] H5T_STD_I32LE } "dims";
H5T_ARRAY { [3] H5T_STD_I32LE } "zones";
H5T_ARRAY { [3] H5T_STD_I32LE } "min_index";
H5T_ARRAY { [3] H5T_STD_I32LE } "max_index";
H5T_ARRAY { [3] H5T_IEEE_F32LE } "align";
}
DATASPACE SCALAR
DATA {
(0): {
"mesh",
"/.silo/#000004",
2,
1,
100,
0,
-1000,
111,
[ 10, 10, 0 ],
[ 9, 9, 0 ],
[ 0, 0, 0 ],
[ 9, 9, 0 ],
[ 0.5, 0.5, 0 ]
}
}
}
ATTRIBUTE "silo_type" {
DATATYPE H5T_STD_I32LE
DATASPACE SCALAR
DATA {
(0): 501
}
}
基本上,f['sigma_t'].attrs['silo']
返回一个tuple
,其中包含所有格式正确的数据,但没有数据类型的任何相关标签。(我需要知道名称meshid
,value0
,等等)有没有办法得到这个?我不知所措。在
HDF5 file包含“sigma_t”字段,实际数据存储在/.silo/#000004
中。在
脚本:
^{pr2}$结果:
('mesh', '/.silo/#000004', 2, 1, 100, 0.0, -1000, 111, array([10, 10, 0], dtype=int32), array([9, 9, 0], dtype=int32), array([0, 0, 0], dtype=int32), array([9, 9, 0], dtype=int32), array([ 0.5, 0.5, 0. ], dtype=float32))
我还想要的是:
('meshid','value0','ndims', ..., 'align')
这可能吗?在
谢谢你回答赛斯!你的回答对我有帮助,但这可能会让事情变得简单一点
我通过the h5py Google groups page从开发人员那里得到了一个答案:这是一个将在h5py1.4中修复的bug。
我最后做的是:
相关问题 更多 >
编程相关推荐