pencil.pipelines.makedict
Functions
|
parameter_table(filename,quiet=True) |
|
trim_table(params,quiet=True) |
|
make_sims_dict(params,quiet=True) |
Module Contents
- pencil.pipelines.makedict.parameter_table(filename, quiet=True)
parameter_table(filename,quiet=True)
Extract and construct a table from a user file filename
- Parameters:
filename (string) – Text file with parameter to each line, parameter name and list of values all separated by colons. Parameter name (first argument in each line) should give full path (see example below).
quiet (bool) – Flag to print output.
- Return type:
Table of full list of all parameter combinations
Examples
Example file format python/pencil/pipelines/example_filename.txt >>> param_table = pc.pipelines.parameter_table(“example_filename.txt”) >>> param_table.columns Index([‘run.in/viscosity_run_pars/nu’, ‘run.in/viscosity_run_pars/ivisc’,
‘run.in/viscosity_run_pars/nu_hyper3’, ‘cparam.local/nxgrid’, ‘run.in/entropy_run_pars/chi_hyper3’, ‘run.in/entropy_run_pars/iheatcond’],
dtype=’object’)
- pencil.pipelines.makedict.trim_table(params, quiet=True)
trim_table(params,quiet=True)
Examples of operations to reduce the table or add columns and rows
- Parameters:
params (obj) – Panda dataframe table.
quiet (bool) – Flag to print output.
- Returns:
params
- Return type:
Condensed table
Notes
Call this script after full table from parameter_table(filename) and before creating dictionary of simulation parameters using make_sims_dict(params). Examples are given below and other options can be seen using https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html
Examples
#Remove rows corresponding to ivisc parameters not required params = params[params[‘run.in/viscosity_run_pars/ivisc’] != “[‘nu-shock’,’nu-hyper3’]” #When changing src parameter set compile to true params[‘compile’][params[‘cparam.local/nxgrid’] == ‘800’] = True
- pencil.pipelines.makedict.make_sims_dict(params, quiet=True, prefix='')
make_sims_dict(params,quiet=True)
Extracting values from pandas table to generate a nested dictionary simset which can be used by clone_sims to set up simulation array
- Parameters:
params (obj) – Extracts list of parameters from userfile keys.
quiet (bool) – Flag to print output.
prefix (string) – Prefix to be added to the names of the generated simulations. Nothing by default.
- Returns:
simset
- Return type:
dictionary array of parameters per simulation
Examples
>>> simset = pc.pipelines.make_sims_dict(params) >>> simset['nu1e-3nu_hyper31e-9nxgrid400chi_hyper31e-9'] {'run.in' : {'viscosity_run_pars': {'nu' : ' 1e-3', 'ivisc' : " ['nu-shock', 'nu-const', 'nu-hyper3']", 'nu_hyper3' : ' 1e-9'}, 'entropy_run_pars' : {'chi_hyper3': ' 1e-9', 'iheatcond': " 'hyper3'"}}, 'cparam.local': {'nxgrid' : ' 400'}}