MeteoIODoc 20241221.207bde49
SyntheticIO.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-3.0-or-later
2/***********************************************************************************/
3/* Copyright 2022 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 SYNTHETICIO_H
20#define SYNTHETICIO_H
21
22#include <meteoio/IOInterface.h>
23
24#include <string>
25
26namespace mio {
34 public:
35 /*Synthesizer(const std::string& station, const std::string& parname, const std::vector< std::pair<std::string, std::string> >& vecArgs) {(void)vecArgs;}*/
36 virtual ~Synthesizer() {}
37
38 virtual double generate(const Date& dt) const {(void)dt; return IOUtils::nodata;}
39};
40
41//object factory for the Synthesizer class
43 public:
44 static Synthesizer* getSynth(std::string type, const std::string& station, const StationData& sd, const std::string& parname, const std::vector< std::pair<std::string, std::string> >& vecArgs, const double& TZ);
45};
46
47
56class SynthIO : public IOInterface {
57 public:
58 SynthIO(const std::string& configfile);
60 SynthIO(const Config& cfgreader);
61
62 ~SynthIO();
63
64 virtual void readStationData(const Date& date, std::vector<StationData>& vecStation);
65 virtual void readMeteoData(const Date& dateStart, const Date& dateEnd,
66 std::vector< std::vector<MeteoData> >& vecMeteo);
67
68 private:
69 void init();
70 std::map< std::string, Synthesizer* > getSynthesizer(const std::string& stationRoot, const StationData &sd) const;
71
72 const Config cfg;
73 std::map< std::string, std::map< std::string, Synthesizer* > > mapSynthesizers; //map[station][parmname] to contain the Synthesizer
74 std::vector<StationData> vecStations;
75 Date dt_start, dt_end;
76 double dt_step, TZ;
77};
78
80//below derived classes of Synthesizer to implement specific algorithms (or generators)
81class CST_Synth : public Synthesizer {
82 public:
83 CST_Synth(const std::string& station, const std::string& parname, const std::vector< std::pair<std::string, std::string> >& vecArgs);
84 virtual double generate(const Date& dt) const override;
85 private:
86 double value;
87};
88
89class STEP_Synth : public Synthesizer {
90 public:
91 STEP_Synth(const std::string& station, const std::string& parname, const std::vector< std::pair<std::string, std::string> >& vecArgs, const double& TZ);
92 virtual double generate(const Date& dt) const override;
93 private:
94 Date dt_step;
95 double value_before, value_after;
96};
97
98class RECT_Synth : public Synthesizer {
99 public:
100 RECT_Synth(const std::string& station, const std::string& parname, const std::vector< std::pair<std::string, std::string> >& vecArgs, const double& TZ);
101 virtual double generate(const Date& dt) const override;
102 private:
103 Date step_start, step_stop;
104 double value, value_step;
105};
106
108 public:
109 STDPRESS_Synth(const StationData& sd);
110 virtual double generate(const Date& dt) const override;
111 private:
112 double altitude;
113};
114
115} //namespace
116#endif
Definition: SyntheticIO.h:81
virtual double generate(const Date &dt) const override
Definition: SyntheticIO.cc:247
CST_Synth(const std::string &station, const std::string &parname, const std::vector< std::pair< std::string, std::string > > &vecArgs)
Definition: SyntheticIO.cc:230
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 representing the IO Layer of the software Alpine3D. For each type of IO (File,...
Definition: IOInterface.h:98
Definition: SyntheticIO.h:98
virtual double generate(const Date &dt) const override
Definition: SyntheticIO.cc:319
RECT_Synth(const std::string &station, const std::string &parname, const std::vector< std::pair< std::string, std::string > > &vecArgs, const double &TZ)
Definition: SyntheticIO.cc:287
Definition: SyntheticIO.h:107
STDPRESS_Synth(const StationData &sd)
Definition: SyntheticIO.cc:327
virtual double generate(const Date &dt) const override
Definition: SyntheticIO.cc:330
Definition: SyntheticIO.h:89
virtual double generate(const Date &dt) const override
Definition: SyntheticIO.cc:279
STEP_Synth(const std::string &station, const std::string &parname, const std::vector< std::pair< std::string, std::string > > &vecArgs, const double &TZ)
Definition: SyntheticIO.cc:252
A class to represent meteo stations with attributes like longitude, latitude, etc.
Definition: StationData.h:41
Definition: SyntheticIO.h:42
static Synthesizer * getSynth(std::string type, const std::string &station, const StationData &sd, const std::string &parname, const std::vector< std::pair< std::string, std::string > > &vecArgs, const double &TZ)
Definition: SyntheticIO.cc:338
This plugin generate synthetic data.
Definition: SyntheticIO.h:56
virtual void readStationData(const Date &date, std::vector< StationData > &vecStation)
Fill vecStation with StationData objects for a certain date of interest.
Definition: SyntheticIO.cc:176
~SynthIO()
Definition: SyntheticIO.cc:86
SynthIO(const std::string &configfile)
Definition: SyntheticIO.cc:76
virtual void readMeteoData(const Date &dateStart, const Date &dateEnd, std::vector< std::vector< MeteoData > > &vecMeteo)
Fill vecMeteo with a time series of objects corresponding to the interval indicated by dateStart and ...
Definition: SyntheticIO.cc:184
SynthIO(const SynthIO &)
Generator to produce synthetic data for the SynthIO plugin.
Definition: SyntheticIO.h:33
virtual ~Synthesizer()
Definition: SyntheticIO.h:36
virtual double generate(const Date &dt) const
Definition: SyntheticIO.h:38
const double nodata
This is the internal nodata value.
Definition: IOUtils.h:75
Definition: Config.cc:31