MeteoIODoc 20240426.aefd3c94
ProcShift.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-3.0-or-later
2/***********************************************************************************/
3/* Copyright 2014 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 PROCSHIFT_H
20#define PROCSHIFT_H
21
22#include <meteoio/meteoFilters/ProcessingBlock.h> //use this one for all others
23
24#include <vector>
25#include <string>
26
27namespace mio {
28
98class ProcShift : public ProcessingBlock { //use this one for simple filter that only look at one data point at a time, for example min_max
99 public:
100 ProcShift(const std::vector< std::pair<std::string, std::string> >& vecArgs, const std::string& name, const Config& cfg);
101
102 virtual void process(const unsigned int& param, const std::vector<MeteoData>& ivec,
103 std::vector<MeteoData>& ovec);
104
105 private:
106 typedef enum INTERPOL_TYPE {
107 cst,
108 stepwise,
109 linear
110 } interpol_type;
111
112 void parse_args(const std::vector< std::pair<std::string, std::string> >& vecArgs);
113 void writeOffsets(const unsigned int& param, const std::vector<MeteoData>& ivec);
114 void correctOffsets(const unsigned int& param, std::vector<MeteoData>& ovec);
115
116 static bool isAllNodata(const std::vector<ProcessingBlock::offset_spec>& vecX, const size_t& startIdx, const size_t& endIdx);
117 static double getMedianSampling(const size_t& param, const std::vector<MeteoData>& ivec);
118
119 std::vector<offset_spec> resampleVector(const std::vector<MeteoData>& ivec, const size_t& param) const;
120 double getPearson(const std::vector<ProcessingBlock::offset_spec>& vecX, const std::vector<ProcessingBlock::offset_spec>& vecY, const size_t& curr_idx, const int& offset) const;
121 int getOffsetFullScan(const std::vector<ProcessingBlock::offset_spec>& vecX, const std::vector<ProcessingBlock::offset_spec>& vecY, const size_t& curr_idx, const int& range_min, const int& range_max) const;
122 int getOffset(const std::vector<ProcessingBlock::offset_spec>& vecX, const std::vector<ProcessingBlock::offset_spec>& vecY, const size_t& curr_idx) const;
123
124 std::vector<ProcessingBlock::offset_spec> corrections;
125 std::string ref_param;
126 std::string root_path;
127 std::string offsets_file;
128 double cst_offset;
129 double sampling_rate;
130 double offset_range;
131 double width_d;
132 size_t width_idx;
133 interpol_type offsets_interp;
134 bool extract_offsets;
135};
136
137} //end namespace
138
139#endif
A class that reads a key/value file. These files (typically named *.ini) follow the INI file format s...
Definition: Config.h:79
Time shifting filter for the selected meteo parameter.
Definition: ProcShift.h:98
virtual void process(const unsigned int &param, const std::vector< MeteoData > &ivec, std::vector< MeteoData > &ovec)
Definition: ProcShift.cc:42
ProcShift(const std::vector< std::pair< std::string, std::string > > &vecArgs, const std::string &name, const Config &cfg)
Definition: ProcShift.cc:33
The base class for all filters that provides the interface and a few helper methods.
Definition: ProcessingBlock.h:67
Definition: Config.cc:31