20 #include "../utility/cnpy.hpp"
27 "Sends request for a field to target object"
36 "Fills data into table. Also handles data sent back following request",
49 ,
"threshold used when Table acts as a buffer for spikes"
56 ,
"When set to true, write to a file instead writing in memory."
57 " If `outfile` is not set, streamer writes to default path."
64 ,
"When set to true, look for spikes in a time-series."
65 " Normally used for monitoring Vm for action potentials."
66 " Could be used for any thresholded event. Default is False."
73 ,
"Set the name of file to which data is written to. If set, "
74 " streaming support is automatically enabled."
81 ,
"Data format for table: default csv"
90 ,
"Name of the table written in header of data file."
101 "Fills spike timings into the Table. Signal has to exceed thresh",
107 "Handles process call, updates internal time stamp.",
113 "Handles reinit call.",
120 static Finfo* procShared[] =
127 ,
"Shared message for process and reinit"
128 , procShared,
sizeof( procShared ) /
sizeof(
const Finfo* )
136 static Finfo* tableFinfos[] =
150 static string doc[] =
153 "Author",
"Upi Bhalla",
155 "Table for accumulating data values, or spike timings. "
156 "Can either receive incoming doubles, or can explicitly "
157 "request values from fields provided they are doubles. "
158 "The latter mode of use is preferable if you wish to have "
159 "independent control of how often you sample from the output "
161 "Typically used for storing simulation output into memory, or to file"
162 " when stream is set to True \n"
163 "There are two functionally identical variants of the Table "
164 "class: Table and Table2. Their only difference is that the "
165 "default scheduling of the Table (Clock Tick 8, dt = 0.1 ms ) "
166 "makes it suitable for "
167 "tracking electrical compartmental models of neurons and "
169 "Table2 (Clock Tick 18, dt = 1.0 s) is good for tracking "
170 "biochemical signaling pathway outputs. \n"
171 "These are just the default values and Tables can be assigned"
172 " to any Clock Tick and timestep in the usual manner.",
181 sizeof( tableFinfos ) /
sizeof (
Finfo* ),
184 sizeof( doc ) /
sizeof(
string )
187 static string doc2[] =
189 doc[0],
"Table2", doc[2], doc[3], doc[4], doc[5]
194 static Cinfo table2Cinfo (
198 sizeof( tableFinfos ) /
sizeof (
Finfo* ),
201 sizeof( doc2 ) /
sizeof(
string )
218 useSpikeMode_(false),
255 vector< double > ret;
258 for ( vector< double >::const_iterator
259 i = ret.begin(); i != ret.end(); ++i )
262 vec().insert(
vec().end(), ret.begin(), ret.end() );
314 vector< double > ret;
317 for ( vector< double >::const_iterator
318 i = ret.begin(); i != ret.end(); ++i )
321 vec().insert(
vec().end(), ret.begin(), ret.end() );
340 vec().push_back( v );
373 if( format ==
"csv" or format ==
"npy" )
377 ,
"Unsupported format " << format
378 <<
" only npy and csv are supported"
454 , vector<double>& tvec
455 ,
const double& currTime
459 for (
size_t i = 0; i < N; i++)
461 tvec.push_back( currTime - (N - i - 1 ) *
dt_ );
462 tvec.push_back( v[i] );
bool getUseStreamer(void) const
void setUseStreamer(bool status)
std::string path(const std::string &separator="/") const
bool createParentDirs(const string &path)
Create directories recursively needed to open the given file p.
void reinit(const Eref &e, ProcPtr p)
Reinitialize.
string format_
format of data. Default to csv.
double getTickDt(unsigned int i) const
Element * element() const
bool outfileIsSet_
Wheather or not outfile path is set by user.
string getExtension(const string &path, bool without_dot)
Get the extension of a given filepath.
static const Cinfo * initCinfo()
string moosePathToUserPath(string path)
When user gives a path /a/b/c, moose creates a path /a[0]/b[0]/c[0]. This is helpful in cases where o...
void setOutfile(string outfilepath)
string tableColumnName_
Column name of this table. Use it when writing data to a datafile.
unsigned int getVecSize() const
void zipWithTime(const vector< double > &yvec, vector< double > &tvec, const double &lasttime)
Take the vector from table and timestamp it. It must only be called when packing the data for writing...
static const Cinfo * initCinfo()
double dt_
dt of its clock. Needed for creating time co-ordinates,
void process(const Eref &e, ProcPtr p)
static DestFinfo * handleInput()
void setColumnName(const string colname)
void setThreshold(double v)
string rootdir_
Table directory into which dump the stream data.
static SrcFinfo1< vector< double > * > * requestOut()
string getColumnName() const
static const Cinfo * tableCinfo
string toFilename(const string &path)
Replace all directory sepearator with _. This creates a filepath which can be created in current dire...
string createMOOSEPath(const string &path)
Create a POSIX compatible path from a given string. Remove/replace bad characters.
bool useStreamer_
If stream is set to true, then stream to outfile_. Default value of outfile_ is table path starting f...
#define LOG(t, a)
This macro only expands when not compiling for release.
double getThreshold() const
vector< string > columns_
string getOutfile(void) const
bool getUseSpikeMode(void) const
vector< double > data_
Keep the data, each entry is preceeded by time value. t0, v0, t1, v1, t2, v2 etc. ...
Table & operator=(const Table &tab)
void setUseSpikeMode(bool status)
static void writeToOutFile(const string &filepath, const string &format, const string &openmode, const vector< double > &data, const vector< string > &columns)
Write to a output file in given format.
void setFormat(const string format)