From af4aeb2ae76e1a5ba7375e42f4255821b72c8729 Mon Sep 17 00:00:00 2001 From: David Robert Verelst <dave@dtu.dk> Date: Mon, 3 Jul 2017 11:56:17 +0200 Subject: [PATCH] prepost: some fixes for dlcplot related issues --- wetb/prepost/dlcplots.py | 10 +++++++--- wetb/prepost/dlctemplate.py | 7 +++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/wetb/prepost/dlcplots.py b/wetb/prepost/dlcplots.py index 2e8351c9..78fef068 100644 --- a/wetb/prepost/dlcplots.py +++ b/wetb/prepost/dlcplots.py @@ -57,6 +57,9 @@ def merge_sim_ids(sim_ids, post_dirs, post_dir_save=False): """ # map the run_dir to the same order as the post_dirs, labels run_dirs = [] + # avoid saving merged cases if there is only one! + if type(sim_ids).__name__ == 'list' and len(sim_ids) == 1: + sim_ids = sim_ids[0] # if sim_id is a list, combine the two dataframes into one df_stats = pd.DataFrame() @@ -99,15 +102,16 @@ def merge_sim_ids(sim_ids, post_dirs, post_dir_save=False): pass else: fpath = os.path.join(post_dir, '-'.join(sim_ids) + '.h5') + fmerged = fpath.replace('.h5', '_statistics.h5') if ii == 0: # and save somewhere so we can add the second data frame on # disc - df_stats.to_hdf(fpath, 'table', mode='w', format='table', + df_stats.to_hdf(fmerged, 'table', mode='w', format='table', complevel=9, complib='blosc') print('%s merged stats written to: %s' % (sim_id, fpath)) else: # instead of doing a concat in memory, add to the hdf store - df_stats.to_hdf(fpath, 'table', mode='r+', format='table', + df_stats.to_hdf(fmerged, 'table', mode='r+', format='table', complevel=9, complib='blosc', append=True) print('%s merging stats into: %s' % (sim_id, fpath)) # df_stats = pd.concat([df_stats, df_stats2], ignore_index=True) @@ -453,7 +457,7 @@ def plot_dlc_stats(df_stats, plot_chans, fig_dir_base, labels=None, mfcs3 = ['r', 'w'] stds = ['r', 'b'] - required = ['[DLC]', '[run_dir]', '[wdir]', '[Windspeed]'] + required = ['[DLC]', '[run_dir]', '[wdir]', '[Windspeed]', '[res_dir]'] cols = df_stats.columns for col in required: if col not in cols: diff --git a/wetb/prepost/dlctemplate.py b/wetb/prepost/dlctemplate.py index a989bd8d..07c8ea97 100644 --- a/wetb/prepost/dlctemplate.py +++ b/wetb/prepost/dlctemplate.py @@ -393,7 +393,8 @@ def post_launch(sim_id, statistics=True, rem_failed=True, check_logs=True, # add_sigs = {name:expr} # in addition, sim_id and case_id are always added by default - tags = ['[Case folder]'] + tags = ['[Case folder]', '[run_dir]', '[res_dir]', '[DLC]', + '[wsp]', '[Windspeed]', '[wdir]'] add = None # general statistics for all channels channel # set neq=None here to calculate 1Hz equivalent loads @@ -538,7 +539,6 @@ if __name__ == '__main__': P_RUN, P_SOURCE, PROJECT, sim_id, P_MASTERFILE, MASTERFILE, POST_DIR \ = dlcdefs.configure_dirs(verbose=True) - # create HTC files and PBS launch scripts (*.p) if opt.prep: print('Start creating all the htc files and pbs_in files...') @@ -569,12 +569,11 @@ if __name__ == '__main__': for nr in [1, 2, 3]: rpl = (nr, nr, node_nr, comp) chans.append('blade%i-blade%i-node-%03i-momentvec-%s' % rpl) - plot_chans['$M_%s B123_{%i}$' % (comp, node_lab)] = chans + plot_chans['$M_%s B123_{%s}$' % (comp, node_lab)] = chans chans = [] # combine blade 1,2,3 pitch angle stats into a single plot for nr in [1, 2, 3]: - rpl = (nr, nr, node_nr, comp) chans.append('bearing-pitch%i-angle-deg' % nr) plot_chans['$B123_{pitch}$'] = chans -- GitLab