從你的 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()