数组的一个括号中有 2 个值,左边是 I,右边是信号的 Q 值。 hdf5 文件非常大,目前我正在尝试将每个括号内的 2 个值分开。我查到的任何内容都对这项工作没有帮助。正如我在标题中所说,文件中的任何内容都没有标签或标题。给出的只是 X、Y 和 Z 轴
我尝试过使用 np.array 和 pandas 进行一些实验,但我对更复杂的数据集相当陌生。
此代码创建一个包含 5 个数据集的简单 HDF5,然后演示如何访问它们以获取 dtype 和形状。注意:您只需要阅读和打印的后半部分。修改文件名以匹配。
获得该信息后,请添加到您的问题中。然后可以修改这个答案以显示解决方案的其余部分。
import h5py
import numpy as np
with h5py.File('SO_78045268.h5','w') as h5f:
h5f.create_dataset('signals',data=np.arange(10).reshape(5,2))
h5f.create_dataset('axis',data=np.arange(5))
h5f.create_dataset('X',data=np.arange(5))
h5f.create_dataset('Y',data=np.arange(5,10))
h5f.create_dataset('Z',data=np.arange(10,15))
with h5py.File('SO_78045268.h5') as h5f:
for name, h5_obj in h5f.items():
if isinstance(h5_obj, h5py.Dataset):
print(f'For dataset: {name}; ')
print(f'dtype: {h5_obj.dtype}, shape: {h5_obj.shape}')