diff --git a/binder/overview.ipynb b/binder/overview.ipynb index 6d98f0f9fb..0a7ce81084 100644 --- a/binder/overview.ipynb +++ b/binder/overview.ipynb @@ -12,7 +12,7 @@ "\n", " Brief intro to AMICI for first-time users.\n", "\n", - "* [Example \"steadystate\"](../python/examples/example_steadystate/ExampleSteadystate.ipynb)\n", + "* [SBML import, observation model, sensitivity analysis, data export and visualization](../python/examples/example_steadystate/ExampleSteadystate.ipynb)\n", "\n", " A more detailed introduction to the AMICI interface, demonstrating sensitivity analysis, various options, finite difference checks, ...\n", "\n", diff --git a/python/examples/example_steadystate/ExampleSteadystate.ipynb b/python/examples/example_steadystate/ExampleSteadystate.ipynb index 502174fe15..09590a3b1a 100644 --- a/python/examples/example_steadystate/ExampleSteadystate.ipynb +++ b/python/examples/example_steadystate/ExampleSteadystate.ipynb @@ -4,9 +4,14 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# AMICI Python example \"steadystate\"\n", + "# SBML import, observation model, sensitivity analysis, data export and visualization\n", "\n", - "This is an example using the [model_steadystate_scaled.sbml] model to demonstrate and test SBML import and AMICI Python interface." + "This is an example using the [model_steadystate_scaled.sbml] model to demonstrate:\n", + "\n", + "* SBML import\n", + "* specifying the observation model\n", + "* performing sensitivity analysis\n", + "* exporting and visualizing simulation results" ] }, { @@ -23,10 +28,7 @@ "model_output_dir = model_name\n", "\n", "import libsbml\n", - "import importlib\n", "import amici\n", - "import os\n", - "import sys\n", "import numpy as np\n", "import matplotlib.pyplot as plt" ] @@ -145,7 +147,7 @@ "metadata": {}, "outputs": [], "source": [ - "constantParameters = [\"k0\"]" + "constant_parameters = [\"k0\"]" ] }, { @@ -341,7 +343,7 @@ " model_output_dir,\n", " verbose=logging.INFO,\n", " observables=observables,\n", - " constant_parameters=constantParameters,\n", + " constant_parameters=constant_parameters,\n", " sigmas=sigmas,\n", ")" ] @@ -361,8 +363,7 @@ "metadata": {}, "outputs": [], "source": [ - "sys.path.insert(0, os.path.abspath(model_output_dir))\n", - "model_module = importlib.import_module(model_name)" + "model_module = amici.import_model_module(model_name, model_output_dir)" ] }, { @@ -447,7 +448,7 @@ "print(\n", " \"Simulation was run using model default parameters as specified in the SBML model:\"\n", ")\n", - "print(model.getParameters())" + "print(dict(zip(model.getParameterIds(), model.getParameters())))" ] }, { @@ -862,18 +863,14 @@ }, { "cell_type": "code", - "execution_count": 13, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(1.0, 0.5, 0.4, 2.0, 0.1, 2.0, 3.0, 0.2)\n" - ] - } - ], + "execution_count": null, + "outputs": [], "source": [ - "print(model.getParameters())" + "# In particular for interactive use, ReturnDataView.by_id() and amici.evaluate provides a more convenient way to access slices of the result:\n", + "# Time trajectory of observable observable_x1\n", + "print(f\"{rdata.by_id('observable_x1')=}\")\n", + "# Time trajectory of state variable x2\n", + "print(f\"{rdata.by_id('x2')=}\")" ], "metadata": { "collapsed": false, @@ -2037,6 +2034,9 @@ "toc_position": {}, "toc_section_display": true, "toc_window_display": false + }, + "nbsphinx": { + "execute": "always" } }, "nbformat": 4,