Analyse API

Get data

Get parameters

runana.analyse.read_input_files(workdir, indices=[], read_func=<function read_input_files_f90nml>)[source]

Read information from input files.

Recursively searches through all subdirectories of workdir. read_func is run in any directory containing a file named ‘hostname.txt’, and the result is stored in a ParamDict, with the path in tuple-form as key. This ParamDict is returned.

If indices is given as a non-empty list, the indices in this argument will be used instead of recursive search

Subdirectories of a directory with a ‘hostname.txt’ file are not searched.

class runana.analyse.ParamDict[source]

Dictionary that holds dictionaries of parameters

ParamDict.diff()[source]

Call dictdiff() on ParamDict object

ParamDict.unpack_list_values()[source]

Takes any numerical parameter value in ParamDict object that is a list and packs it into individual slots with name numparam_name + idx

Works in-place

class runana.analyse.ChangedParams(param_dicts, *args, **kwargs)[source]

Parameters that changed. Derived from dict

Parameters:param_dicts (dict) – Dictionary containing dictionaries of parameters, in the form returned from e.g. collect_from_all()
ChangedParams.groupby_varname()[source]

Groups elements according to the name of the variable.

Returns a dictionary containing the values of the variables, and another with all the pairs of runs

class runana.analyse.Seqs(param_dicts, *args, **kwargs)[source]

Seqeunces of related runs

Parameters:param_dicts (dict) – Dictionary containing dictionaries of parameters, in the form returned from e.g. collect_from_all()
runana.input_file_handling.read_input_files_f90nml(patterns=['*.nml'], read_one_file=<function read_and_flatten_namelist>)[source]

Read the all files matching patterns with f90nml.read()

The namelists are flattened and supersetted, the resulting dict is returned

runana.input_file_handling.read_input_files_upname(patterns=['*.inp'])[source]

Read the all files matching patterns with read_upname_file()

The data from all the files is supersetted and the resulting dict is returned

runana.input_file_handling.read_input_files_positional(patterns=['*.inp'])[source]

Read the all files matching patterns with read_positional_file()

The data from all the files is supersetted and the resulting dict is returned

runana.input_file_handling.read_upname_file(filename)[source]

Reads file in upname format

In this format the names of variables are given on a line, with the values on the following line. Each variable/name should be seperated by at least two whitespaces or a tab. Each set of names/values lines should be seperated by at least one blank line

runana.input_file_handling.read_positional_file(filename)[source]

Reads input file

A dictionary is returned, the keys of which are the tuples (iline,iword) with the line and word index of the value. Each variable/name should be seperated by at least two whitespaces, a comma or a tab.

runana.analyse.groupby_n_var_params(dict_w_params, n_var_params=1)[source]

Convenience function for finding sets of data for which n_var_params parameters are changing

Get other stuff

runana.analyse.make_collector_function(workdir, read_func, *args, **kwargs)[source]

Returns a function that runs read_func(*args,**kwargs) in the directory that is the join of workdir and the argument to the function

runana.analyse.prepend_dir(workdir)[source]

Returns a function that takes a tuple of directories and returns the combination of those into a path, with workdir prepended

runana.analyse.read_from_dir(read_func, workdir)[source]

Composes read_func with prepend_dir(workdir)

runana.analyse.dictdiff(alldicts)[source]

In-place removes all key:value pairs that are shared across all dicts

Parameters:alldicts (dict) – a dictionary containing dictionaries

Analyse with pandas API

This module requires the pandas package

class runana.analyse_pandas.SeqsDataFrame(data=None, index: Axes | None = None, columns: Axes | None = None, dtype: Dtype | None = None, copy: bool | None = None)[source]
SeqsDataFrame.import_from_seq(seqsnew, varvals, inplace=False)[source]

Converts the seqs object into a SeqsDataFrame

SeqsDataFrame.calc_convergence()[source]

Calculate an estimate for relative convergence error.

Calculates (O2-O1)/O2*x2/(x2-x1) where O are values and x are numerical parameters, which is an estimate of the difference between the value calculated at the given numerical parameter and the “true” value of the fully converged limit.

All numerical parameter values have to be scalar and numeric.

Returns a new SeqsDataFrame.

SeqsDataFrame.plot_(outfile, logx=False, logy=False, grid=False, param_panda=None)[source]

Requires numpy and matplotlib

runana.analyse_pandas.return_dict_element(dict_, error=<class 'KeyError'>)[source]

Returns a function that returns dict_[arg], while ignoring error

runana.analyse_pandas.make_a_seq_panda(dict_w_params)[source]

Convenience function for finding sequences of data, and putting them in a Pandas structure

Read numbers API

runana.read_numbers.read_number_from_file(fname, inumber, pattern='')[source]
runana.read_numbers.read_last_number_from_file(fname, pattern='')[source]
runana.read_numbers.read_column_from_file(fname, icolumn, pattern='')[source]
runana.read_numbers.read_file_one_block(fname)[source]
runana.read_numbers.read_file_sev_blocks(fname)[source]

Matplotlib managers

Context managers for using matplotlib. Use these together with pythons with statement

class runana.matplotlib_managers.plot_manager(outfile, print_outfile=True, *args, **kwargs)[source]

Creates pdf file using matplotlib.backends.backend_pdf.PdfPages() and returns the handle to this pdf.

*args and *kwargs are passed to PdfPages
class runana.matplotlib_managers.single_fig_manager(pp, *args, **kwargs)[source]

Create a matplotlib.figure.Figure

args and kwargs are passed to the Figure constructor

Parameters:pp (matplotlib.backends.backend_pdf.PdfPages) – handle that has a savefig method
class runana.matplotlib_managers.single_ax_manager(pp, *args, **kwargs)[source]

Create an axis with a single subplot in a Figure object.

Subclassed from single_fig_manager, and all the arguments are the same

runana.matplotlib_managers.plot_ax_manager(outfile, *args, **kwargs)[source]

Create a pdf with name outfile containing one plot