A collection of code samples to illustrate reading and writing HDF5 files from Python using the PyTables module.
create_table.py
: creates an HDF5 filetest.h5
that has a root-level groupparticles
containing a data setinitial
that holds the particles mass, x- and y-coordinates, x- and y-component of its velocity as floating point numbers, and an ID as an integer value.add_table.py
: adds a data setfinal
in theparticles
group oftest.h5
.add_array.py
: adds a groupfields
totest.h5
, and inserts an 2D array as data sethiggs
. The data is stored as a numpy array.compute_avg.py
: reads thehiggs
data set fromtest.h5
, as numpy array, and computes the average value of all points.query_table.py
: select only the particles in theinitial
data set that have a velocity above a certain threshold, and print them.particle.py
: defines a classParticle
.test.h5
: test HDF5 file.write_large_dataset.py
: script to create an HDF5 file with a large dataset, useful to experiment with various forms of reading the dataread_large_dataset.py
: script to experiment with various read modes, reading an entire dataset, reading non-contiguous rows and columnsh5py.ipynb
: Jupyter notebook illustrating the h5py package.