def run_ttests(simfolder): ''' Make statistical t tests :param string simfolder: relative path to simfolder ''' c = configparser.ConfigParser() c.read('{}/stosim.conf'.format((simfolder))) delim = utils.get_delimiter(c) relevant_confs = utils.get_relevant_confs(simfolder) # tell about what we'll do if we have at least one test for c in relevant_confs: if c.has_section("ttest1"): print('') print('*' * 80) print("[StoSim] Running T-tests ...") print('*' * 80) print('') break else: print("[StoSim] No T-tests specified.") for c in relevant_confs: i = 1 while c.has_section("ttest%i" % i): print("Test {}:".format(c.get('ttest%i' % i, 'name').strip('"'))) if not (c.has_option("ttest%i" % i, "set1") and c.has_option("ttest%i" % i, "set2")): print("[StoSim] T-test {} is missing one or both"\ " data set descriptions.".format(i)) break tester.ttest(simfolder, c, i, delim) i += 1
def make_plots(simfolder, plot_nrs=[]): """ generate plots as specified in the simulation conf :param string simfolder: relative path to simfolder :param list plot_nrs: a list with plot indices. If empty, plot all """ simfolder = simfolder.strip('/') #if osp.exists("%s/plots" % simfolder): # rmtree('%s/plots' % simfolder) if not osp.exists("%s/plots" % simfolder): os.mkdir('%s/plots' % simfolder) # tell about what we'll do if we have at least one plot relevant_confs = utils.get_relevant_confs(simfolder) for c in relevant_confs: if c.has_section("figure1"): print('') print('*' * 80) print("[StoSim] creating plots ...") print('*' * 80) print('') break else: print("[StoSim] No plots specified.") # Describe all options first. # These might be set in plot-settings (in each simulation config) # and also per-figure general_options = {'use-colors': bool, 'use-tex': bool, 'line-width': int, 'font-size': int, 'infobox-pos': str, 'use-y-errorbars': bool, 'errorbar-every': int } figure_specific_options = { 'name': str, 'xcol': int, 'x-range': str, 'y-range': str, 'x-label': str, 'y-label': str, 'custom-script': str } figure_specific_options.update(general_options) def get_opt_val(conf, d, section, option, t): if conf.has_option(section, option): val = c.get(section, option).strip() if t is int: val = c.getint(section, option) if t is bool: val = c.getboolean(section, option) if t is float: val = c.getfloat(section, option) # config-options with '-' are nice, but not good parameter names d[option.replace('-', '_')] = val general_settings = {} c = configparser.ConfigParser() c.read('{}/stosim.conf'.format((simfolder))) delim = utils.get_delimiter(c) for o, t in general_options.items(): get_opt_val(c, general_settings, 'plot-settings', o, t) general_params = [] if c.has_option('plot-settings', 'params'): general_params = c.get('plot-settings', 'params').split(',') for c in relevant_confs: i = 1 settings = general_settings.copy() # overwrite with plot-settings for this subsimulation for o, t in general_options.items(): get_opt_val(c, settings, 'plot-settings', o, t) if c.has_option('plot-settings', 'params'): general_params.extend(c.get('plot-settings', 'params').split(',')) while c.has_section("figure%i" % i): if i in plot_nrs or len(plot_nrs) == 0: fig_settings = settings.copy() for o, t in figure_specific_options.items(): get_opt_val(c, fig_settings, 'figure%i' % i, o, t) plot_confs = [] j = 1 while c.has_option("figure%i" % i, "plot%i" % j): # make plot settings from conf string d = utils.decode_search_from_confstr( c.get('figure%i' % i, 'plot%i' % j), sim=c.get('meta', 'name') ) # then add general param settings to each plot, if # not explicitly in there for param in general_params: if ":" in param: param = param.split(':') key = param[0].strip() if not key in list(d.keys()): d[key] = param[1].strip() # add simulation file name, then we can select accordingly if c.has_option('meta', '_subconf-filename_'): scfn = c.get('meta', '_subconf-filename_') if scfn != '' and not 'sim' in d: d['sim'] = scfn # making sure all necessary plot attributes are there if ('_name' in list(d.keys())and '_ycol' in list(d.keys()) and '_type' in list(d.keys())): plot_confs.append(d) else: print(''' [StoSim] Warning: Incomplete graph specification in Experiment %s - for plot {} in figure {}. \n Specify at least _name and _ycol.'''.format((c.get('meta', 'name'), j, i))) j += 1 plotter.plot(filepath='%s/data' % simfolder, delim=delim, outfile_name='%s/plots/%s.pdf' \ % (simfolder, fig_settings['name']),\ plots=plot_confs,\ **fig_settings) i += 1