MeteoIODoc 20250905.f67af007
 
Loading...
Searching...
No Matches
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) override;
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
149 public:
150 TimeShift(const std::vector< std::pair<std::string, std::string> >& vecArgs, const std::string& name, const Config& cfg);
151
152 void process(const unsigned int& param, const std::vector<MeteoData>& ivec, std::vector<MeteoData>& ovec) override;
153
154 private:
155 void process_corrections(std::vector<MeteoData>& ovec) const;
156 void process_offset(std::vector<MeteoData>& ovec) const;
157 std::vector<offset_spec> dst_changes;
158 double offset;
159 bool has_offset;
160};
161
175class TimeSort : public ProcessingBlock {
176 public:
177 TimeSort(const std::vector< std::pair<std::string, std::string> >& vecArgs, const std::string& name, const Config& cfg);
178
179 void process(const unsigned int& param, const std::vector<MeteoData>& ivec, std::vector<MeteoData>& ovec) override;
180};
181
208class TimeLoop : public ProcessingBlock {
209 public:
210 TimeLoop(const std::vector< std::pair<std::string, std::string> >& vecArgs, const std::string& name, const Config& cfg);
211
212 void process(const unsigned int& param, const std::vector<MeteoData>& ivec, std::vector<MeteoData>& ovec) override;
213 void process(Date &dateStart, Date &dateEnd) override;
214
215 private:
216 Date req_start, req_end;
217 Date match_date, ref_start, ref_end;
218};
219
220} //end namespace
221
222#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:208
void process(const unsigned int &param, const std::vector< MeteoData > &ivec, std::vector< MeteoData > &ovec) override
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()
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:148
void process(const unsigned int &param, const std::vector< MeteoData > &ivec, std::vector< MeteoData > &ovec) override
Definition TimeFilters.cc:286
Sort out of order timesteps.
Definition TimeFilters.h:175
void process(const unsigned int &param, const std::vector< MeteoData > &ivec, std::vector< MeteoData > &ovec) override
Definition TimeFilters.cc:364
Timesteps suppression filter.
Definition TimeFilters.h:87
void process(const unsigned int &param, const std::vector< MeteoData > &ivec, std::vector< MeteoData > &ovec) override
Definition TimeFilters.cc:88
Definition Config.cc:34