diff --git a/src/mdevaluate/utils.py b/src/mdevaluate/utils.py index 5f48fbf..4fc47fe 100644 --- a/src/mdevaluate/utils.py +++ b/src/mdevaluate/utils.py @@ -3,6 +3,7 @@ Collection of utility functions. """ import functools from time import time as pytime +from subprocess import run from types import FunctionType import numpy as np @@ -500,3 +501,18 @@ def timing(function): return result return wrap + +def cleanup_h5(hdf5_file) -> None: + hdf5_temp_file = f"{hdf5_file[:-3]}_temp.h5" + run( + [ + "ptrepack", + "--chunkshape=auto", + "--propindexes", + "--complevel=9", + "--complib=blosc", + hdf5_file, + hdf5_temp_file, + ] + ) + run(["mv", hdf5_temp_file, hdf5_file]) \ No newline at end of file