pencil.pipelines.makedict ========================= .. py:module:: pencil.pipelines.makedict Functions --------- .. autoapisummary:: pencil.pipelines.makedict.parameter_table pencil.pipelines.makedict.trim_table pencil.pipelines.makedict.make_sims_dict Module Contents --------------- .. py:function:: parameter_table(filename, quiet=True) parameter_table(filename,quiet=True) Extract and construct a table from a user file filename :param filename: 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). :type filename: string :param quiet: Flag to print output. :type quiet: bool :rtype: Table of full list of all parameter combinations .. rubric:: 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') .. py:function:: trim_table(params, quiet=True) trim_table(params,quiet=True) Examples of operations to reduce the table or add columns and rows :param params: Panda dataframe table. :type params: obj :param quiet: Flag to print output. :type quiet: bool :returns: **params** :rtype: Condensed table .. rubric:: 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 .. rubric:: 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 .. py:function:: 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 :param params: Extracts list of parameters from userfile keys. :type params: obj :param quiet: Flag to print output. :type quiet: bool :param prefix: Prefix to be added to the names of the generated simulations. Nothing by default. :type prefix: string :returns: **simset** :rtype: dictionary array of parameters per simulation .. rubric:: 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'}}