MeteoIODoc  MeteoIODoc-2.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TimeSeriesManager.h
Go to the documentation of this file.
1 /***********************************************************************************/
2 /* Copyright 2014 WSL Institute for Snow and Avalanche Research SLF-DAVOS */
3 /***********************************************************************************/
4 /* This file is part of MeteoIO.
5  MeteoIO is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  MeteoIO is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef TIMESERIESMANAGER_H
19 #define TIMESERIESMANAGER_H
20 
21 #include <meteoio/DataGenerator.h>
22 #include <meteoio/MeteoProcessor.h>
26 #include <meteoio/IOHandler.h>
27 #include <meteoio/Config.h>
28 
29 namespace mio {
30 
32  public:
33  TimeSeriesManager(IOHandler& in_iohandler, const Config& in_cfg);
34 
35  size_t getStationData(const Date& date, STATIONS_SET& vecStation);
36 
51  size_t getMeteoData(const Date& dateStart, const Date& dateEnd,
52  std::vector< METEO_SET >& vecVecMeteo);
53 
69  size_t getMeteoData(const Date& i_date, METEO_SET& vecMeteo);
70 
82  void push_meteo_data(const IOUtils::ProcessingLevel& level, const Date& date_start, const Date& date_end,
83  const std::vector< METEO_SET >& vecMeteo);
84 
85  void push_meteo_data(const IOUtils::ProcessingLevel& level, const Date& date_start, const Date& date_end,
86  const std::vector< MeteoData >& vecMeteo, const bool& invalidate_cache=true);
87 
100  void setProcessingLevel(const unsigned int& i_level);
101 
110  void setMinBufferRequirements(const double& buffer_size, const double& buff_before);
111 
121  double getAvgSamplingRate() const;
122 
123  void writeMeteoData(const std::vector< METEO_SET >& vecMeteo, const std::string& name="");
124 
125  const std::string toString() const;
126 
135  void add_to_points_cache(const Date& i_date, const METEO_SET& vecMeteo);
136 
140  void clear_cache();
141 
147  const Config getConfig() const {return cfg;}
148 
154  IOHandler& getIOHandler() const {return iohandler;}
155 
162  Date getRawBufferStart() const {return raw_buffer.getBufferStart();}
163 
170  Date getRawBufferEnd() const {return raw_buffer.getBufferEnd();}
171 
172  private:
173  void setDfltBufferProperties();
174  void fill_filtered_cache();
175  void fillRawBuffer(const Date& date_start, const Date& date_end);
176 
177  const Config& cfg;
178  IOHandler& iohandler;
179  MeteoProcessor meteoprocessor;
180  DataGenerator dataGenerator;
181 
182  ProcessingProperties proc_properties;
183  std::map<Date, METEO_SET > point_cache;
184  MeteoBuffer raw_buffer;
185  MeteoBuffer filtered_cache;
186 
187  Duration chunk_size;
188  Duration buff_before;
189  unsigned int processing_level;
190 };
191 } //end namespace
192 #endif
Definition: ProcessingBlock.h:33
void setMinBufferRequirements(const double &buffer_size, const double &buff_before)
Set buffer window properties requirements as known to the application itself. This will compare these...
Definition: TimeSeriesManager.cc:70
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:149
double getAvgSamplingRate() const
Returns the average sampling rate in the data. This computes the average sampling rate of the data th...
Definition: TimeSeriesManager.cc:246
TimeSeriesManager(IOHandler &in_iohandler, const Config &in_cfg)
Definition: TimeSeriesManager.cc:27
A class to buffer meteorological data. This class buffers MeteoData objects. It is currently NOT a pr...
Definition: Buffer.h:38
Date getRawBufferStart() const
Returns the begining of the raw buffer. This is the start date of the request that was given to the I...
Definition: TimeSeriesManager.h:162
std::vector< MeteoData > METEO_SET
Definition: MeteoData.h:29
void writeMeteoData(const std::vector< METEO_SET > &vecMeteo, const std::string &name="")
Definition: TimeSeriesManager.cc:241
void setProcessingLevel(const unsigned int &i_level)
Set the desired ProcessingLevel of the TimeSeriesManager instance The processing level affects the wa...
Definition: TimeSeriesManager.cc:85
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. This is a way to manipulate MeteoData var...
Definition: TimeSeriesManager.cc:264
ProcessingLevel
Definition: IOUtils.h:51
A class to generate meteo data from user-selected models or parametrizations. This class sits in betw...
Definition: DataGenerator.h:43
This class is the class to use for raw I/O operations. It is responsible for transparently loading th...
Definition: IOHandler.h:36
Date getBufferEnd() const
Returns the end of the buffer. This is the end date of the request that was given to the IOHandler...
Definition: Buffer.cc:256
std::vector< StationData > STATIONS_SET
Definition: StationData.h:129
A class that reads a key/value file. These files (typically named *.ini) follow the INI file format s...
Definition: Config.h:58
const Config getConfig() const
Returns a copy of the internal Config object. This is convenient to clone an iomanager.
Definition: TimeSeriesManager.h:147
Date getBufferStart() const
Returns the begining of the buffer. This is the start date of the request that was given to the IOHan...
Definition: Buffer.cc:251
A class to handle timestamps. This class handles conversion between different time display formats (I...
Definition: Date.h:79
size_t getStationData(const Date &date, STATIONS_SET &vecStation)
Definition: TimeSeriesManager.cc:140
IOHandler & getIOHandler() const
Returns a copy of the internal IOHandler object. This is convenient to clone an iomanager.
Definition: TimeSeriesManager.h:154
A facade class that invokes the processing of the filters and the resampling.
Definition: MeteoProcessor.h:38
Date getRawBufferEnd() const
Returns the end of the raw buffer. This is the end date of the request that was given to the IOHandle...
Definition: TimeSeriesManager.h:170
void clear_cache()
Clear the point cache. All resampled values are dismissed, will need to be recalculated.
Definition: TimeSeriesManager.cc:274
Definition: TimeSeriesManager.h:31
void push_meteo_data(const IOUtils::ProcessingLevel &level, const Date &date_start, const Date &date_end, const std::vector< METEO_SET > &vecMeteo)
Push a vector of time series of MeteoData objects into the TimeSeriesManager. This overwrites any int...
Definition: TimeSeriesManager.cc:93
const std::string toString() const
Definition: TimeSeriesManager.cc:318