开始使用免费开始使用

从 HDF5 文件中提取数据

在本练习中,您将从 HDF5 文件中提取 LIGO 实验的真实数据,并对其进行可视化。

为此,您需要先探索 HDF5 分组 'strain'

本练习是课程的一部分

Python 数据导入入门

查看课程

练习说明

  • 将 HDF5 分组 data['strain'] 赋值给 group
  • for 循环中,打印 group 中 HDF5 分组的键。
  • 将时间序列数据 data['strain']['Strain'] 赋值为名为 strain 的 NumPy 数组。
  • num_samples 设为 10000,即我们希望采样的时间点数量。
  • 运行其余代码,以生成 LIGO_data.hdf5 中时间序列数据的图。

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Get the HDF5 group: group


# Check out keys of group
for key in ____:
    print(____)

# Set variable equal to time series data: strain


# Set number of time points to sample: num_samples


# Set time vector
time = np.arange(0, 1, 1/num_samples)

# Plot data
plt.plot(time, strain[:num_samples])
plt.xlabel('GPS Time (s)')
plt.ylabel('strain')
plt.show()
编辑并运行代码