Save data¶
- encore.data.save_data.save_data_to_hdf5_file(path: Path, data_dict: dict)¶
Saves a python dictionary structure to a file in the specified path.
Uses the function save_data_to_hdf5 to recursively save the contents of the dictionary to a path, creating the necessary groups and datasets.
- Parameters:
path (Path) – Path of the output file. Must be .h5 file
data_dict (dict) – Dictionary with the variables to save.
- encore.data.save_data.save_dict_to_hdf5(group: Group, data: dict | list | int | float | str | ndarray)¶
Recursively saves data to an HDF5 file group.
This method iterates through a dictionary and saves its contents to the provided HDF5 group. If a value in the dictionary is another dictionary, it creates a subgroup and recursively saves its contents. If the value is a list, it attempts to create a dataset in the group, catching exceptions if the data cannot be saved. Datasets are stored using a custom compression level 3 with gzip. For other data types, the method directly stores the value in the group.
- Parameters:
group (h5py.Group) – The HDF5 group to which the data will be saved.
data (dict) – The data to be saved, which can be a dictionary, list, or other types.