NEST main@caf0ae8
 
Loading...
Searching...
No Matches
recording_device.h
Go to the documentation of this file.
1/*
2 * recording_device.h
3 *
4 * This file is part of NEST.
5 *
6 * Copyright (C) 2004 The NEST Initiative
7 *
8 * NEST is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * NEST is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with NEST. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23#ifndef RECORDING_DEVICE_H
24#define RECORDING_DEVICE_H
25
26// C++ includes:
27#include <fstream>
28#include <vector>
29
30// Includes from nestkernel:
31#include "device.h"
32#include "device_node.h"
33#include "kernel_manager.h"
34#include "nest_types.h"
35#include "node.h"
36#include "recording_backend.h"
37
38
39namespace nest
40{
41
42/* BeginUserDocs: NOINDEX
43
44Short description
45+++++++++++++++++
46
47Recording device
48
49Description
50+++++++++++
51
52Recording time window
53+++++++++++++++++++++
54
55The time span during which the recorder actively records can be
56specified using the properties ``start`` and ``stop``. These define
57the recording period of the device in ms. An additional property
58``origin`` allows to shift the recording window by a certain time,
59which can be useful in experimental protocols with :ref:`repeated
60simulations <stepped_simulations>`. Please note that events with
61timestamp `t = start` are not recorded.
62
63Data handling
64+++++++++++++
65
66All recorded data is handed over to the recording backend, selected
67via the ``record_to`` property::
68
69 >>> sr = nest.Create("spike_recorder", params={"record_to":"ascii", "time_in_steps": False})
70 >>> mm = nest.Create("multimeter", 1, {"record_from": ["V_m", "g_ex"], "record_to": "memory"})
71
72
73By default, data recorded from recorders is stored in the `memory` backend.
74You can access the data recorded by the recorders with the ``events`` property.
75
76::
77
78 mm_events = mm.get("events")
79
80.. note::
81
82 The type of recording backend you choose may affect the efficiency of your simulation.
83 The `memory` backend is ideal for interactive work, but can only be used for limited
84 amount of data. Additionally, transferring data to disk later on may be slower than
85 directly writing from the NEST kernel via `ascii` or `sionlib` backends.
86
87 Large simulations with many threads may benefit from the `sionlib` backend, as the `ascii`
88 backend opens many files which can be very time consuming on parallel file systems.
89
90 The complete list of parameters and other recording backend options
91 can be found in the :ref:`guide to recording from simulations <recording_backends>`.
92
93Recorder properties
94+++++++++++++++++++
95
96label
97 A string (default: `""`) specifying an arbitrary textual label for
98 the device. Recording backends might use the label to generate
99 device specific identifiers like filenames and such.
100
101n_events
102 The number of events that were collected by the recorder can be
103 read out of the `n_events` entry. The number of events can be reset
104 to 0. Other values cannot be set.
105
106origin
107 A positive floating point number (default : `0.0`) used as the
108 reference time in ms for `start` and `stop`.
109
110record_to
111 A string (default: `"memory"`) containing the name of the recording
112 backend where to write data to. An empty string turns all recording
113 of individual events off.
114
115start
116 A positive floating point number (default: `0.0`) specifying the
117 activation time in ms, relative to `origin`.
118
119stop
120 A floating point number (default: `infinity`) specifying the
121 deactivation time in ms, relative to `origin`. The value of `stop`
122 must be greater than or equal to `start`.
123
124EndUserDocs */
125
156class RecordingDevice : public DeviceNode, public Device
157{
158public:
161
163 using Node::pre_run_hook;
164 void pre_run_hook( const std::vector< std::string >&, const std::vector< std::string >& );
165
166 bool is_active( Time const& T ) const override;
167
175
176 virtual Type get_type() const = 0;
177
178 const std::string& get_label() const;
179
180 void set_status( const Dictionary& ) override;
181 void get_status( Dictionary& ) const override;
182
183protected:
184 void write( const Event&, const std::vector< double >&, const std::vector< long >& );
185 void set_initialized_() override;
186
187private:
189 {
190 std::string label_;
191 std::string record_to_;
192
193 Parameters_();
194 Parameters_( const Parameters_& ) = default;
195 Parameters_& operator=( const Parameters_& ) = default;
196 void get( Dictionary& ) const;
197 void set( const Dictionary& );
198 } P_;
199
200 struct State_
201 {
202 size_t n_events_;
203
204 State_();
205 void get( Dictionary& ) const;
206 void set( const Dictionary& );
207 } S_;
208
210};
211
212} // namespace
213
214#endif /* #ifndef RECORDING_DEVICE_H */
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
Base class for device objects.
Definition device_node.h:36
Class implementing common interface and properties common for all devices.
Definition device.h:60
virtual void pre_run_hook()
Set internal variables before calls to SimulationManager::run()
Definition device.cpp:141
Encapsulate information sent between nodes.
Definition event.h:103
virtual void pre_run_hook()=0
Re-calculate dependent parameters of the node.
Base class for all recording devices.
Definition recording_device.h:157
const std::string & get_label() const
Definition recording_device.cpp:63
virtual void pre_run_hook()
Set internal variables before calls to SimulationManager::run()
Definition device.cpp:141
void set_status(const Dictionary &) override
Change properties of the node according to the entries in the dictionary.
Definition recording_device.cpp:130
virtual Type get_type() const =0
void get_status(Dictionary &) const override
Export properties of the node by setting entries in the status dictionary.
Definition recording_device.cpp:182
void write(const Event &, const std::vector< double > &, const std::vector< long > &)
Definition recording_device.cpp:217
struct nest::RecordingDevice::Parameters_ P_
void set_initialized_() override
Definition recording_device.cpp:49
Dictionary backend_params_
Definition recording_device.h:209
RecordingDevice()
Definition recording_device.cpp:32
struct nest::RecordingDevice::State_ S_
Type
Definition recording_device.h:169
@ MULTIMETER
Definition recording_device.h:170
@ SPIKE_RECORDER
Definition recording_device.h:171
@ SPIN_DETECTOR
Definition recording_device.h:172
@ WEIGHT_RECORDER
Definition recording_device.h:173
bool is_active(Time const &T) const override
Returns true if the device is active at the given time stamp.
Definition recording_device.cpp:209
Definition nest_time.h:135
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
Declarations for base class Node.
Definition recording_device.h:189
std::string label_
A user-defined label for symbolic device names.
Definition recording_device.h:190
void get(Dictionary &) const
Definition recording_device.cpp:75
std::string record_to_
The name of the recording backend to use.
Definition recording_device.h:191
Parameters_()
Definition recording_device.cpp:68
Parameters_ & operator=(const Parameters_ &)=default
Parameters_(const Parameters_ &)=default
void set(const Dictionary &)
Definition recording_device.cpp:82
Definition recording_device.h:201
void set(const Dictionary &)
Definition recording_device.cpp:114
void get(Dictionary &) const
Definition recording_device.cpp:105
State_()
Definition recording_device.cpp:99
size_t n_events_
The number of events recorded by the device.
Definition recording_device.h:202