diff --git a/wetb/prepost/Simulations.py b/wetb/prepost/Simulations.py index 5f2412cea4d62a9f5ad12ef060d3c62a83bf8042..5953852f9733b6329fc21d61513edfb75a456512 100755 --- a/wetb/prepost/Simulations.py +++ b/wetb/prepost/Simulations.py @@ -4517,7 +4517,8 @@ class Cases(object): # TODO: test this first fname = os.path.join(post_dir, sim_id + '_statistics' + ext) dfs = misc.dict2df(df_dict2, fname, save=save, update=update, - csv=csv, xlsx=xlsx, check_datatypes=False) + csv=csv, xlsx=xlsx, check_datatypes=False, + complib=self.complib) df_dict2 = None df_dict = None @@ -4539,7 +4540,8 @@ class Cases(object): # TODO: test this first fname = os.path.join(post_dir, sim_id + '_statistics' + ext) dfs = misc.dict2df(df_dict2, fname, save=save, update=update, - csv=csv, xlsx=xlsx, check_datatypes=False) + csv=csv, xlsx=xlsx, check_datatypes=False, + complib=self.complib) return dfs @@ -4806,7 +4808,8 @@ class Cases(object): # make consistent data types, and convert to DataFrame fname = os.path.join(post_dir, sim_id + '_Leq') df_Leq = misc.dict2df(dict_Leq, fname, save=save, update=update, - csv=csv, check_datatypes=True, xlsx=xlsx) + csv=csv, check_datatypes=True, xlsx=xlsx, + complib=self.complib) # only keep the ones that do not have nan's (only works with index) return df_Leq @@ -4928,7 +4931,8 @@ class Cases(object): # make consistent data types, and convert to DataFrame fname = os.path.join(post_dir, sim_id + '_AEP') df_AEP = misc.dict2df(dict_AEP, fname, update=update, csv=csv, - save=save, check_datatypes=True, xlsx=xlsx) + save=save, check_datatypes=True, xlsx=xlsx, + complib=self.complib) return df_AEP diff --git a/wetb/prepost/misc.py b/wetb/prepost/misc.py index f5cd5cf93466285c110c6ad70b99d5e7ffaf96de..b0bd74982c05a716bea95f61a6c49a122b8ef956 100644 --- a/wetb/prepost/misc.py +++ b/wetb/prepost/misc.py @@ -1024,7 +1024,8 @@ def df_dict_check_datatypes(df_dict): def dict2df(df_dict, fname, save=True, update=False, csv=False, colsort=None, - check_datatypes=False, rowsort=None, csv_index=False, xlsx=False): + check_datatypes=False, rowsort=None, csv_index=False, xlsx=False, + complib='blosc'): """ Convert the df_dict to df and save/update if required. If converting to df fails, pickle the object. Optionally save as csv too. @@ -1088,12 +1089,12 @@ def dict2df(df_dict, fname, save=True, update=False, csv=False, colsort=None, print('updating: %s ...' % (fname), end='') try: dfs.to_hdf('%s.h5' % fname, 'table', mode='r+', append=True, - format='table', complevel=9, complib='blosc') + format='table', complevel=9, complib=complib) except IOError: print('Can not update, file does not exist. Saving instead' '...', end='') dfs.to_hdf('%s.h5' % fname, 'table', mode='w', - format='table', complevel=9, complib='blosc') + format='table', complevel=9, complib=complib) else: print('saving: %s ...' % (fname), end='') if csv: @@ -1101,7 +1102,7 @@ def dict2df(df_dict, fname, save=True, update=False, csv=False, colsort=None, if xlsx: dfs.to_excel('%s.xlsx' % fname, index=csv_index) dfs.to_hdf('%s.h5' % fname, 'table', mode='w', - format='table', complevel=9, complib='blosc') + format='table', complevel=9, complib=complib) print('DONE!!\n')