MeteoIODoc 20260620.13b5b0a5
Environmental timeseries pre-processing
Loading...
Searching...
No Matches
TimeSeriesManager.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-3.0-or-later
2/***********************************************************************************/
3/* Copyright 2014 WSL Institute for Snow and Avalanche Research SLF-DAVOS */
4/***********************************************************************************/
5/* This file is part of MeteoIO.
6 MeteoIO is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 MeteoIO is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
18*/
19#ifndef TIMESERIESMANAGER_H
20#define TIMESERIESMANAGER_H
21
26#include <meteoio/IOHandler.h>
27#include <meteoio/Config.h>
28
29#include <map>
30#include <vector>
31#include <utility>
32#include <string>
33
34namespace mio {
35
37 public:
44
56 TimeSeriesManager(IOHandler& in_iohandler, const Config& in_cfg, const char& rank=1, const IOUtils::OperationMode &mode=IOUtils::STD);
57
58 size_t getStationData(const Date& date, STATIONS_SET& vecStation);
59
74 size_t getMeteoData(const Date& dateStart, const Date& dateEnd,
75 std::vector< METEO_SET >& vecVecMeteo);
76
92 size_t getMeteoData(const Date& i_date, METEO_SET& vecMeteo);
93
106 void push_meteo_data(const IOUtils::ProcessingLevel& level, const Date& date_start, const Date& date_end,
107 const std::vector< MeteoData >& vecMeteo, const bool& invalidate_cache=true);
108
109 void push_meteo_data(const IOUtils::ProcessingLevel& level, const Date& date_start, const Date& date_end,
110 const std::vector< METEO_SET >& vecMeteo);
111
124 void setProcessingLevel(const unsigned int& i_level);
125
134 void setBufferProperties(const double& buffer_size, const double& buff_before);
135
136 void setRawBufferProperties(const Date& raw_buffer_start, const Date& raw_buffer_end);
137
143 void getBufferProperties(Duration &o_buffer_size, Duration &o_buff_before) const;
144
154 double getAvgSamplingRate() const;
155
156 void writeMeteoData(const std::vector< METEO_SET >& vecMeteo, const std::string& name="");
157
158 const std::string toString() const;
159
169 void add_to_points_cache(const Date& i_date, const METEO_SET& vecMeteo);
170
175 void clear_cache(const cache_types& cache);
176
181 const Config& getConfig() const {return cfg;}
182
187 const IOHandler& getIOHandler() const {return iohandler;}
188
196 Date getBufferStart(const cache_types& cache) const;
197
205 Date getBufferEnd(const cache_types& cache) const;
206
214 Date getDataStart(const cache_types& cache) const;
215
223 Date getDataEnd(const cache_types& cache) const;
224
225
226 private:
227 static bool compare(std::pair<Date, METEO_SET> p1, std::pair<Date, METEO_SET> p2);
228 void setDfltBufferProperties();
229 void fill_filtered_cache();
230 void fillRawBuffer(const Date& date_start, const Date& date_end);
231
232 const Config& cfg;
233 IOHandler& iohandler;
234 MeteoProcessor meteoprocessor;
235 DataGenerator dataGenerator;
236
237 ProcessingProperties proc_properties;
238 std::map<Date, METEO_SET > point_cache;
239 MeteoBuffer raw_buffer;
240 MeteoBuffer filtered_cache;
241
242 Date raw_requested_start, raw_requested_end;
243 Duration chunk_size;
244 Duration buff_before;
245 unsigned int processing_level;
246};
247} //end namespace
248#endif
A class that reads a key/value file. These files (typically named *.ini) follow the INI file format s...
Definition Config.h:79
A class to generate meteo data from user-selected models or parametrizations. This class sits in betw...
Definition DataGenerator.h:44
A class to handle timestamps. This class handles conversion between different time display formats (I...
Definition Date.h:87
This class is the class to use for raw I/O operations. It is responsible for transparently loading th...
Definition IOHandler.h:39
A class to buffer meteorological data. This class buffers MeteoData objects. It is currently NOT a pr...
Definition Buffer.h:39
A facade class that invokes the processing of the filters and the resampling.
Definition MeteoProcessor.h:42
Definition ProcessingBlock.h:36
Definition TimeSeriesManager.h:36
size_t getMeteoData(const Date &dateStart, const Date &dateEnd, std::vector< METEO_SET > &vecVecMeteo)
Fill vecMeteo with a time series of objects corresponding to the interval indicated by dateStart and ...
Definition TimeSeriesManager.cc:228
Date getDataEnd(const cache_types &cache) const
Returns the real end of the raw data in buffer.
Definition TimeSeriesManager.cc:160
void setBufferProperties(const double &buffer_size, const double &buff_before)
Set buffer window properties requirements as known to the application itself.
Definition TimeSeriesManager.cc:76
void clear_cache(const cache_types &cache)
Clear the chosen cache.
Definition TimeSeriesManager.cc:380
const std::string toString() const
Definition TimeSeriesManager.cc:440
double getAvgSamplingRate() const
Returns the average sampling rate in the data.
Definition TimeSeriesManager.cc:111
void writeMeteoData(const std::vector< METEO_SET > &vecMeteo, const std::string &name="")
Definition TimeSeriesManager.cc:344
cache_types
Definition TimeSeriesManager.h:38
@ ALL
all caches
Definition TimeSeriesManager.h:42
@ FILTERED
the filtered data cache
Definition TimeSeriesManager.h:40
@ RAW
the raw data cache
Definition TimeSeriesManager.h:39
@ POINTS
the (interpolated) points cache
Definition TimeSeriesManager.h:41
void push_meteo_data(const IOUtils::ProcessingLevel &level, const Date &date_start, const Date &date_end, const std::vector< MeteoData > &vecMeteo, const bool &invalidate_cache=true)
Push a vector of time series of MeteoData objects into the TimeSeriesManager. This overwrites any int...
Definition TimeSeriesManager.cc:197
void getBufferProperties(Duration &o_buffer_size, Duration &o_buff_before) const
Get the current buffer requirements (ie user defined buffer + filters/resampling requirements)
Definition TimeSeriesManager.cc:97
Date getBufferStart(const cache_types &cache) const
Returns the beginning of the raw buffer.
Definition TimeSeriesManager.cc:120
Date getDataStart(const cache_types &cache) const
Returns the real beginning of the raw data in buffer.
Definition TimeSeriesManager.cc:144
void setProcessingLevel(const unsigned int &i_level)
Set the desired ProcessingLevel of the TimeSeriesManager instance The processing level affects the wa...
Definition TimeSeriesManager.cc:103
size_t getStationData(const Date &date, STATIONS_SET &vecStation)
Definition TimeSeriesManager.cc:219
void add_to_points_cache(const Date &i_date, const METEO_SET &vecMeteo)
Add a METEO_SET for a specific instance to the point cache.
Definition TimeSeriesManager.cc:370
void setRawBufferProperties(const Date &raw_buffer_start, const Date &raw_buffer_end)
Definition TimeSeriesManager.cc:91
Date getBufferEnd(const cache_types &cache) const
Returns the end of the raw buffer.
Definition TimeSeriesManager.cc:132
const IOHandler & getIOHandler() const
Returns the internal IOHandler object.
Definition TimeSeriesManager.h:187
const Config & getConfig() const
Returns the internal Config object.
Definition TimeSeriesManager.h:181
OperationMode
Keywords for mode of operation. Please keep all the GRID_xxx last!
Definition IOUtils.h:63
@ STD
default: extract timeseries from timeseries or grids from grids or spatially interpolate timeseries
Definition IOUtils.h:64
ProcessingLevel
Definition IOUtils.h:54
Definition Config.cc:34
std::vector< MeteoData > METEO_SET
Definition MeteoData.h:32
std::vector< StationData > STATIONS_SET
Definition StationData.h:144