MeteoIODoc  MeteoIODoc-2.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
InterpolationAlgorithms.h
Go to the documentation of this file.
1 /***********************************************************************************/
2 /* Copyright 2010 WSL Institute for Snow and Avalanche Research SLF-DAVOS */
3 /***********************************************************************************/
4 /* This file is part of MeteoIO.
5  MeteoIO is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  MeteoIO is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef INTERPOLATIONALGORITHMS_H
19 #define INTERPOLATIONALGORITHMS_H
20 
24 #include <meteoio/GridsManager.h>
27 
28 #include <vector>
29 #include <string>
30 
31 namespace mio {
32 
33 class Meteo2DInterpolator; // forward declaration, cyclic header include
34 
44 
45  public:
47  const std::vector<std::string>& i_vecArgs,
48  const std::string& i_algo, TimeSeriesManager& i_tsmanager, GridsManager& i_gridsmanager) :
49  algo(i_algo), mi(i_mi), tsmanager(i_tsmanager), gridsmanager(i_gridsmanager), date(0., 0), vecArgs(i_vecArgs), vecMeteo(), vecData(),
50  vecMeta(), info(), param(MeteoData::firstparam), nrOfMeasurments(0) {}
52  //if anything is not ok (wrong parameter for this algo, insufficient data, etc) -> return zero
53  virtual double getQualityRating(const Date& i_date, const MeteoData::Parameters& in_param) = 0;
54  virtual void calculate(const DEMObject& dem, Grid2DObject& grid) = 0;
55  std::string getInfo() const;
56  const std::string algo;
57 
58  protected:
59  size_t getData(const Date& i_date, const MeteoData::Parameters& i_param, std::vector<double>& o_vecData);
60  size_t getData(const Date& i_date, const MeteoData::Parameters& i_param,
61  std::vector<double>& o_vecData, std::vector<StationData>& o_vecMeta);
62  static size_t getStationAltitudes(const std::vector<StationData>& i_vecMeta, std::vector<double>& o_vecData);
63  void getTrend(const std::vector<double>& vecAltitudes, const std::vector<double>& vecDat, Fit1D &trend) const;
64  static void detrend(const Fit1D& trend, const std::vector<double>& vecAltitudes, std::vector<double> &vecDat, const double& min_alt=-1e4, const double& max_alt=1e4);
65  static void retrend(const DEMObject& dem, const Fit1D& trend, Grid2DObject &grid, const double& min_alt=-1e4, const double& max_alt=1e4);
66  void simpleWindInterpolate(const DEMObject& dem, const std::vector<double>& vecDataVW, const std::vector<double>& vecDataDW, Grid2DObject &VW, Grid2DObject &DW);
67 
72  const std::vector<std::string> vecArgs; //we must keep our own copy, it is different for each algorithm!
73 
74  std::vector<MeteoData> vecMeteo;
75  std::vector<double> vecData;
76  std::vector<StationData> vecMeta;
77  std::ostringstream info;
79  size_t nrOfMeasurments;
80 };
81 
83  public:
84  static InterpolationAlgorithm* getAlgorithm(const std::string& i_algoname,
85  Meteo2DInterpolator& i_mi,
86  const std::vector<std::string>& i_vecArgs, TimeSeriesManager& tsm, GridsManager& gdm);
87 };
88 
89 } //end namespace mio
90 
91 #endif
GridsManager & gridsmanager
Definition: InterpolationAlgorithms.h:70
static void retrend(const DEMObject &dem, const Fit1D &trend, Grid2DObject &grid, const double &min_alt=-1e4, const double &max_alt=1e4)
Definition: InterpolationAlgorithms.cc:342
void simpleWindInterpolate(const DEMObject &dem, const std::vector< double > &vecDataVW, const std::vector< double > &vecDataDW, Grid2DObject &VW, Grid2DObject &DW)
Definition: InterpolationAlgorithms.cc:361
static size_t getStationAltitudes(const std::vector< StationData > &i_vecMeta, std::vector< double > &o_vecData)
Definition: InterpolationAlgorithms.cc:245
static InterpolationAlgorithm * getAlgorithm(const std::string &i_algoname, Meteo2DInterpolator &i_mi, const std::vector< std::string > &i_vecArgs, TimeSeriesManager &tsm, GridsManager &gdm)
Definition: InterpolationAlgorithms.cc:158
Date date
Definition: InterpolationAlgorithms.h:71
Definition: GridsManager.h:28
size_t nrOfMeasurments
the available number of measurements
Definition: InterpolationAlgorithms.h:79
TimeSeriesManager & tsmanager
Definition: InterpolationAlgorithms.h:69
std::vector< StationData > vecMeta
store the station data for the given parameter
Definition: InterpolationAlgorithms.h:76
Parameters
Definition: MeteoData.h:119
static void detrend(const Fit1D &trend, const std::vector< double > &vecAltitudes, std::vector< double > &vecDat, const double &min_alt=-1e4, const double &max_alt=1e4)
Definition: InterpolationAlgorithms.cc:326
size_t getData(const Date &i_date, const MeteoData::Parameters &i_param, std::vector< double > &o_vecData)
Definition: InterpolationAlgorithms.cc:213
A class to perform 2D spatial interpolations. For more, see Spatial interpolations.
Definition: InterpolationAlgorithms.h:43
std::vector< double > vecData
store the measurement for the given parameter
Definition: InterpolationAlgorithms.h:75
std::ostringstream info
to store some extra information about the interplation process
Definition: InterpolationAlgorithms.h:77
InterpolationAlgorithm(Meteo2DInterpolator &i_mi, const std::vector< std::string > &i_vecArgs, const std::string &i_algo, TimeSeriesManager &i_tsmanager, GridsManager &i_gridsmanager)
Definition: InterpolationAlgorithms.h:46
A class to represent DEMs and automatically compute some properties. This class stores elevation grid...
Definition: DEMObject.h:39
virtual void calculate(const DEMObject &dem, Grid2DObject &grid)=0
std::vector< MeteoData > vecMeteo
Definition: InterpolationAlgorithms.h:74
A class to represent 2D Grids. Typical application as DEM or Landuse Model.
Definition: Grid2DObject.h:37
const std::vector< std::string > vecArgs
Definition: InterpolationAlgorithms.h:72
virtual ~InterpolationAlgorithm()
Definition: InterpolationAlgorithms.h:51
A class to spatially interpolate meteo parameters. For more, see Spatial interpolations.
Definition: Meteo2DInterpolator.h:99
A class to perform 1D regressions It works on a time serie and uses either ad-hoc methods or matrix a...
Definition: libfit1D.h:119
std::string getInfo() const
Return an information string about the interpolation process.
Definition: InterpolationAlgorithms.cc:263
A class to handle timestamps. This class handles conversion between different time display formats (I...
Definition: Date.h:79
Definition: InterpolationAlgorithms.h:82
virtual double getQualityRating(const Date &i_date, const MeteoData::Parameters &in_param)=0
A class to represent a singular measurement received from one station at a certain time (represented ...
Definition: MeteoData.h:101
MeteoData::Parameters param
the parameter that we will interpolate
Definition: InterpolationAlgorithms.h:78
const std::string algo
Definition: InterpolationAlgorithms.h:56
Definition: TimeSeriesManager.h:31
void getTrend(const std::vector< double > &vecAltitudes, const std::vector< double > &vecDat, Fit1D &trend) const
Read the interpolation arguments and compute the trend accordingly.
Definition: InterpolationAlgorithms.cc:282
Meteo2DInterpolator & mi
Definition: InterpolationAlgorithms.h:68