|
4 | 4 | "cell_type": "markdown", |
5 | 5 | "metadata": {}, |
6 | 6 | "source": [ |
7 | | - "# AMICI Python example \"steadystate\"\n", |
| 7 | + "# SBML import, observation model, sensitivity analysis, data export and visualization\n", |
8 | 8 | "\n", |
9 | | - "This is an example using the [model_steadystate_scaled.sbml] model to demonstrate and test SBML import and AMICI Python interface." |
| 9 | + "This is an example using the [model_steadystate_scaled.sbml] model to demonstrate:\n", |
| 10 | + "\n", |
| 11 | + "* SBML import\n", |
| 12 | + "* specifying the observation model\n", |
| 13 | + "* performing sensitivity analysis\n", |
| 14 | + "* exporting and visualizing simulation results" |
10 | 15 | ] |
11 | 16 | }, |
12 | 17 | { |
|
23 | 28 | "model_output_dir = model_name\n", |
24 | 29 | "\n", |
25 | 30 | "import libsbml\n", |
26 | | - "import importlib\n", |
27 | 31 | "import amici\n", |
28 | | - "import os\n", |
29 | | - "import sys\n", |
30 | 32 | "import numpy as np\n", |
31 | 33 | "import matplotlib.pyplot as plt" |
32 | 34 | ] |
|
145 | 147 | "metadata": {}, |
146 | 148 | "outputs": [], |
147 | 149 | "source": [ |
148 | | - "constantParameters = [\"k0\"]" |
| 150 | + "constant_parameters = [\"k0\"]" |
149 | 151 | ] |
150 | 152 | }, |
151 | 153 | { |
|
341 | 343 | " model_output_dir,\n", |
342 | 344 | " verbose=logging.INFO,\n", |
343 | 345 | " observables=observables,\n", |
344 | | - " constant_parameters=constantParameters,\n", |
| 346 | + " constant_parameters=constant_parameters,\n", |
345 | 347 | " sigmas=sigmas,\n", |
346 | 348 | ")" |
347 | 349 | ] |
|
361 | 363 | "metadata": {}, |
362 | 364 | "outputs": [], |
363 | 365 | "source": [ |
364 | | - "sys.path.insert(0, os.path.abspath(model_output_dir))\n", |
365 | | - "model_module = importlib.import_module(model_name)" |
| 366 | + "model_module = amici.import_model_module(model_name, model_output_dir)" |
366 | 367 | ] |
367 | 368 | }, |
368 | 369 | { |
|
447 | 448 | "print(\n", |
448 | 449 | " \"Simulation was run using model default parameters as specified in the SBML model:\"\n", |
449 | 450 | ")\n", |
450 | | - "print(model.getParameters())" |
| 451 | + "print(dict(zip(model.getParameterIds(), model.getParameters())))" |
451 | 452 | ] |
452 | 453 | }, |
453 | 454 | { |
|
862 | 863 | }, |
863 | 864 | { |
864 | 865 | "cell_type": "code", |
865 | | - "execution_count": 13, |
866 | | - "outputs": [ |
867 | | - { |
868 | | - "name": "stdout", |
869 | | - "output_type": "stream", |
870 | | - "text": [ |
871 | | - "(1.0, 0.5, 0.4, 2.0, 0.1, 2.0, 3.0, 0.2)\n" |
872 | | - ] |
873 | | - } |
874 | | - ], |
| 866 | + "execution_count": null, |
| 867 | + "outputs": [], |
875 | 868 | "source": [ |
876 | | - "print(model.getParameters())" |
| 869 | + "# In particular for interactive use, ReturnDataView.by_id() and amici.evaluate provides a more convenient way to access slices of the result:\n", |
| 870 | + "# Time trajectory of observable observable_x1\n", |
| 871 | + "print(f\"{rdata.by_id('observable_x1')=}\")\n", |
| 872 | + "# Time trajectory of state variable x2\n", |
| 873 | + "print(f\"{rdata.by_id('x2')=}\")" |
877 | 874 | ], |
878 | 875 | "metadata": { |
879 | 876 | "collapsed": false, |
|
2037 | 2034 | "toc_position": {}, |
2038 | 2035 | "toc_section_display": true, |
2039 | 2036 | "toc_window_display": false |
| 2037 | + }, |
| 2038 | + "nbsphinx": { |
| 2039 | + "execute": "always" |
2040 | 2040 | } |
2041 | 2041 | }, |
2042 | 2042 | "nbformat": 4, |
|
0 commit comments