TimedArray class¶
(Shortest import: from brian2 import TimedArray)
-
class
brian2.input.timedarray.
TimedArray
(values, dt, name=None)[source]¶ Bases:
brian2.core.functions.Function
,brian2.core.names.Nameable
,brian2.utils.caching.CacheKey
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 asfunction_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.
dt :
Quantity
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) # doctest: +ELLIPSIS ... >>> 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) # doctest: +ELLIPSIS ... >>> print mon.v[:] [[ 1. 3.] [ 2. 4.] [ 1. 3.] [ 2. 4.]] mV
Methods
is_locally_constant
(dt)Return whether this function (if interpreted as a function of time) should be considered constant over a timestep. Details
-
is_locally_constant
(dt)[source]¶ Return whether this function (if interpreted as a function of time) should be considered constant over a timestep. This is most importantly used by
TimedArray
so that linear integration can be used. In its standard implementation, always returnsFalse
.Parameters: dt : float
The length of a timestep (without units).
Returns: constant : bool
Whether the results of this function can be considered constant over one timestep of length
dt
.
-
Tutorials and examples using this¶
- Tutorial 3-intro-to-brian-simulations
- Example synapses/jeffress
- Example frompapers/Sturzl_et_al_2000
- Example frompapers/Brunel_Wang_2001
- Example frompapers/Stimberg_et_al_2018/example_6_COBA_with_astro
- Example frompapers/Stimberg_et_al_2018/example_4_synrel