OGS
SensorData.h
Go to the documentation of this file.
1
15#pragma once
16
17#include <cstddef>
18#include <string>
19#include <vector>
20
28{
29 OTHER = 0,
33 // please expand if necessary
34};
35
42enum class TimeStepType
43{
44 NONE = 0,
45 SECONDS,
46 MINUTES,
47 DAYS,
48 WEEKS,
49 MONTHS,
50 YEARS,
51 DATE, // time series is given as a vector of dates
52 DATETIME // time series is given as a vector of date + time
53};
54
62class SensorData final
63{
64public:
67 explicit SensorData(const std::string& file_name);
68
71 explicit SensorData(std::vector<std::size_t> time_steps);
72
74
78 void addTimeSeries(const std::string& data_name, std::vector<float>* data,
79 const std::string& data_unit_string = "");
80
84 void addTimeSeries(SensorDataType data_name, std::vector<float>* data,
85 const std::string& data_unit_string = "");
86
88 const std::vector<float>* getTimeSeries(
89 SensorDataType time_series_name) const;
90
92 const std::vector<SensorDataType>& getTimeSeriesNames() const
93 {
94 return _vec_names;
95 }
96
98 const std::vector<std::size_t>& getTimeSteps() const { return _time_steps; }
99
101 std::size_t getStartTime() const { return _start; }
102
104 std::size_t getEndTime() const { return _end; }
105
108 std::size_t getStepSize() const { return _step_size; }
109
112
115
117 static std::string convertSensorDataType2String(SensorDataType t);
118
120 static SensorDataType convertString2SensorDataType(const std::string& s);
121
122private:
124 int readDataFromFile(const std::string& file_name);
125
126 std::size_t _start;
127 std::size_t _end;
128 std::size_t _step_size;
130 std::vector<std::string> _data_unit_string;
131 std::vector<std::size_t> _time_steps;
132 std::vector<SensorDataType> _vec_names;
133 std::vector<std::vector<float>*> _data_vecs;
134};
TimeStepType
Definition SensorData.h:43
SensorDataType
Definition SensorData.h:28
A container for sensor data at an observation site. The class stores a number of time series and has ...
Definition SensorData.h:63
std::size_t getEndTime() const
Returns the last time step.
Definition SensorData.h:104
const std::vector< float > * getTimeSeries(SensorDataType time_series_name) const
Returns the time series with the given name.
const std::vector< std::size_t > & getTimeSteps() const
Returns the time step vector (if it exists)
Definition SensorData.h:98
std::size_t _end
Definition SensorData.h:127
std::size_t getStartTime() const
Returns the first time step.
Definition SensorData.h:101
const std::vector< SensorDataType > & getTimeSeriesNames() const
Returns all time series names contained in this container.
Definition SensorData.h:92
std::vector< SensorDataType > _vec_names
Definition SensorData.h:132
std::vector< std::vector< float > * > _data_vecs
Definition SensorData.h:133
TimeStepType _time_unit
Definition SensorData.h:129
SensorData(const std::string &file_name)
std::size_t getStepSize() const
Definition SensorData.h:108
std::size_t _start
Definition SensorData.h:126
std::vector< std::string > _data_unit_string
Definition SensorData.h:130
std::vector< std::size_t > _time_steps
Definition SensorData.h:131
void addTimeSeries(const std::string &data_name, std::vector< float > *data, const std::string &data_unit_string="")
std::size_t _step_size
Definition SensorData.h:128
int readDataFromFile(const std::string &file_name)
Reads a CSV-file with time series data and fills the container.
TimeStepType getTimeUnit() const
Returns the unit the time steps.
Definition SensorData.h:114
static SensorDataType convertString2SensorDataType(const std::string &s)
Converts Strings to Sensor Data Types.
static std::string convertSensorDataType2String(SensorDataType t)
Converts Sensor Data Types to Strings.
void setTimeUnit(TimeStepType t)
Allows to set a unit for the time steps.
Definition SensorData.h:111