DEMutilities. analyze_parameter_study

In order to be able to use this module import it like this:

import DEMutilities.analyze_parameter_study
#or assign it to a shorter name
import DEMutilities.analyze_parameter_study as ana
DEMutilities.analyze_parameter_study.analyze_parallel(script_name, dir_list, out_name='ana_out.txt', params_pickle_name='ana.pickle', N_threads=-1, verbose=False)

Runs script ‘script_name’ in parallel in the directories in the dir_list.

The assumption is, that the script will somehow analyse the simulations and print the results. If the results should be gathered (see ‘result_dictionaries’), then parameters should be printed one per line in the format ‘parameter_name : value’.

All other stuff in that file will be ignored. Example usage - assuming a script that does what you want for a single simulation:

from DEMutilities.analyze_parameter_study import *
import pprint, glob
fname = './ana_out.txt'
analyze_parallel( './', dir_list, out_name=fname)
#Ok, let's gather the results for R:
res = result_dictionaries( dir_list,fname )
header, vals = make_result_table( res )
header = clean_header(header)
write_results_table( header,vals )

Can be used to shorten the parameter names in the header retrieved by make_result_table to the shortest unique version.

DEMutilities.analyze_parameter_study.delcolumn(matrix, i)

Efficiently deleting a column from a “python matrix” - list of lists.

DEMutilities.analyze_parameter_study.lex_sort_vals(header, vals, sort_to_names)
DEMutilities.analyze_parameter_study.make_result_table(dict_list, ignore_non_scalars=True, crop_path=True)

From a dictionary list (gathered by result dictionaries), we return two lists: the header and a list of lists of values, hence a table of all parameters. If ‘ignore_non_scalars’ is True (default), the resulting list of lists of values will only contain floats/ints, leaving out also those headers whose values have a different type.

DEMutilities.analyze_parameter_study.result_dictionaries(dir_list, fname, parameters_fname='./params.pickle', orig_params_dict=None, skip_empty=False)

Constructs a list of dictionaries containing the result values (one per line in the format ‘parameter_name’ : value) in the files with name ‘fname’ in the directories in dir_list, adding a dictionary with the simulation parameters found in that directory.

If fname ends in ‘.pickle’, it is assumed that the file contains a dictionary that we only need to append.

DEMutilities.analyze_parameter_study.write_results_table(header, values, fname='results.csv', omit_empty=False)

Writes a csv file that can be read by e.g. R (or excel, or...).