diff --git a/wetb/prepost/Simulations.py b/wetb/prepost/Simulations.py index 751149b931c73cb65da32805d9f7748ffc459f6b..5f2412cea4d62a9f5ad12ef060d3c62a83bf8042 100755 --- a/wetb/prepost/Simulations.py +++ b/wetb/prepost/Simulations.py @@ -2585,7 +2585,7 @@ class ErrorLogs(object): self.err_init[' *** ERROR *** Error findin'] = len(self.err_init) # *** ERROR *** In body actions self.err_init[' *** ERROR *** In body acti'] = len(self.err_init) - # *** ERROR *** Command unknown + # *** ERROR *** Command unknown and ignored self.err_init[' *** ERROR *** Command unkn'] = len(self.err_init) # *** ERROR *** ERROR - More bodies than elements on main_body: tower self.err_init[' *** ERROR *** ERROR - More'] = len(self.err_init) @@ -3615,6 +3615,7 @@ class Cases(object): self.loadstats = kwargs.get('loadstats', False) self.rem_failed = kwargs.get('rem_failed', True) self.config = kwargs.get('config', {}) + self.complib = kwargs.get('complib', 'blosc') # determine the input argument scenario if len(args) == 1: if type(args[0]).__name__ == 'dict': @@ -3853,7 +3854,7 @@ class Cases(object): return def cases2df(self): - """Convert the cases dict to a DataFrame and save as excel sheet""" + """Convert the cases dict to a DataFrame and check data types""" tag_set = [] @@ -4371,7 +4372,7 @@ class Cases(object): fname = os.path.join(respath, resfile + '_postres.h5') print(' saving post-processed res: %s...' % fname, end='') df_new_sigs.to_hdf(fname, 'table', mode='w', format='table', - complevel=9, complib='blosc') + complevel=9, complib=self.complib) print('done!') del df_new_sigs @@ -4588,18 +4589,18 @@ class Cases(object): print('updating statistics: %s ...' % (post_dir + sim_id), end='') try: dfs.to_hdf('%s.h5' % fpath, 'table', mode='r+', append=True, - format='table', complevel=9, complib='blosc') + format='table', complevel=9, complib=self.complib) except IOError: print('Can not update, file does not exist. Saving instead' '...', end='') dfs.to_hdf('%s.h5' % fpath, 'table', mode='w', - format='table', complevel=9, complib='blosc') + format='table', complevel=9, complib=self.complib) else: print('saving statistics: %s ...' % (post_dir + sim_id), end='') if csv: dfs.to_csv('%s.csv' % fpath) dfs.to_hdf('%s.h5' % fpath, 'table', mode='w', - format='table', complevel=9, complib='blosc') + format='table', complevel=9, complib=self.complib) print('DONE!!\n') diff --git a/wetb/prepost/h2_vs_hs2.py b/wetb/prepost/h2_vs_hs2.py index 5dcc64cff5759a0958a0228027b283840f5617bc..5f5b0b79db3be60839c1bb66e497b43c7780dc91 100644 --- a/wetb/prepost/h2_vs_hs2.py +++ b/wetb/prepost/h2_vs_hs2.py @@ -459,7 +459,7 @@ class Sims(object): return tune_tags - def post_processing(self, statistics=True, resdir=None, + def post_processing(self, statistics=True, resdir=None, complib='blosc', calc_mech_power=False): """ Parameters @@ -478,7 +478,7 @@ class Sims(object): # logfile analysis is written to a csv file in logfiles directory # ========================================================================= # load the file saved in post_dir - cc = sim.Cases(post_dir, self.sim_id, rem_failed=False) + cc = sim.Cases(post_dir, self.sim_id, rem_failed=False, complib=complib) if resdir is None: # we keep the run_dir as defined during launch @@ -771,6 +771,29 @@ class MappingsH2HS2(object): def _body_structure_modes_hs(self, fname): self.body_freq_hs = hs2.results().load_cmb_df(fname) + def save(self, fpath): + """Save all the HAWC2 mappings created to fixed width text files + similar to HAWCStab2. + """ + + fname = 'hawc2_ss_mean_power_curve.txt' + tmp = self.pwr_h2_mean.copy() + tmp.set_index('windspeed', inplace=True) + tmp.index.name = 'windspeed' + header = ''.join(['%16s' % k for k in self.pwr_h2_mean.columns]) + header = ' windspeed' + header + np.savetxt(os.path.join(fpath, fname), tmp.to_records(), header=header, + fmt='% 01.06e ') + + fname = 'hawc2_ss_std_power_curve.txt' + tmp = self.pwr_h2_mean.copy() + tmp.set_index('windspeed', inplace=True) + tmp.index.name = 'windspeed' + header = ''.join(['%16s' % k for k in self.pwr_h2_mean.columns]) + header = ' windspeed' + header + np.savetxt(os.path.join(fpath, fname), tmp.to_records(), header=header, + fmt='% 01.06e ') + class Plots(object): """