Class DataRecorder
source code
Record time-series data from a simulation.
A DataRecorder instance stores a set of named time-series
variables, consisting of a sequence of recorded data items of any
type, along with the times at which they were recorded.
DataRecorder is an abstract class for which different
implementations may exist for different means of storing recorded
data. For example, the subclass InMemoryRecorder stores all the
data in memory.
A DataRecorder instance can operate either as an event processor, or in a
stand-alone mode. Both usage modes can be used on the same
instance in the same simulation.
STAND-ALONE USAGE:
A DataRecorder instance is used as follows:
- Method .add_variable adds a named time series variable.
- Method .record_data records a new data item and timestamp.
- Method .get_data gets a time-delimited sequence of data from a variable
EVENTPROCESSOR USAGE:
A DataRecorder can also be connected to a simulation as an event
processor, forming a kind of virtual recording equipment. An
output port from any event processor in a simulation can be
connected to a DataRecorder; the recorder will automaticall create
a variable with the same name as the connection, and record any
incoming data on that variable with the time it was received. For
example:
topo.sim['Recorder'] = InMemoryRecorder()
topo.sim.connect('V1','Recorder',name='V1 Activity')
This script snippet will create a new DataRecorder and
automatically record all activity sent from the sheet 'V1'.
|
|
__init__(self,
**params)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature |
source code
|
|
|
|
|
|
|
|
|
|
input_event(self,
conn,
data)
Called by the simulation when an EPConnectionEvent is delivered;
the EventProcessor should process the data somehow. |
source code
|
|
|
|
add_variable(self,
name)
Create a new time-series variable with the given name. |
source code
|
|
|
|
record_data(self,
varname,
time,
data)
Record the given data item with the given timestamp in the
named timeseries. |
source code
|
|
|
|
get_data(self,
varname,
times=(None, None),
fill_range=False)
Get the named timeseries between the given times
(inclusive). |
source code
|
|
|
|
get_times(self,
var)
Get all the timestamps for a given variable. |
source code
|
|
|
|
get_time_indices(self,
varname,
start_time,
end_time)
For the named variable, get the start and end indices suitable
for slicing the data to include all times t:: |
source code
|
|
|
Inherited from base.simulation.EventProcessor:
process_current_time,
script_repr,
send_output,
start
Inherited from param.parameterized.Parameterized:
__getstate__,
__repr__,
__setstate__,
__str__,
debug,
defaults,
force_new_dynamic_value,
get_param_values,
get_value_generator,
inspect_value,
message,
print_param_values,
set_default,
set_dynamic_time_fn,
set_param,
state_pop,
state_push,
verbose,
warning
Inherited from object:
__delattr__,
__format__,
__getattribute__,
__hash__,
__new__,
__reduce__,
__reduce_ex__,
__setattr__,
__sizeof__,
__subclasshook__
|
|
Inherited from object:
__class__
|
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
- Overrides:
object.__init__
- (inherited documentation)
|
get_data(self,
varname,
times=(None, None),
fill_range=False)
| source code
|
Get the named timeseries between the given times
(inclusive). If fill_range is true, the returned data will
have timepoints exactly at the start and end of
the given timerange. The data values at these timepoints will
be those of the next-earlier datapoint in the series.
(NOTE: fill_range can fail to create a beginning timepoint if
the start of the time range is earlier than the first recorded datapoint.]
|
get_time_indices(self,
varname,
start_time,
end_time)
| source code
|
For the named variable, get the start and end indices suitable
for slicing the data to include all times t::
start_time <= t <= end_time.
A start_ or end_time of None is interpreted to mean the
earliest or latest available time, respectively.
|
__abstract
bool(x) -> bool
Returns True when the argument x is true, False otherwise.
The builtins True and False are the only two instances of the class bool.
The class bool is a subclass of the class int, and cannot be subclassed.
- Value:
-
|