From 0f95335b204bff9144ad8cd1d6bb54392c131a80 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Tue, 19 Sep 2023 22:30:16 +0200 Subject: [PATCH 1/3] Doc: Rename 'steadystate example' New title + some minor updates Closes #1990 --- binder/overview.ipynb | 2 +- .../ExampleSteadystate.ipynb | 39 +++++++++---------- 2 files changed, 19 insertions(+), 22 deletions(-) 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..e2197ae5c7 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, From 8a66dc8bd13f36a92e243768309d7768673522c7 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Wed, 20 Sep 2023 14:12:59 +0200 Subject: [PATCH 2/3] Always execute --- python/examples/example_steadystate/ExampleSteadystate.ipynb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python/examples/example_steadystate/ExampleSteadystate.ipynb b/python/examples/example_steadystate/ExampleSteadystate.ipynb index e2197ae5c7..a1b4314c6c 100644 --- a/python/examples/example_steadystate/ExampleSteadystate.ipynb +++ b/python/examples/example_steadystate/ExampleSteadystate.ipynb @@ -2020,7 +2020,10 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.7" + "version": "3.7.7", + "nbsphinx": { + "execute": "always" + } }, "toc": { "base_numbering": 1, From efc752a11cee6bb3ef169962f9f3552bde9c542f Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Wed, 20 Sep 2023 14:36:23 +0200 Subject: [PATCH 3/3] Always execute --- .../examples/example_steadystate/ExampleSteadystate.ipynb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python/examples/example_steadystate/ExampleSteadystate.ipynb b/python/examples/example_steadystate/ExampleSteadystate.ipynb index a1b4314c6c..09590a3b1a 100644 --- a/python/examples/example_steadystate/ExampleSteadystate.ipynb +++ b/python/examples/example_steadystate/ExampleSteadystate.ipynb @@ -2020,10 +2020,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.7", - "nbsphinx": { - "execute": "always" - } + "version": "3.7.7" }, "toc": { "base_numbering": 1, @@ -2037,6 +2034,9 @@ "toc_position": {}, "toc_section_display": true, "toc_window_display": false + }, + "nbsphinx": { + "execute": "always" } }, "nbformat": 4,