hdf5 saving module
This script provides functionality to serialize Python dictionaries and class instances into HDF5 files using the h5py library.
It supports nested structures, compresses NumPy arrays, and stores primitive types as attributes.
These functions are used to save the simulations into .h5 files.
- class aurelia_hdf5_saving.DictGroup(parent, name, data)
A helper class that recursively stores dictionary contents into HDF5 groups and datasets.
- aurelia_hdf5_saving.convert_strings_to_utf8(obj)
This function recursively converts strings in objects to UTF-8 encoded bytes for HDF5 compatibility. Handles strings, lists, tuples, dictionaries, and objects with
__dict__.
- aurelia_hdf5_saving.save_class_to_hdf5(obj, folderpath, filename, groupname=None)
Saves a class into an HDF5 file.
args:
obj: A python object. Object to save.folderpath: A string. Path to save the file.filename: A string. Name of the HDF5 file.groupname: A string. Name of the group inside the file.
- aurelia_hdf5_saving.save_dict_to_hdf5(dict_obj, folderpath, filename, groupname)
Saves a dictionary into an HDF5 file.
args:
dict_obj: A python dictionary. Dictionary to save.folderpath: A string. Path to save the file.filename: A string. Name of the HDF5 file.groupname: A string. Name of the group inside the file.