31 : _start(time_steps.front()),
32 _end(time_steps.back()),
35 _time_steps(time_steps)
38 time_steps.begin(), time_steps.end(), std::less_equal{}))
40 ERR(
"Error in SensorData() - Time series has no order!");
53 std::vector<float>* data,
54 const std::string& data_unit_string)
62 std::vector<float>* data,
63 const std::string& data_unit_string)
70 "Warning in SensorData::addTimeSeries() - Lengths of time "
71 "series does not match number of time steps.");
80 "Warning in SensorData::addTimeSeries() - Lengths of time "
81 "series does not match number of time steps.");
94 for (std::size_t i = 0; i <
_vec_names.size(); i++)
101 ERR(
"Error in SensorData::getTimeSeries() - Time series '{:s}' not found.",
108 std::ifstream in(file_name.c_str());
112 INFO(
"SensorData::readDataFromFile() - Could not open file {:s}.",
120 std::getline(in, line);
122 std::list<std::string>::const_iterator it(fields.begin());
123 std::size_t
const nFields = fields.size();
130 std::size_t
const nDataArrays(nFields - 1);
133 for (std::size_t i = 0; i < nDataArrays; i++)
140 while (std::getline(in, line))
144 if (nFields != fields.size())
150 std::size_t
const pos(it->rfind(
"."));
151 std::size_t
const current_time_step = (pos == std::string::npos)
152 ? atoi((it++)->c_str())
156 for (std::size_t i = 0; i < nDataArrays; i++)
159 static_cast<float>(strtod((it++)->c_str(),
nullptr)));
175 return "Evaporation";
179 return "Precipitation";
183 return "Temperature";
191 if (s ==
"Evaporation" || s ==
"EVAPORATION")
195 if (s ==
"Precipitation" || s ==
"PRECIPITATION")
199 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)