Skip to content

experiment.experiment

SimulationExperiments and helpers.

SimulationExperiment

SimulationExperiment(
    sid=None,
    base_path=None,
    data_path=None,
    ureg=None,
    **kwargs,
)

Generic simulation experiment.

Consists of models, datasets, simulations, tasks, results, processing, figures

SimulationExperiement.

:param sid: :param base_path: :param data_path: :param ureg: :param kwargs:

results property

results

Access simulation results.

Results are mapped on tasks based on the task_ids. E.g. to get the results for the task with id 'task_glciv' use

    simexp.results["task_glciv"]
    self.results["task_glciv"]

initialize

initialize()

Initialize SimulationExperiment.

Initialization must be separated from object construction due to the parallel execution of the problem later on. Certain objects cannot be serialized and must be initialized. :return:

models

models()

Define model definitions.

The child classes fill out the information.

datasets

datasets()

Define dataset definitions (experimental data).

The child classes fill out the information.

simulations

simulations()

Define simulation definitions.

The child classes fill out the information.

tasks

tasks()

Define task definitions.

The child classes fill out the information.

data

data()

Define DataGenerators including functions.

This determines the selection in the model.

All data which is accessed in a simulation result must be defined in a data generator. The data generators are important for defining the selections of a simulation experiment.

figures

figures()

Figure definition.

Selections accessed in figures and analyses must be registered beforehand via datagenerators.

Most figures do not require access to concrete data, but only abstract data concepts.

figures_mpl

figures_mpl()

Matplotlib figure definition.

Selections accessed in figures and analyses must be registered beforehand via datagenerators.

Most figures do not require access to concrete data, but only abstract data concepts.

fit_mappings

fit_mappings()

Define fit mappings.

Mapping reference data on observables. Used for the optimization of parameters. The child classes fill out the information.

reports

reports()

Define reports.

Reports are defined by a hashmap label:Data. Reports can be serialized in multiple manners.

add_data

add_data(d)

Add data to the tracked data.

add_selections_data

add_selections_data(selections, task_ids=None)

Add selections to given tasks.

The data for the selections will be part of the results.

Selections are necessary to access data from simulations. Here these selections are added to the tasks. If no tasks are given, the selections are added to all tasks.

:param reset: drop and reset all selections.

run

run(
    simulator,
    output_path=None,
    show_figures=False,
    save_results=False,
    figure_formats=None,
    reduced_selections=True,
)

Execute given experiment and store results.

evaluate_fit_mappings

evaluate_fit_mappings()

Evaluate fit mappings.

to_json

to_json(path=None, indent=2)

Convert experiment to JSON for exchange.

:param path: path for file, if None JSON str is returned :return:

to_dict

to_dict()

Convert to dictionary.

This is the basis for the JSON serialization.

from_json classmethod

from_json(json_info)

Load experiment from json path or str.

save_datasets

save_datasets(results_path)

Save datasets.

save_results

save_results(results_path)

Save results (mean timecourse).

:param results_path: :return:

create_mpl_figures

create_mpl_figures()

Create matplotlib figures.

show_mpl_figures

show_mpl_figures(mpl_figures)

Show matplotlib figures.

The figures of the serializer are created without pyplot, so that rendering does not fill its global registry; a figure it does not manage cannot show itself. Showing is the one place which needs the state machine, so a figure gets a manager here and only here.

Parameters:

Name Type Description Default
mpl_figures dict[str, FigureMPL]

the figures to show.

required

save_mpl_figures

save_mpl_figures(
    results_path, mpl_figures, figure_formats=None
)

Save matplotlib figures.

save_interactive_figures

save_interactive_figures(results_path)

Write the figures as interactive pages.

The pages are drawn by plotly, see sbmlsim.plot.serialization_plotly: matplotlib draws the static images a publication needs and plotly the pages a reader zooms and hovers over. Both read the same Figure, so the two cannot disagree about what they show.

plotly is not a dependency of sbmlsim; a run which asks for the interactive figures without it says so and writes none.

Parameters:

Name Type Description Default
results_path Path

directory of the pages.

required

Returns:

Type Description
dict[str, Path]

The path of the page of every figure, empty without plotly.

close_mpl_figures classmethod

close_mpl_figures(mpl_figures)

Close matplotlib figures.

A figure of the serializer is not in the registry of pyplot and is released when nothing refers to it any more, for which this is a no-op. A figure of figures_mpl() may well come from pyplot, and that one is closed here.

Parameters:

Name Type Description Default
mpl_figures dict[str, FigureMPL]

the figures to close.

required

ExperimentResult dataclass

ExperimentResult(experiment, output_path)

Result of a simulation experiment.

to_dict

to_dict()

Conversion to dictionary.

Used in serialization and required for reports.