Commit 615ef457 authored by Maxime Rey's avatar Maxime Rey
Browse files

Added rename function for hdf5.

parent 60e278c1
......@@ -52,7 +52,7 @@ def h5_clean(fields,filename):
print(f'Wrong filename {filename}')
def h5_list(filepath):
def h5_list(genpath,folder):
"""
Lists the keys in an hdf5 file.
......@@ -60,8 +60,27 @@ def h5_list(filepath):
"""
import h5py
thefile = h5py.File(filepath,'r+')
print(list(thefile.keys()), len(thefile.keys()))
thefile = h5py.File(genpath+folder,'r+')
print(len(thefile.keys()), list(thefile.keys()))
def h5rename(genpath, folders, timesteps, filename):
import h5py
for folder in folders:
RamsesDir = genpath+folders
filepath = f'{RamsesDir}/ratadat/{filename}.h5'
thefile = h5py.File(filepath,'r+')
# print all keys
# print(len(thefile.keys()), list(thefile.keys()))
# Replace oldname by oldname.
for timestep in timesteps:
oldname = f"somenamingscheme_{timestep:05d}"
newname = f"diffnamingscheme_{timestep:05d}"
thefile.create_dataset(newname,data=thefile[oldname])
del thefile[oldname]
def compute_aout(dt=10, z_init=15, nbins=10, zmin=None, checktimes=False):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment