从 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()