From 2d7905315d078937934bacccafddbfe8264ee09d Mon Sep 17 00:00:00 2001 From: Sebastian Kloth Date: Thu, 21 Dec 2023 16:39:30 +0100 Subject: [PATCH] Added cleanup_h5 to utils.py --- src/mdevaluate/utils.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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