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

Bases: 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=None, 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 classes to fill

prefix: bool, str or list

Prefix that was added while writing the file. If None, the prefix in the file are used. This only works when the mapping from column name without prefix to container is unique. If True, the default_prefix attribute of the containers is used 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.