我有许多包含复数数组的HDF5数据集,这些数据集是使用Python和h5py
创建的。例如:
import numpy, h5py
with h5py.File("test.h5", "w") as f:
f["mat"] = numpy.array([1.0 + .5j, 2.0 - 1.0j], dtype=complex)
HDF5 没有本地的复数概念,因此 h5py
将其存储为复合数据类型,并使用 "r" 和 "i" 作为实部和虚部的字段。
如何使用 HDF5.jl
在 Julia 中加载这样的复数数组?
编辑:明显的尝试是
using HDF5
h5open("test.h5", "r") do fd
println(read(fd, "mat"))
end
返回一种晦涩难懂的响应:
HDF5Compound(Uint8[0,0,0,0,0,0,240,63,0,0,0,0,0,0,224,63,0,0,0,0,0,0,0,64,0,0,0,0,0,0,240,191],Type[Float64,Float64],ASCIIString["r","i"],Uint64[0,8])