Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ See also our [versioning policy](https://amici.readthedocs.io/en/latest/versioni
* Model output directory keyword arguments have been harmonized:
What was previously `model_output_dir`, `output_dir`, `outdir` is now
consistently called `output_dir` across the API.
* Plotting functions have been moved from `amici.plotting` to
`amici.sim.sundials.plotting`. The `model` argument has been removed.

**Features**

Expand Down
10 changes: 5 additions & 5 deletions doc/examples/example_errors.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,10 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "42b79264344ba95f",
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": [
"# Create a copy of this simulation condition\n",
"edata = ExpData(res[EDATAS][0])\n",
Expand All @@ -265,9 +264,10 @@
"rdata = run_simulation(amici_model, amici_solver, edata)\n",
"\n",
"# Visualize state trajectories\n",
"plot_state_trajectories(rdata, model=amici_model)\n",
"plot_state_trajectories(rdata)\n",
"plt.yscale(\"log\")"
]
],
"id": "fcebaf5d7951e1"
},
{
"cell_type": "markdown",
Expand Down
6 changes: 3 additions & 3 deletions doc/examples/example_petab/petab_v2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
"source": [
"rdata = result.rdatas[0]\n",
"edata = result.edatas[0]\n",
"plot_observable_trajectories(rdata, model=simulator.model, edata=edata)"
"plot_observable_trajectories(rdata, edata=edata)"
],
"id": "d6bbefc2e3d3ccbc"
},
Expand Down Expand Up @@ -197,8 +197,8 @@
"metadata": {},
"outputs": [],
"source": [
"plot_observable_trajectories(rdata, model=model, edata=edata)\n",
"plot_state_trajectories(rdata, model=model)"
"plot_observable_trajectories(rdata, edata=edata)\n",
"plot_state_trajectories(rdata)"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,10 @@
"\n",
"# plot trajectories\n",
"fig, axes = plt.subplots(2, 2, figsize=(8, 8))\n",
"plot_state_trajectories(rdata, model=model, ax=axes[0, 0])\n",
"plot_observable_trajectories(rdata, model=model, ax=axes[1, 0])\n",
"plot_state_trajectories(rdata_reduced, model=model_reduced, ax=axes[0, 1])\n",
"plot_observable_trajectories(rdata_reduced, model=model_reduced, ax=axes[1, 1])\n",
"plot_state_trajectories(rdata, ax=axes[0, 0])\n",
"plot_observable_trajectories(rdata, ax=axes[1, 0])\n",
"plot_state_trajectories(rdata_reduced, ax=axes[0, 1])\n",
"plot_observable_trajectories(rdata_reduced, ax=axes[1, 1])\n",
"fig.tight_layout()"
]
},
Expand Down Expand Up @@ -386,7 +386,7 @@
"timepoints = np.linspace(0, 14, 200)\n",
"model.set_timepoints(timepoints)\n",
"rdata = run_simulation(model, solver)\n",
"plot_state_trajectories(rdata, model=model)\n",
"plot_state_trajectories(rdata)\n",
"\n",
"for stst_value in steady_state:\n",
" plt.axhline(y=stst_value, color=\"gray\", linestyle=\"--\", linewidth=1)"
Expand Down Expand Up @@ -501,8 +501,8 @@
"print(\"Initial state used for simulation:\", rdata_reduced[\"x0\"])\n",
"\n",
"\n",
"plot_state_trajectories(rdata_reduced, model=model_reduced)\n",
"plot_observable_trajectories(rdata_reduced, model=model_reduced)"
"plot_state_trajectories(rdata_reduced)\n",
"plot_observable_trajectories(rdata_reduced)"
]
},
{
Expand Down
72 changes: 46 additions & 26 deletions doc/examples/getting_started/GettingStarted.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import amici\n",
"import numpy as np\n",
"\n",
"sbml_importer = amici.SbmlImporter(\"model_steadystate_scaled.xml\")"
],
"outputs": [],
"execution_count": null
]
},
{
"cell_type": "markdown",
Expand All @@ -39,14 +40,14 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"model_name = \"model_steadystate\"\n",
"model_dir = \"model_dir\"\n",
"sbml_importer.sbml2amici(model_name, model_dir)"
],
"outputs": [],
"execution_count": null
]
},
{
"cell_type": "markdown",
Expand All @@ -58,17 +59,17 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# load the model module\n",
"model_module = amici.import_model_module(model_name, model_dir)\n",
"# instantiate model\n",
"model = model_module.get_model()\n",
"# instantiate solver\n",
"solver = model.create_solver()"
],
"outputs": [],
"execution_count": null
]
},
{
"cell_type": "markdown",
Expand All @@ -77,10 +78,12 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"source": "model.set_free_parameter_by_name(\"p1\", 1e-3)",
"outputs": [],
"execution_count": null
"source": [
"model.set_free_parameter_by_name(\"p1\", 1e-3)"
]
},
{
"cell_type": "markdown",
Expand All @@ -89,10 +92,12 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"source": "solver.set_absolute_tolerance(1e-10)",
"outputs": [],
"execution_count": null
"source": [
"solver.set_absolute_tolerance(1e-10)"
]
},
{
"cell_type": "markdown",
Expand All @@ -108,14 +113,14 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# set timepoints\n",
"model.set_timepoints([0, 1])\n",
"model.set_timepoints(np.linspace(0, 10, 101))\n",
"rdata = model.simulate(solver=solver)"
],
"outputs": [],
"execution_count": null
]
},
{
"cell_type": "markdown",
Expand All @@ -124,36 +129,51 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"rdata.x"
],
"outputs": [],
"execution_count": null
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": "All results attributes are always ordered according to the model. For species, this means that the columns of `rdata.x` match the ordering of species in the model, which can be accessed as [Model.get_state_names](https://amici.readthedocs.io/en/latest/generated/amici.sim.sundials.html#amici.sim.sundials.Model.get_state_names)"
"source": "All results attributes are always ordered according to the model. For species, this means that the columns of `rdata.x` match the ordering of species in the model, which can be accessed as [Model.get_state_names](https://amici.readthedocs.io/en/latest/generated/amici.sim.sundials.html#amici.sim.sundials.Model.get_state_names) or as `ReturnData.state_names`:"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"source": "model.get_state_names()",
"outputs": [],
"execution_count": null
"source": [
"model.get_state_names()"
]
},
{
"metadata": {},
"cell_type": "markdown",
"metadata": {},
"source": "For convenience, most results stored in `ReturnData` can also be retrieved as [xarray.DataArray](https://docs.xarray.dev/en/stable/index.html) objects that already include the respective row and column names. This can be accessed via the `xr` attribute of `ReturnData`. Here, we access the model state `x` as `DataArray` object to convert it to a `pandas.DataFrame`:"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"rdata.xr.x.to_pandas()"
]
},
{
"cell_type": "code",
"source": "rdata.xr.x.to_pandas()",
"execution_count": null,
"metadata": {},
"outputs": [],
"execution_count": null
"source": [
"from amici.sim.sundials.plotting import *\n",
"\n",
"plot_state_trajectories(rdata)"
]
},
{
"cell_type": "markdown",
Expand Down
Loading
Loading