IniziaInizia gratis

Using h5py to import HDF5 files

The file 'LIGO_data.hdf5' is already in your working directory. In this exercise, you'll import it using the h5py library. You'll also print out its datatype to confirm you have imported it correctly. You'll then study the structure of the file in order to see precisely what HDF groups it contains.

You can find the LIGO data plus loads of documentation and tutorials here. There is also a great tutorial on Signal Processing with the data here.

Questo esercizio fa parte del corso

Introduction to Importing Data in Python

Visualizza il corso

Istruzioni dell'esercizio

  • Import the package h5py.
  • Assign the name of the file to the variable file.
  • Load the file as read only into the variable data.
  • Print the datatype of data.
  • Print the names of the groups in the HDF5 file 'LIGO_data.hdf5'.

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

# Import packages
import numpy as np
import ____

# Assign filename: file


# Load file: data
data = h5py.File(____, ____)

# Print the datatype of the loaded file


# Print the keys of the file
for key in ____:
    print(____)
Modifica ed esegui il codice