MeteoIODoc  2.10.0
TimeFilters.h
Go to the documentation of this file.
1 // SPDX-License-Identifier: LGPL-3.0-or-later
2 /***********************************************************************************/
3 /* Copyright 2017 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 TIMEFILTERS_H
20 #define TIMEFILTERS_H
21 
22 #include <meteoio/IOUtils.h>
24 #include <vector>
25 #include <string>
26 
27 namespace mio {
34  public:
35  TimeProcStack(const Config& i_cfg);
36  TimeProcStack(const TimeProcStack& source);
37  ~TimeProcStack() {for (size_t ii=0; ii<filter_stack.size(); ii++) delete filter_stack[ii];}
38 
39  void process(std::vector< std::vector<MeteoData> >& ivec);
40  void process(Date &dateStart, Date &dateEnd);
41 
42  TimeProcStack& operator=(const TimeProcStack& source);
43  static void checkUniqueTimestamps(std::vector<METEO_SET> &vecVecMeteo);
44  static const std::string timeParamName;
45 
46  private:
47  std::vector<ProcessingBlock*> filter_stack; //for now: strictly linear chain of processing blocks
48  bool enable_time_filtering;
49 };
50 
87 class TimeSuppr : public ProcessingBlock {
88  public:
89  TimeSuppr(const std::vector< std::pair<std::string, std::string> >& vecArgs, const std::string& name, const Config& cfg);
90 
91  void process(const unsigned int& param, const std::vector<MeteoData>& ivec, std::vector<MeteoData>& ovec);
92 
93  private:
94  //possible modes of operation
95  typedef enum SUPPR_MODE {
96  NONE,
97  BYDATES,
98  FRAC,
99  CLEANUP
100  } suppr_mode;
101 
102  void supprByDates(std::vector<MeteoData>& ovec) const;
103  void supprFrac(std::vector<MeteoData>& ovec) const;
104  void supprInvalid(std::vector<MeteoData>& ovec) const;
105 
106  std::map< std::string, std::vector<DateRange> > suppr_dates;
107  double range, width;
108  suppr_mode op_mode;
109 };
110 
141 class TimeShift : public ProcessingBlock {
142  public:
143  TimeShift(const std::vector< std::pair<std::string, std::string> >& vecArgs, const std::string& name, const Config& cfg);
144 
145  void process(const unsigned int& param, const std::vector<MeteoData>& ivec, std::vector<MeteoData>& ovec);
146 
147  private:
148  std::vector<offset_spec> dst_changes;
149 };
150 
164 class TimeSort : public ProcessingBlock {
165  public:
166  TimeSort(const std::vector< std::pair<std::string, std::string> >& vecArgs, const std::string& name, const Config& cfg);
167 
168  void process(const unsigned int& param, const std::vector<MeteoData>& ivec, std::vector<MeteoData>& ovec);
169 };
170 
197 class TimeLoop : public ProcessingBlock {
198  public:
199  TimeLoop(const std::vector< std::pair<std::string, std::string> >& vecArgs, const std::string& name, const Config& cfg);
200 
201  void process(const unsigned int& param, const std::vector<MeteoData>& ivec, std::vector<MeteoData>& ovec);
202  void process(Date &dateStart, Date &dateEnd);
203 
204  private:
205  Date req_start, req_end;
206  Date match_date, ref_start, ref_end;
207 };
208 
209 } //end namespace
210 
211 #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 handle timestamps. This class handles conversion between different time display formats (I...
Definition: Date.h:87
The base class for all filters that provides the interface and a few helper methods.
Definition: ProcessingBlock.h:67
Loops over a specific time period.
Definition: TimeFilters.h:197
TimeLoop(const std::vector< std::pair< std::string, std::string > > &vecArgs, const std::string &name, const Config &cfg)
Definition: TimeFilters.cc:351
void process(const unsigned int &param, const std::vector< MeteoData > &ivec, std::vector< MeteoData > &ovec)
Definition: TimeFilters.cc:393
Since the time filters are quite specific to TIME (and need to be applied before),...
Definition: TimeFilters.h:33
static const std::string timeParamName
Definition: TimeFilters.h:44
TimeProcStack(const Config &i_cfg)
Definition: TimeFilters.cc:436
~TimeProcStack()
Definition: TimeFilters.h:37
static void checkUniqueTimestamps(std::vector< METEO_SET > &vecVecMeteo)
check that timestamps are unique and in increasing order
Definition: TimeFilters.cc:517
void process(std::vector< std::vector< MeteoData > > &ivec)
Definition: TimeFilters.cc:489
TimeProcStack & operator=(const TimeProcStack &source)
Definition: TimeFilters.cc:462
Time corrections.
Definition: TimeFilters.h:141
TimeShift(const std::vector< std::pair< std::string, std::string > > &vecArgs, const std::string &name, const Config &cfg)
Definition: TimeFilters.cc:253
void process(const unsigned int &param, const std::vector< MeteoData > &ivec, std::vector< MeteoData > &ovec)
Definition: TimeFilters.cc:276
Sort out of order timesteps.
Definition: TimeFilters.h:164
void process(const unsigned int &param, const std::vector< MeteoData > &ivec, std::vector< MeteoData > &ovec)
Definition: TimeFilters.cc:338
TimeSort(const std::vector< std::pair< std::string, std::string > > &vecArgs, const std::string &name, const Config &cfg)
Definition: TimeFilters.cc:327
Timesteps suppression filter.
Definition: TimeFilters.h:87
void process(const unsigned int &param, const std::vector< MeteoData > &ivec, std::vector< MeteoData > &ovec)
Definition: TimeFilters.cc:88
TimeSuppr(const std::vector< std::pair< std::string, std::string > > &vecArgs, const std::string &name, const Config &cfg)
Definition: TimeFilters.cc:37
Definition: Config.cc:30