Skip to content
Snippets Groups Projects
Commit 8578bfb8 authored by Yngve Levinsen's avatar Yngve Levinsen
Browse files

add force flag to savetohdf

by default false. if true overwrite existing group
parent e22267a7
No related branches found
No related tags found
No related merge requests found
......@@ -740,15 +740,21 @@ class density_file:
self.Np=self._sum_merge(o,'Np')
self.Nrun+=o.Nrun
def savetohdf(self,filename='Density.h5',group='TraceWin'):
def savetohdf(self,filename='Density.h5',group='TraceWin', force=False):
'''
Saves data to HDF5
'''
import h5py
import h5py,sys
fout = h5py.File(filename,'a')
if group in fout:
del fout[group]
if force:
del fout[group]
else:
if sys.flags.debug:
print("Group {} already exist in {}".format(group,filename))
return
group = fout.create_group(group)
# header attributes..
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment