MeteoIODoc 20241005.2ccf54a9
Meteo1DInterpolator.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-3.0-or-later
2/***********************************************************************************/
3/* Copyright 2009 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 METEO1DINTERPOLATOR_H
20#define METEO1DINTERPOLATOR_H
21
23#include <meteoio/Config.h>
25#include <meteoio/meteoFilters/ProcessingBlock.h> //for ProcessingProperties
26
27#include <string>
28#include <vector>
29#include <map>
30#include <memory>
31
32namespace mio {
87 public:
89
90 void addAlgorithm(std::shared_ptr<ResamplingAlgorithms> algo, const double& max_gap_size);
91 std::vector<std::shared_ptr<ResamplingAlgorithms>> buildStack(const ResamplingAlgorithms::gap_info& gap) const;
92
93 void resetResampling();
94 void resample(const std::string &stationHash, const size_t &index, const ResamplingAlgorithms::ResamplingPosition elementpos, const size_t &ii, const std::vector<MeteoData> &vecM, MeteoData &md, const double& max_gap_size) const;
95 std::string getStackStr() const;
96 bool empty() const;
97
98 private:
99 std::vector<double> max_gap_sizes;
100 std::vector<std::shared_ptr<ResamplingAlgorithms>> stack;
101};
102
104 public:
105
120 Meteo1DInterpolator(const Config& in_cfg, const char& rank=1, const IOUtils::OperationMode &mode=IOUtils::STD);
122
131 bool resampleData(const Date& date, const std::string& stationHash, const std::vector<MeteoData>& vecM, MeteoData& md);
132
136 void resetResampling();
137
138 void getWindowSize(ProcessingProperties& o_properties) const;
139
141 const std::string toString() const;
142
143 private:
144 std::vector< std::pair<std::string, std::string> > getArgumentsForAlgorithm(const std::string& parname, const std::string& algorithm) const;
145 std::string getAlgorithmsForParameter(const std::string& parname) const;
146
147 void processAlgorithms(const std::string& parname, const std::vector<std::pair<int, std::string>>& vecAlgos, std::string base_parname="", const IOUtils::OperationMode& mode=IOUtils::STD, const char& rank=1);
148 void createResamplingStacks(const IOUtils::OperationMode& mode, const char& rank);
149 // resampling stack helpers
150 void addAlgorithmToStack(const std::string& parname,const std::string& algo_name ,const std::vector<std::pair<std::string, std::string>>& vecArgs, const double& i_max_gap_size);
151 void createDefaultAlgorithm(const std::string &parname);
152
153 std::map< std::string, ResamplingStack > mapAlgorithms; //per parameter interpolation algorithms
154 const Config& cfg;
155 double max_gap_size;
156 bool enable_resampling, data_qa_logs;
157 std::string gap_size_key; // To support window size for now; TODO: remove at some point
158
159 public:
160 static const std::string interpol_section;
161 static const std::string interpol_pattern;
162 static const std::string arg_pattern;
163};
164
165
166} //end namespace
167
168#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
A class that can resample MeteoData objects.
Definition: Meteo1DInterpolator.h:103
static const std::string interpol_section
Definition: Meteo1DInterpolator.h:160
Meteo1DInterpolator(const Meteo1DInterpolator &org)=default
static const std::string arg_pattern
Definition: Meteo1DInterpolator.h:162
void getWindowSize(ProcessingProperties &o_properties) const
Definition: Meteo1DInterpolator.cc:182
static const std::string interpol_pattern
Definition: Meteo1DInterpolator.h:161
bool resampleData(const Date &date, const std::string &stationHash, const std::vector< MeteoData > &vecM, MeteoData &md)
A function that executes all the resampling algorithms that have been setup in the constructor.
Definition: Meteo1DInterpolator.cc:189
Meteo1DInterpolator & operator=(const Meteo1DInterpolator &)
Assignement operator.
Definition: Meteo1DInterpolator.cc:281
void resetResampling()
Call each ResamplingAlgorithms to reset its cached data (as might be needed after a rebuffer)
Definition: Meteo1DInterpolator.cc:268
Meteo1DInterpolator(const Config &in_cfg, const char &rank=1, const IOUtils::OperationMode &mode=IOUtils::STD)
The default constructor Set up the interpolation algorithm for each parameter Init tasklist: a vector...
Definition: Meteo1DInterpolator.cc:60
const std::string toString() const
Definition: Meteo1DInterpolator.cc:291
A class to represent a singular measurement received from one station at a certain time (represented ...
Definition: MeteoData.h:108
Definition: ProcessingBlock.h:36
ResamplingPosition
Definition: ResamplingAlgorithms.h:46
Definition: Meteo1DInterpolator.h:86
std::string getStackStr() const
Definition: Meteo1DInterpolator.cc:352
ResamplingStack()
Definition: Meteo1DInterpolator.cc:311
void resample(const std::string &stationHash, const size_t &index, const ResamplingAlgorithms::ResamplingPosition elementpos, const size_t &ii, const std::vector< MeteoData > &vecM, MeteoData &md, const double &max_gap_size) const
Definition: Meteo1DInterpolator.cc:336
std::vector< std::shared_ptr< ResamplingAlgorithms > > buildStack(const ResamplingAlgorithms::gap_info &gap) const
Definition: Meteo1DInterpolator.cc:318
bool empty() const
Definition: Meteo1DInterpolator.cc:350
void resetResampling()
Definition: Meteo1DInterpolator.cc:330
void addAlgorithm(std::shared_ptr< ResamplingAlgorithms > algo, const double &max_gap_size)
Definition: Meteo1DInterpolator.cc:313
OperationMode
Keywords for mode of operation. Please keep all the GRID_xxx last!
Definition: IOUtils.h:63
@ STD
default: extract timeseries from timeseries or grids from grids or spatially interpolate timeseries
Definition: IOUtils.h:64
Definition: Config.cc:31