bjmorgan / kinisi

A Python package for estimating diffusion properties from molecular dynamics simulations.
https://kinisi.readthedocs.io
MIT License
53 stars 11 forks source link

Adding a diff.save() method to save the whole DiffusionAnalyzer object #15

Closed gabkrenzer closed 2 years ago

gabkrenzer commented 2 years ago

This would be very useful to then post-process soundly.

arm61 commented 2 years ago

This is a good idea, implementation would involve a .save() method and a .load() method for the Analyzer class, should be pretty straight forward to implement with pickle.

bjmorgan commented 2 years ago

Ideally this would use a format with a well-defined specification (e.g. JSON) rather than pickle, but I appreciate this would take more development effort.

arm61 commented 2 years ago

Actually it shouldn't be too mush to have as_dict and from_dict methods that can be dumped to JSON.

arm61 commented 2 years ago

Hmm. It is looking like it is more work than I expected to have json serialisation (not impossible though). In the meantime, I recommending pickling your own objects (https://pythonexamples.org/python-pickle-class-object/).

arm61 commented 2 years ago

I have a potential solution which writes to HDF5 files. Happy to hear thoughts on the PR

arm61 commented 2 years ago

I have merged this solution. It will be part of a future 0.3.10 release in the coming weeks.