Skip to content

Commit acb0375

Browse files
authored
doc(python) Extend steadystate python-interface example | ci(python) Fixes #348 (#349)
* doc(python) Extend steadystate python-interface example * feature(python) Add basic plotting functions * ci(python) python3 instead of python3.6 * ci() Disallow failure on osx; update python path * doc(python) make doxygen compatible * ci(osx) add tex path
1 parent 17b29a0 commit acb0375

File tree

5 files changed

+1194
-212
lines changed

5 files changed

+1194
-212
lines changed

.travis.yml

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -52,35 +52,13 @@ matrix:
5252
on:
5353
branch: master
5454

55-
allow_failures:
56-
# allow osx build to fail until symengine/homebrew/python3.7 issue is resolved
57-
- os: osx
58-
osx_image: xcode9.3
59-
compiler: clang
60-
before_install:
61-
- brew update # without this homebrew can stumble over wrong ruby version
62-
- travis_wait brew install gcc || brew link --overwrite gcc # fix linker warning regarding /usr/local/include/c++
63-
- brew install hdf5 cppcheck swig doxygen ragel graphviz homebrew/cask/mactex
64-
- brew upgrade python
65-
after_success:
66-
- cd $BASE_DIR # cd to base dir for correct relative path in deploy
67-
deploy:
68-
provider: pages
69-
local-dir: doc
70-
skip-cleanup: true
71-
github-token: $GITHUB_TOKEN # Set in the settings page of your repository, as a secure variable
72-
keep-history: false
73-
verbose: true
74-
on:
75-
branch: master
76-
7755
install:
7856
# Python distutils only looks for `swig` and does not find `swig3.0`
7957
- export BASE_DIR=`pwd`
8058
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then mkdir -p ~/bin/ && ln -s /usr/bin/swig3.0 ~/bin/swig && export PATH=~/bin/:$PATH; fi
8159
- pyenv versions
8260
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then pyenv shell 2.7 3.6; fi
83-
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export PATH=/Users/travis/Library/Python/3.6/bin:$PATH; fi
61+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export PATH=/Users/travis/Library/Python/3.7/bin:/Library/TeX/texbin:$PATH; fi
8462
- pip3 install --user --upgrade pip setuptools wheel pkgconfig doxypypy coverage scipy
8563
- ./scripts/buildSuiteSparse.sh
8664
- ./scripts/buildSundials.sh

python/amici/plotting.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
"""@package amici.plotting Plotting related functions"""
2+
3+
import matplotlib.pyplot as plt
4+
5+
def plotStateTrajectories(rdata, state_indices=None, ax = None):
6+
"""Plot state trajectories
7+
8+
Arguments:
9+
rdata: AMICI simulation results as returned by amici.getSimulationResults()
10+
state_indices: Indices of states for which trajectories are to be plotted
11+
ax: matplotlib.axes.Axes instance to plot into
12+
13+
Returns:
14+
15+
Raises:
16+
17+
"""
18+
if not ax:
19+
fig, ax = plt.subplots()
20+
if not state_indices:
21+
state_indices = range(rdata['x'].shape[1])
22+
for ix in state_indices:
23+
ax.plot(rdata['t'], rdata['x'][:, ix], label='$x_%d$' % ix)
24+
ax.set_xlabel('$t$ (s)')
25+
ax.set_ylabel('$x_i(t)$ (mmol/ml)')
26+
ax.legend()
27+
ax.set_title('State trajectories')
28+
29+
30+
def plotObservableTrajectories(rdata, observable_indices=None, ax = None):
31+
"""Plot observable trajectories
32+
33+
Arguments:
34+
rdata: AMICI simulation results as returned by amici.getSimulationResults()
35+
observable_indices: Indices of observables for which trajectories are to be plotted
36+
ax: matplotlib.axes.Axes instance to plot into
37+
38+
Returns:
39+
40+
Raises:
41+
42+
"""
43+
if not ax:
44+
fig, ax = plt.subplots()
45+
if not observable_indices:
46+
observable_indices = range(rdata['y'].shape[1])
47+
for iy in observable_indices:
48+
ax.plot(rdata['t'], rdata['y'][:, iy], label='$y_%d$' % iy)
49+
ax.set_xlabel('$t$ (s)')
50+
ax.set_ylabel('$y_i(t)$ (AU)')
51+
ax.legend()
52+
ax.set_title('Observables')

0 commit comments

Comments
 (0)