Cubic spline function

Using experimental data as model input via a fitted spline function.


In [17]:
%matplotlib inline
from __future__ import print_function
import tellurium as te
import sbmlutils
from sbmlutils.examples.testfiles import test_dir
import os

In [18]:
sbml_path = os.path.join(test_dir, 'models', 'cubicSpline.xml')
r = te.loads(sbml_path)

In [19]:
r.selections = ['time', 'experimental_data', 'a', 'b', 'c', 'd', 't_0']
s = r.simulate(0, 10, 101)
r.plot(s)


Out[19]:
<module 'matplotlib.pyplot' from '/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.pyc'>

In [20]:
print(r.getAntimony())


// Created by libAntimony v2.9.0
model *New_Model()

  // Assignment Rules:
  experimental_data := a*(time - t_0)^3 + b*(time - t_0)^2 + c*(time - t_0) + d;

  // Events:
  event_1: at time > 0: d = 0, c = 1.02212, b = 0, a = -0.02212, t_0 = 0;
  event_2: at time > 1: d = 1, c = 0.955759, b = -0.066361, a = -0.389398, t_0 = 1;
  event_3: at time > 2: d = 1.5, c = -0.345157, b = -1.234555, a = 0.579712, t_0 = 2;
  event_4: at time > 3: d = 0.5, c = -1.075131, b = 0.504581, a = -0.048735, t_0 = 3;
  event_5: at time > 6: d = 0.5, c = 0.636518, b = 0.065969, a = -0.202487, t_0 = 6;
  event_6: at time > 7: d = 1, c = 0.160995, b = -0.541492, a = 0.180497, t_0 = 7;
  event_7: at time > 8: d = 0, c = 0, b = 0, a = 0, t_0 = 8;

  // Variable initializations:
  t_0 = 0;
  a = 0;
  b = 0;
  c = 0;
  d = 0;

  // Other declarations:
  var t_0, a, b, c, d, experimental_data;

  // Unit definitions:
  unit volume = 1e-3 litre;
  unit substance = 1e-3 mole;

  // Display Names:
  experimental_data is "experimental data";
end


In [ ]: