開始使用免費開始

從你的 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()
編輯並執行程式碼