MeteoIODoc 20260914.909d27f1
Environmental timeseries pre-processing
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 DUPLICATES
100 } suppr_mode;
101
102 void supprByDates(std::vector<MeteoData>& ovec) const;
103 void supprFrac(std::vector<MeteoData>& ovec) const;
104 void supprDuplicates(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
136 public:
137 TimeRounding(const std::vector< std::pair<std::string, std::string> >& vecArgs, const std::string& name, const Config& cfg);
138
139 void process(const unsigned int& param, const std::vector<MeteoData>& ivec, std::vector<MeteoData>& ovec) override;
140
141 private:
142 void process_corrections(std::vector<MeteoData>& ovec) const;
143 void process_offset(std::vector<MeteoData>& ovec) const;
144 double precision, offset;
145 Date::RND type;
146};
147
148
187 public:
188 TimeShift(const std::vector< std::pair<std::string, std::string> >& vecArgs, const std::string& name, const Config& cfg);
189
190 void process(const unsigned int& param, const std::vector<MeteoData>& ivec, std::vector<MeteoData>& ovec) override;
191
192 private:
193 void process_corrections(std::vector<MeteoData>& ovec) const;
194 void process_offset(std::vector<MeteoData>& ovec) const;
195 std::vector<offset_spec> dst_changes;
196 double offset;
197 bool has_offset;
198};
199
213class TimeSort : public ProcessingBlock {
214 public:
215 TimeSort(const std::vector< std::pair<std::string, std::string> >& vecArgs, const std::string& name, const Config& cfg);
216
217 void process(const unsigned int& param, const std::vector<MeteoData>& ivec, std::vector<MeteoData>& ovec) override;
218};
219
246class TimeLoop : public ProcessingBlock {
247 public:
248 TimeLoop(const std::vector< std::pair<std::string, std::string> >& vecArgs, const std::string& name, const Config& cfg);
249
250 void process(const unsigned int& param, const std::vector<MeteoData>& ivec, std::vector<MeteoData>& ovec) override;
251 void process(Date &dateStart, Date &dateEnd) override;
252
253 private:
254 Date req_start, req_end;
255 Date match_date, ref_start, ref_end;
256};
257
258} //end namespace
259
260#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:86
RND
Keywords for selecting rounding strategy.
Definition Date.h:101
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:246
void process(const unsigned int &param, const std::vector< MeteoData > &ivec, std::vector< MeteoData > &ovec) override
Definition TimeFilters.cc:472
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:593
void process(std::vector< std::vector< MeteoData > > &ivec)
Definition TimeFilters.cc:565
TimeProcStack & operator=(const TimeProcStack &source)
Definition TimeFilters.cc:541
Time corrections.
Definition TimeFilters.h:135
void process(const unsigned int &param, const std::vector< MeteoData > &ivec, std::vector< MeteoData > &ovec) override
Definition TimeFilters.cc:291
Time corrections.
Definition TimeFilters.h:186
void process(const unsigned int &param, const std::vector< MeteoData > &ivec, std::vector< MeteoData > &ovec) override
Definition TimeFilters.cc:340
Sort out of order timesteps.
Definition TimeFilters.h:213
void process(const unsigned int &param, const std::vector< MeteoData > &ivec, std::vector< MeteoData > &ovec) override
Definition TimeFilters.cc:417
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:91
Definition Config.cc:34