MeteoIODoc 20241221.207bde49
GeneratorAlgorithms.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-3.0-or-later
2/***********************************************************************************/
3/* Copyright 2013 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 GENERATORALGORITHMS_H
20#define GENERATORALGORITHMS_H
21
23#include <meteoio/Config.h>
24
25#include <vector>
26#include <set>
27#include <string>
28
29#ifdef _MSC_VER
30 #pragma warning(disable:4512) //we don't need any = operator!
31#endif
32
33namespace mio {
34
112 public:
114 //fill one MeteoData, for one station. This is used by the dataGenerators
115 virtual bool generate(const size_t& param, MeteoData& md, const std::vector<MeteoData>& vecMeteo) = 0;
116
126 virtual bool create(const size_t& param, const size_t& ii_min, const size_t& ii_max, std::vector<MeteoData>& vecMeteo) = 0;
127
133 bool skipStation(const std::string& station_id) const;
134
140 bool skipTimeStep(const Date& dt) const;
141
142 /*
143 * @brief Should this height be skipped? based on user-provided height restrictions
144 * @param[in] height current height
145 * @return true if the provided height should be skipped
146 */
147 bool skipHeight(const double& height) const;
148
149 std::vector<DateRange> getTimeRestrictions() const {return time_restrictions;}
150 std::string getAlgo() const {return algo;}
151 protected:
152 GeneratorAlgorithm(const std::vector< std::pair<std::string, std::string> >& vecArgs, const std::string& i_algo, const std::string& i_section, const double& TZ);
153 virtual void parse_args(const std::vector< std::pair<std::string, std::string> >& /*vecArgs*/) {}
154 static std::set<std::string> initStationSet(const std::vector< std::pair<std::string, std::string> >& vecArgs, const std::string& keyword);
155 void initHeightRestrictions(const std::vector<std::pair<std::string, std::string>> vecArgs);
156
157 const std::vector<DateRange> time_restrictions;
158 const std::set<std::string> excluded_stations, kept_stations;
161 const std::string algo, section;
162
163 //These are used by several generators in order work with radiation data by looking at HS and deciding which albedo should be used
164 static const double soil_albedo, snow_albedo, snow_thresh;
165 static const double default_height;
166};
167
169 public:
170 static GeneratorAlgorithm* getAlgorithm(const Config& cfg, const std::string& i_algoname, const std::string& i_section, const std::vector< std::pair<std::string, std::string> >& vecArgs);
171};
172
173} //end namespace mio
174
175#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
Definition: GeneratorAlgorithms.h:168
static GeneratorAlgorithm * getAlgorithm(const Config &cfg, const std::string &i_algoname, const std::string &i_section, const std::vector< std::pair< std::string, std::string > > &vecArgs)
Definition: GeneratorAlgorithms.cc:150
Interface class for the generator models.
Definition: GeneratorAlgorithms.h:111
static const double soil_albedo
Definition: GeneratorAlgorithms.h:164
std::string getAlgo() const
Definition: GeneratorAlgorithms.h:150
bool skipTimeStep(const Date &dt) const
Should this timestep be skipped, based on user-provided time restrictions?
Definition: GeneratorAlgorithms.cc:283
virtual bool create(const size_t &param, const size_t &ii_min, const size_t &ii_max, std::vector< MeteoData > &vecMeteo)=0
Fill one time series of MeteoData for one station.
const std::string algo
Definition: GeneratorAlgorithms.h:161
const std::set< std::string > excluded_stations
Definition: GeneratorAlgorithms.h:158
void initHeightRestrictions(const std::vector< std::pair< std::string, std::string > > vecArgs)
Definition: GeneratorAlgorithms.cc:198
const std::set< std::string > kept_stations
Definition: GeneratorAlgorithms.h:158
static std::set< std::string > initStationSet(const std::vector< std::pair< std::string, std::string > > &vecArgs, const std::string &keyword)
Definition: GeneratorAlgorithms.cc:259
std::vector< DateRange > getTimeRestrictions() const
Definition: GeneratorAlgorithms.h:149
const std::vector< DateRange > time_restrictions
Definition: GeneratorAlgorithms.h:157
GeneratorAlgorithm(const std::vector< std::pair< std::string, std::string > > &vecArgs, const std::string &i_algo, const std::string &i_section, const double &TZ)
protected constructor only to be called by children
Definition: GeneratorAlgorithms.cc:195
std::set< double > included_heights
Definition: GeneratorAlgorithms.h:159
std::set< double > excluded_heights
Definition: GeneratorAlgorithms.h:159
virtual ~GeneratorAlgorithm()
Definition: GeneratorAlgorithms.h:113
virtual bool generate(const size_t &param, MeteoData &md, const std::vector< MeteoData > &vecMeteo)=0
bool skipHeight(const double &height) const
Definition: GeneratorAlgorithms.cc:250
static const double snow_thresh
Definition: GeneratorAlgorithms.h:164
const std::string section
Definition: GeneratorAlgorithms.h:161
static const double default_height
Definition: GeneratorAlgorithms.h:165
bool all_heights
Definition: GeneratorAlgorithms.h:160
static const double snow_albedo
Definition: GeneratorAlgorithms.h:164
bool skipStation(const std::string &station_id) const
Should this station be skipped, based on user-provided station ID restrictions?
Definition: GeneratorAlgorithms.cc:275
virtual void parse_args(const std::vector< std::pair< std::string, std::string > > &)
Definition: GeneratorAlgorithms.h:153
A class to represent a singular measurement received from one station at a certain time (represented ...
Definition: MeteoData.h:108
Definition: Config.cc:31