TimedArray(arr, times=None, clock=None, start=None, dt=None)¶
An array where each value has an associated time.
- The values of the array. The first index is the time index. Any array shape works in principle, but only 1D/2D arrays are supported (other shapes may work, but may not). The idea is to, have the shapes (T,) or (T, N) for T the number of time steps and N the number of neurons.
- A 1D array of times whose length should be the same as the first
arr. Usually it is preferable to specify a clock rather than an array of times, but this doesn’t work in the case where the time intervals are not fixed.
- Specify the times corresponding to array values by a clock. The
tattribute of the clock is the time of the first value in the array, and the time interval is the
dtattribute of the clock. If neither
clockis specified, a clock will be guessed in the usual way (see
- Rather than specifying a clock, you can specify the start time
and time interval explicitly. Technically, this is useful
because it doesn’t create a
Clockobject which can lead to ambiguity about which clock is the default. If dt is specified and start is not, start is assumed to be 0.
Note that if the clock, or start time and dt, of the array should be the default clock values, then you should not specify clock, start or dt (see Technical notes below).
Arbitrary slicing of the array is supported, but the clock will only be preserved where the intervals can be guaranteed to be fixed, that is except for the case where lists or numpy arrays are used on the time index.
Timed arrays can be called as if they were a function of time if the array times are based on a clock (but not if the array times are arbitrary as the look up costs would be excessive). If
x(t)is called where
times[i]<=t<times[i]+dtfor some index i then
x(t)will have the value
x[i]. You can also call
ta 1D array. If x is 1D then
x(t)[i]=x(t[i]), if x is 2D then
Has one method:
Note that specifying a new clock, or values of start and dt, will mean that if you use this
TimedArrayto set the value of a
NeuronGroupvariable, it will be updated on the schedule of this clock, which can (due to floating point errors) induce some timing problems. This rarely happens, but if an occasional inaccuracy of order dt might conceivably be critical for your simulation, you should use
RegularClockobjects instead of
TimedArraySetter(group, var, arr, times=None, clock=None, start=None, dt=None, when='start')¶
Sets NeuronGroup values with a TimedArray.
At the beginning of each update step, this object will set the values of a given state variable of a group with the value from the array corresponding to the current simulation time.
NeuronGroupto which the variable belongs.
- The name or index of the state variable in the group.
- The array of values used to set the variable in the group.
Can be an array or a
TimedArray. If it is an array, you should specify the
clockarguments, or leave them blank to use the default clock.
- Times corresponding to the array values, see
TimedArrayfor more details.
- The clock for the
NetworkOperation. If none is specified, use the group’s clock. If
arris not a
TimedArraythen this clock will be used to initialise it too.
- Can specify these instead of a clock (see
- The standard
whenkeyword, although note that the default value is ‘start’.