Created
March 7, 2019 13:05
-
-
Save sergeyprokudin/d77a4f19737cda9864f5cc43558d454a to your computer and use it in GitHub Desktop.
Small function to dave dictionary of numpy arrays to H5 file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import h5py | |
import os | |
def save_h5(savepath, arr_dict): | |
if os.path.exists(savepath): | |
os.remove(savepath) | |
h5ds = h5py.File(savepath) | |
for arr_name in arr_dict.keys(): | |
h5ds.create_dataset(arr_name, data=arr_dict[arr_name], compression='gzip', compression_opts=4) | |
h5ds.close() | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment