Skip to content

Add universal saving/loading functions based on h5 format#165

Open
cowalz wants to merge 2 commits into
dschick:developfrom
cowalz:develop
Open

Add universal saving/loading functions based on h5 format#165
cowalz wants to merge 2 commits into
dschick:developfrom
cowalz:develop

Conversation

@cowalz
Copy link
Copy Markdown

@cowalz cowalz commented Apr 7, 2025

Added to function (save_to_h5 and load_from_h5) to the helpers.py, which should provide a more streamlined data management with unified variable names. The usage of attributes in principle allows saving all relevant parameters of the simulation run as metadata in the h5 file. The h5 format also allows compression, significantly reducing the file size by about 4x to 5x.
A working example is provided in the example.py or .ipynb scripts. The generated h5 files can be read with python or viewed for example with the h5web extension in Visual Studio Code.

I am not sure if there is a convenient way to automatically add all available metadata, like excitation pulse parameters and sample composition to the h5 file, so for now the function only adds the sample structure and composition information as attributes.

@dschick
Copy link
Copy Markdown
Owner

dschick commented Apr 8, 2025

Hi @cowalz ,

Thanks a lot for this PR!
Could you maybe motivate it a little bit more so we can discuss your solution?

There is already a possibility to save simulation results of all simulation objects as .npy files using a hashing algorithm for the simulation parameters and the sample structures.

In the former Matlab version, I also implemented a way to store the sample structure alone in some kind of XML format.

Please feel free to open an issue for this discussion.

Best

Daniel

@cowalz
Copy link
Copy Markdown
Author

cowalz commented Apr 9, 2025

Hi Daniel, thanks for your feedback. I will open an Issue related to this PR where we can further discuss this idea:
#166

Best Constantin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants