MeteoIODoc 2.11.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
27namespace 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
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
87class 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
147 public:
148 TimeShift(const std::vector< std::pair<std::string, std::string> >& vecArgs, const std::string& name, const Config& cfg);
149
150 void process(const unsigned int& param, const std::vector<MeteoData>& ivec, std::vector<MeteoData>& ovec);
151
152 private:
153 void process_corrections(std::vector<MeteoData>& ovec) const;
154 void process_offset(std::vector<MeteoData>& ovec) const;
155 std::vector<offset_spec> dst_changes;
156 double offset;
157 bool has_offset;
158};
159
173class TimeSort : public ProcessingBlock {
174 public:
175 TimeSort(const std::vector< std::pair<std::string, std::string> >& vecArgs, const std::string& name, const Config& cfg);
176
177 void process(const unsigned int& param, const std::vector<MeteoData>& ivec, std::vector<MeteoData>& ovec);
178};
179
206class TimeLoop : public ProcessingBlock {
207 public:
208 TimeLoop(const std::vector< std::pair<std::string, std::string> >& vecArgs, const std::string& name, const Config& cfg);
209
210 void process(const unsigned int& param, const std::vector<MeteoData>& ivec, std::vector<MeteoData>& ovec);
211 void process(Date &dateStart, Date &dateEnd);
212
213 private:
214 Date req_start, req_end;
215 Date match_date, ref_start, ref_end;
216};
217
218} //end namespace
219
220#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:206
TimeLoop(const std::vector< std::pair< std::string, std::string > > &vecArgs, const std::string &name, const Config &cfg)
Definition: TimeFilters.cc:377
void process(const unsigned int &param, const std::vector< MeteoData > &ivec, std::vector< MeteoData > &ovec)
Definition: TimeFilters.cc:419
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:462
~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:540
void process(std::vector< std::vector< MeteoData > > &ivec)
Definition: TimeFilters.cc:512
TimeProcStack & operator=(const TimeProcStack &source)
Definition: TimeFilters.cc:488
Time corrections.
Definition: TimeFilters.h:146
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:286
Sort out of order timesteps.
Definition: TimeFilters.h:173
void process(const unsigned int &param, const std::vector< MeteoData > &ivec, std::vector< MeteoData > &ovec)
Definition: TimeFilters.cc:364
TimeSort(const std::vector< std::pair< std::string, std::string > > &vecArgs, const std::string &name, const Config &cfg)
Definition: TimeFilters.cc:353
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:31