32 : _start(time_steps.front()),
33 _end(time_steps.back()),
36 _time_steps(time_steps)
39 time_steps.begin(), time_steps.end(), std::less_equal{}))
41 ERR(
"Error in SensorData() - Time series has no order!");
54 std::vector<float>* data,
55 const std::string& data_unit_string)
63 std::vector<float>* data,
64 const std::string& data_unit_string)
71 "Warning in SensorData::addTimeSeries() - Lengths of time "
72 "series does not match number of time steps.");
81 "Warning in SensorData::addTimeSeries() - Lengths of time "
82 "series does not match number of time steps.");
95 for (std::size_t i = 0; i <
_vec_names.size(); i++)
102 ERR(
"Error in SensorData::getTimeSeries() - Time series '{:s}' not found.",
109 std::ifstream in(file_name.c_str());
113 INFO(
"SensorData::readDataFromFile() - Could not open file {:s}.",
121 std::getline(in, line);
123 std::list<std::string>::const_iterator it(fields.begin());
124 std::size_t
const nFields = fields.size();
131 std::size_t
const nDataArrays(nFields - 1);
134 for (std::size_t i = 0; i < nDataArrays; i++)
141 while (std::getline(in, line))
145 if (nFields != fields.size())
151 std::size_t
const pos(it->rfind(
"."));
152 std::size_t
const current_time_step = (pos == std::string::npos)
153 ? atoi((it++)->c_str())
157 for (std::size_t i = 0; i < nDataArrays; i++)
160 static_cast<float>(strtod((it++)->c_str(),
nullptr)));
176 return "Evaporation";
180 return "Precipitation";
184 return "Temperature";
192 if (s ==
"Evaporation" || s ==
"EVAPORATION")
196 if (s ==
"Precipitation" || s ==
"PRECIPITATION")
200 if (s ==
"Temperature" || s ==
"TEMPERATURE")
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Definition of the SensorData class.
const std::vector< float > * getTimeSeries(SensorDataType time_series_name) const
Returns the time series with the given name.
std::vector< SensorDataType > _vec_names
std::vector< std::vector< float > * > _data_vecs
SensorData(const std::string &file_name)
std::vector< std::string > _data_unit_string
std::vector< std::size_t > _time_steps
void addTimeSeries(const std::string &data_name, std::vector< float > *data, const std::string &data_unit_string="")
int readDataFromFile(const std::string &file_name)
Reads a CSV-file with time series data and fills the container.
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.
int strDate2int(const std::string &s)
std::vector< std::string > splitString(std::string const &str)