class ctapipe.io.hdf5tableio.HDF5TableReader(**kwargs)[source]

Bases: ctapipe.io.tableio.TableReader

Reader that reads a single row of an HDF5 table at once into a Container. Simply construct a HDF5TableReader with an input HDF5 file, and call the read(path, container) method to get a generator that fills the given container with a new row of the table on each access.

Columns in the table are automatically mapped to container fields by name, and if a field is missing in either, it is skipped during read, but a warning is emitted.

Columns that were written by HDF5TableWriter and which had unit transforms applied, will have the units re-applied when reading (the unit used is stored in the header attributes).

Note that this is only useful if you want to read all information one event at a time into a container, which is not very I/O efficient. For some other use cases, it may be much more efficient to access the table data directly, for example to read an entire column or table at once (which means not using the Container data structure).

Todo: - add ability to synchronize reading of multiple tables on a key

Methods Summary


open(filename, **kwargs)

read(table_name, containers[, prefixes, …])

Returns a generator that reads the next row from the table into the given container.

Methods Documentation

open(filename, **kwargs)[source]
read(table_name, containers, prefixes=False, ignore_columns=None)[source]

Returns a generator that reads the next row from the table into the given container. The generator returns the same container. Note that no containers are copied, the data are overwritten inside.

table_name: str

name of table to read from


Container instance to fill

prefix: bool, str or list

Prefix that was added while writing the file. If True, the container prefix is taken into consideration, when comparing column names and container fields. If False, no prefix is used. If a string is provided, it is used as prefix for all containers. If a list is provided, the length needs to match th number of containers.