HDF5InputOutput#

class pybrops.core.io.HDF5InputOutput.HDF5InputOutput[source]#

Bases: object

Abstract class for defining HDF5 input/output functionality.

This abstract class defines two functions with the following purposes:

  • to_hdf5 - write an object to an HDF5 file.

  • from_hdf5 - load an object from an HDF5 file.

Methods

from_hdf5

Read an object from an HDF5 file.

to_hdf5

Write an object to an HDF5 file.

abstract classmethod from_hdf5(filename, groupname)[source]#

Read an object from an HDF5 file.

Parameters:
  • filename (str, Path, h5py.File) – If str, an HDF5 file name from which to read. If Path, an HDF5 file name from which to read. If h5py.File, an opened HDF5 file from which to read.

  • groupname (str, None) – If str, an HDF5 group name under which object data is stored. If None, object is read from base HDF5 group.

Returns:

out – An object read from an HDF5 file.

Return type:

HDF5InputOutput

abstract to_hdf5(filename, groupname, overwrite)[source]#

Write an object to an HDF5 file.

Parameters:
  • filename (str, Path, h5py.File) – If str, an HDF5 file name to which to write. If Path, an HDF5 file path to which to write. If h5py.File, an opened HDF5 file to which to write.

  • groupname (str, None) – If str, an HDF5 group name under which object data is stored. If None, object is written to the base HDF5 group.

  • overwrite (bool) – Whether to overwrite values in an HDF5 file if a field already exists.

Return type:

None