MeteoIODoc  MeteoIODoc-2.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MeteoData.h
Go to the documentation of this file.
1 /***********************************************************************************/
2 /* Copyright 2009 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 METEODATA_H
19 #define METEODATA_H
20 
23 
24 #include <string>
25 #include <vector>
26 
27 namespace mio {
28 
29 class MeteoData; //forward declaration
30 typedef std::vector<MeteoData> METEO_SET;
31 
41 class MeteoGrids {
42  public:
46  RH,
47  QI,
48  TD,
49  VW,
50  DW,
52  ISWR,
53  RSWR,
56  ILWR,
58  HS,
59  PSUM,
63  TSG,
64  TSS,
66  P,
68  U,
69  V,
70  W,
71  SWE,
72  RSNO,
73  ROT,
74  ALB,
75  DEM,
78  AZI,
80 
81  static const size_t nrOfParameters;
82  static const std::string& getParameterName(const size_t& parindex);
83  static size_t getParameterIndex(const std::string& parname);
84 
85  private:
86  //static methods
87  static std::vector<std::string> paramname;
88  static const bool __init;
89  static bool initStaticData();
90 };
91 
101 class MeteoData {
102  public:
112  typedef enum MERGE_TYPE {
116  } Merge_Type;
117 
121  TA,
122  RH,
123  TSG,
124  TSS,
125  HS,
126  VW,
127  DW,
136 
137  static const std::string& getParameterName(const size_t& parindex);
138 
142  MeteoData(void);
143 
148  MeteoData(const Date& in_date);
149 
155  MeteoData(const Date& date_in, const StationData& meta_in);
156 
161  void setDate(const Date& in_date) {date = in_date;}
162 
169  size_t addParameter(const std::string& i_paramname);
170 
176  bool param_exists(const std::string& parname) const;
177 
182  void reset();
183 
184  bool isResampled() const {return resampled;}
185  void setResampled(const bool& in_resampled) {resampled = in_resampled;}
186 
187  void standardizeNodata(const double& plugin_nodata);
188 
189  double& operator()(const size_t& parindex);
190  const double& operator()(const size_t& parindex) const;
191  double& operator()(const std::string& parname);
192  const double& operator()(const std::string& parname) const;
193 
194  const std::string& getNameForParameter(const size_t& parindex) const;
195  size_t getParameterIndex(const std::string& parname) const;
196  size_t getNrOfParameters() const {return nrOfAllParameters;}
197 
208  static void mergeTimeSeries(std::vector<MeteoData>& vec1, const std::vector<MeteoData>& vec2, const Merge_Type& strategy=STRICT_MERGE);
209 
223  static void merge(std::vector<MeteoData>& vec1, const std::vector<MeteoData>& vec2, const bool& simple_merge=false);
224 
237  static void merge(std::vector<MeteoData>& vec, const MeteoData& meteo2, const bool& simple_merge=false);
238 
250  static void merge(std::vector<MeteoData>& vec);
251 
260  static MeteoData merge(MeteoData meteo1, const MeteoData& meteo2);
261 
269  void merge(const MeteoData& meteo2);
270 
276  static MeteoData::Merge_Type getMergeType(std::string merge_type);
277 
278  const std::string toString() const;
279  friend std::iostream& operator<<(std::iostream& os, const MeteoData& data);
280  friend std::iostream& operator>>(std::iostream& is, MeteoData& data);
281 
282  //Comparison operators
283  bool operator==(const MeteoData&) const;
284  inline bool operator!=(const MeteoData& in) const {return !(*this==in);}
285  inline bool operator<(const MeteoData& in) const {return (this->date < in.date);}
286  inline bool operator>(const MeteoData& in) const {return (this->date > in.date);}
287 
288  //direct access allowed
291 
292  static const size_t nrOfParameters;
293 
294  private:
295  //static methods
296  static std::vector<std::string> s_default_paramname;
297  static const double epsilon;
298  static const bool __init;
299  static bool initStaticData();
300 
301  //private data members, please keep the order consistent with declaration lists and logic!
302  std::vector<std::string> extra_param_name;
303  std::vector<double> data;
304  size_t nrOfAllParameters;
305  bool resampled;
306 };
307 
308 } //end namespace
309 
310 #endif
bool param_exists(const std::string &parname) const
Check whether a certain parameter is a part of this MeteoData instance.
Definition: MeteoData.cc:147
Dew Point temperature.
Definition: MeteoData.h:48
Incoming short wave, diffuse.
Definition: MeteoData.h:54
bool isResampled() const
Definition: MeteoData.h:184
Station1 receives data from station2 only for common timestamps.
Definition: MeteoData.h:113
size_t addParameter(const std::string &i_paramname)
Add another variable to the MeteoData object, a double value will be added and the nrOfParameters inc...
Definition: MeteoData.cc:163
Height of snow.
Definition: MeteoData.h:125
Snow mean density.
Definition: MeteoData.h:72
North component of wind.
Definition: MeteoData.h:69
friend std::iostream & operator<<(std::iostream &os, const MeteoData &data)
Definition: MeteoData.cc:296
Maximum wind velocity.
Definition: MeteoData.h:51
Cloud transmissivity or ISWR/ISWR_clear_sky.
Definition: MeteoData.h:57
static size_t getParameterIndex(const std::string &parname)
Definition: MeteoData.cc:86
Definition: MeteoData.h:44
std::vector< MeteoData > METEO_SET
Definition: MeteoData.h:29
Precipitation phase: between 0 (fully solid) and 1(fully liquid)
Definition: MeteoData.h:134
Cloud transmissivity or ISWR/ISWR_clear_sky.
Definition: MeteoData.h:132
Relative humidity.
Definition: MeteoData.h:46
StationData meta
The meta data of the measurement.
Definition: MeteoData.h:290
void standardizeNodata(const double &plugin_nodata)
Standardize nodata values The plugin-specific nodata values are replaced by MeteoIO's internal nodata...
Definition: MeteoData.cc:201
Reflected short wave radiation.
Definition: MeteoData.h:129
Temperature within the soil, at a given depth.
Definition: MeteoData.h:65
Water equivalent of precipitations, either solid or liquid.
Definition: MeteoData.h:133
Temperature snow surface.
Definition: MeteoData.h:64
Wind direction.
Definition: MeteoData.h:50
Albedo.
Definition: MeteoData.h:74
const std::string toString() const
Definition: MeteoData.cc:279
Air pressure.
Definition: MeteoData.h:120
Air pressure.
Definition: MeteoData.h:66
Specific humidity.
Definition: MeteoData.h:47
friend std::iostream & operator>>(std::iostream &is, MeteoData &data)
Definition: MeteoData.cc:316
Water equivalent of precipitations, either solid or liquid.
Definition: MeteoData.h:59
Incoming short wave radiation.
Definition: MeteoData.h:130
size_t getNrOfParameters() const
Definition: MeteoData.h:196
static const size_t nrOfParameters
holds the number of meteo parameters stored in MeteoData
Definition: MeteoData.h:292
Parameters
Definition: MeteoData.h:119
void setDate(const Date &in_date)
A setter function for the measurement date.
Definition: MeteoData.h:161
Water equivalent of solid precipitation.
Definition: MeteoData.h:62
Hillshade.
Definition: MeteoData.h:76
A class to represent the meteorological parameters that could be contained in a grid. This should be very close to MeteoData with a few additions (like the wind u,v,w)
Definition: MeteoData.h:41
Temperature of the snow surface.
Definition: MeteoData.h:124
size_t getParameterIndex(const std::string &parname) const
Definition: MeteoData.cc:263
Sea level air pressure.
Definition: MeteoData.h:67
bool operator<(const MeteoData &in) const
so vectors can be sorted by timestamps
Definition: MeteoData.h:285
MeteoData(void)
The default constructor initializing every double attribute to nodata and the Date to julian==0...
Definition: MeteoData.cc:180
East component of wind.
Definition: MeteoData.h:68
If station2 can provide some data before/after station1, this extra data is added to station1...
Definition: MeteoData.h:114
static void merge(std::vector< MeteoData > &vec1, const std::vector< MeteoData > &vec2, const bool &simple_merge=false)
Simple merge strategy for vectors containing meteodata for a given timestamp. If some fields of the M...
Definition: MeteoData.cc:464
static void mergeTimeSeries(std::vector< MeteoData > &vec1, const std::vector< MeteoData > &vec2, const Merge_Type &strategy=STRICT_MERGE)
Simple merge strategy for two vectors containing meteodata time series for two stations. If some fields of the MeteoData objects given in the first vector are nodata, they will be filled by the matching field from the MeteoData objects given in the second vector (if the same timestamp exist).
Definition: MeteoData.cc:359
Vertical component of wind.
Definition: MeteoData.h:70
Air temperature.
Definition: MeteoData.h:45
Digital Elevation Model.
Definition: MeteoData.h:75
Total generated runoff.
Definition: MeteoData.h:73
bool operator>(const MeteoData &in) const
so vectors can be sorted by timestamps
Definition: MeteoData.h:286
Incoming short wave radiation.
Definition: MeteoData.h:52
Merge_Type
Available MeteoData merging strategies. When the two stations both have data at a given time step...
Definition: MeteoData.h:112
static const std::string & getParameterName(const size_t &parindex)
Definition: MeteoData.cc:126
Date date
Timestamp of the measurement.
Definition: MeteoData.h:289
Water equivalent of liquid precipitation.
Definition: MeteoData.h:61
static const size_t nrOfParameters
holds the number of meteo parameters stored in MeteoData
Definition: MeteoData.h:81
Precipitation phase, between 0 (fully solid) and 1 (fully liquid)
Definition: MeteoData.h:60
Snow Water Equivalent.
Definition: MeteoData.h:71
Maximum wind velocity.
Definition: MeteoData.h:128
static MeteoData::Merge_Type getMergeType(std::string merge_type)
Parse a string containing a merge type and return the proper enum member for it.
Definition: MeteoData.cc:339
Height of snow.
Definition: MeteoData.h:58
Air temperature.
Definition: MeteoData.h:121
A class to handle timestamps. This class handles conversion between different time display formats (I...
Definition: Date.h:79
Wind direction.
Definition: MeteoData.h:127
Relative humidity.
Definition: MeteoData.h:122
A class to represent meteo stations with attributes like longitude, latitude, etc.
Definition: StationData.h:38
Incoming short wave, direct.
Definition: MeteoData.h:55
Definition: MeteoData.h:79
void reset()
Resets all the meteo parameters to IOUtils::nodata NOTE: member vars date and resampled are not affec...
Definition: MeteoData.cc:192
Incoming long wave radiation (downwelling)
Definition: MeteoData.h:131
Wind velocity.
Definition: MeteoData.h:126
A class to represent a singular measurement received from one station at a certain time (represented ...
Definition: MeteoData.h:101
Wind velocity.
Definition: MeteoData.h:49
Reflected short wave radiation.
Definition: MeteoData.h:53
DEM slope azimuth.
Definition: MeteoData.h:78
bool operator!=(const MeteoData &in) const
Operator that tests for inequality.
Definition: MeteoData.h:284
static const std::string & getParameterName(const size_t &parindex)
Definition: MeteoData.cc:78
Incoming long wave radiation.
Definition: MeteoData.h:56
Temperature of the ground surface.
Definition: MeteoData.h:123
DEM slope angle.
Definition: MeteoData.h:77
bool operator==(const MeteoData &) const
Operator that tests for equality.
Definition: MeteoData.cc:210
Parameters
Definition: MeteoData.h:44
Definition: MeteoData.h:119
double & operator()(const size_t &parindex)
Definition: MeteoData.cc:227
const std::string & getNameForParameter(const size_t &parindex) const
Definition: MeteoData.cc:138
void setResampled(const bool &in_resampled)
Definition: MeteoData.h:185
Temperature ground surface.
Definition: MeteoData.h:63
Definition: MeteoData.h:135
All timestamps from station2 are brought into station1 even if the timestamps don't match...
Definition: MeteoData.h:115