TimedArray class¶

(Shortest import: from brian2 import TimedArray)

class brian2.input.timedarray.TimedArray(values, dt, name=None)[source]

A function of time built from an array of values. The returned object can be used as a function, including in model equations etc. The resulting function has to be called as funcion_name(t) if the provided value array is one-dimensional and as function_name(t, i) if it is two-dimensional.

Parameters: values : ndarray or Quantity An array of values providing the values at various points in time. This array can either be one- or two-dimensional. If it is two-dimensional it’s first dimension should be the time. The time distance between values in the values array. name : str, optional A unique name for this object, see Nameable for details. Defaults to '_timedarray*'.

Notes

For time values corresponding to elements outside of the range of values provided, the first respectively last element is returned.

Examples

>>> from brian2 import *
>>> ta = TimedArray([1, 2, 3, 4] * mV, dt=0.1*ms)
>>> print(ta(0.3*ms))
4. mV
>>> G = NeuronGroup(1, 'v = ta(t) : volt')
>>> mon = StateMonitor(G, 'v', record=True)
>>> net = Network(G, mon)
>>> net.run(1*ms)
...
>>> print(mon[0].v)
[ 1.  2.  3.  4.  4.  4.  4.  4.  4.  4.] mV
>>> ta2d = TimedArray([[1, 2], [3, 4], [5, 6]]*mV, dt=0.1*ms)
>>> G = NeuronGroup(4, 'v = ta2d(t, i%2) : volt')
>>> mon = StateMonitor(G, 'v', record=True)
>>> net = Network(G, mon)
>>> net.run(0.2*ms)
...
>>> print mon.v[:]
[[ 1.  3.]
[ 2.  4.]
[ 1.  3.]
[ 2.  4.]] mV


Methods

Details

is_locally_constant(dt)[source]