Alpine3D 20240428.cd14b8b
MeteoObj.h
Go to the documentation of this file.
1/***********************************************************************************/
2/* Copyright 2009-2015 WSL Institute for Snow and Avalanche Research SLF-DAVOS */
3/***********************************************************************************/
4/* This file is part of Alpine3D.
5 Alpine3D 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 Alpine3D 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 Alpine3D. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef METEOOBJ_H
19#define METEOOBJ_H
20
21#include <meteoio/MeteoIO.h>
22#include <snowpack/libsnowpack.h>
23
24#include <alpine3d/MPIControl.h>
25#include <alpine3d/Glaciers.h>
26
27#include <iostream>
28
29class SnGrids {
30 public:
32 //Make sure you also put the parameters in the same order in SnGrids::initStaticData()!!
79
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 std::vector<std::string> paramname;
87 static const bool __init;
88 static bool initStaticData();
89};
90
92{
93 public:
94 MeteoObj(const mio::Config& config, const mio::DEMObject& in_dem);
95 ~MeteoObj();
96
97 void setSkipWind(const bool& i_skipWind);
98 void prepare(const mio::Date& in_date);
99 void get(const mio::Date& in_date,
100 mio::Grid2DObject& ta,
101 mio::Grid2DObject& rh,
102 mio::Grid2DObject& psum,
103 mio::Grid2DObject& psum_ph,
104 mio::Grid2DObject& vw,
105 mio::Grid2DObject& dw,
106 mio::Grid2DObject& p,
107 mio::Grid2DObject& ilwr,
108 mio::Grid2DObject& iswr_dir,
109 mio::Grid2DObject& iswr_diff);
110 void get(const mio::Date& in_date, std::vector<mio::MeteoData>& o_vecMeteo);
111 bool fillPrecSplitting();
112 void checkMeteoForcing(const mio::Date& calcDate);
113 void setGlacierMask(const mio::Grid2DObject& glacierMask);
114 void setDEM(const mio::DEMObject& in_dem);
115 double getTiming() const;
116
117 private:
118 static void checkLapseRate(const std::vector<mio::MeteoData>& i_vecMeteo, const mio::MeteoData::Parameters& param);
119 static void checkGridRange(const mio::Date& calcDate, const mio::Grid2DObject& grid, const mio::MeteoData::Parameters& param);
120 static void checkInputsRequirements(std::vector<mio::MeteoData>& vecData);
121 void fillMeteoGrids(const mio::Date& calcDate);
122 void getMeteo(const mio::Date& calcDate);
123
124 mio::Timer timer;
125 const mio::Config &config;
126 mio::IOManager io;
127 mio::DEMObject dem;
128 mio::Grid2DObject ta, rh, psum, psum_ph, vw, dw, p, ilwr, iswr_dir, iswr_diff;
129 mio::Grid2DObject sum_ta, sum_rh, sum_rh_psum, sum_psum, sum_psum_ph, sum_vw, sum_ilwr;
130 std::vector<mio::MeteoData> vecMeteo;
131 mio::Date date;
132 Glaciers *glaciers;
133 unsigned int count_sums, count_precip;
134 bool skipWind;
135 bool dataFromGrids;
136};
137
138#endif
Definition: Glaciers.h:48
Definition: MeteoObj.h:92
void setDEM(const mio::DEMObject &in_dem)
Definition: MeteoObj.cc:390
bool fillPrecSplitting()
Definition: MeteoObj.cc:291
void setGlacierMask(const mio::Grid2DObject &glacierMask)
Definition: MeteoObj.cc:382
double getTiming() const
Definition: MeteoObj.cc:213
void prepare(const mio::Date &in_date)
Definition: MeteoObj.cc:134
void setSkipWind(const bool &i_skipWind)
Definition: MeteoObj.cc:130
~MeteoObj()
Definition: MeteoObj.cc:125
MeteoObj(const mio::Config &config, const mio::DEMObject &in_dem)
Definition: MeteoObj.cc:113
void checkMeteoForcing(const mio::Date &calcDate)
Definition: MeteoObj.cc:400
void get(const mio::Date &in_date, mio::Grid2DObject &ta, mio::Grid2DObject &rh, mio::Grid2DObject &psum, mio::Grid2DObject &psum_ph, mio::Grid2DObject &vw, mio::Grid2DObject &dw, mio::Grid2DObject &p, mio::Grid2DObject &ilwr, mio::Grid2DObject &iswr_dir, mio::Grid2DObject &iswr_diff)
Definition: MeteoObj.cc:143
Definition: MeteoObj.h:29
static const std::string & getParameterName(const size_t &parindex)
Definition: MeteoObj.cc:92
static size_t getParameterIndex(const std::string &parname)
Definition: MeteoObj.cc:100
static const size_t nrOfParameters
holds the number of meteo parameters stored in MeteoData
Definition: MeteoObj.h:81
Parameters
this enum provides names for possible Snowpack grids
Definition: MeteoObj.h:33
@ MS_ICE_SOIL
The total amount of ice in the soil at the present time.
Definition: MeteoObj.h:66
@ DW
Wind direction (deg)
Definition: MeteoObj.h:37
@ TSNOW_AVG
Average snow temperature in the top xxx m.
Definition: MeteoObj.h:51
@ TOP_ALB
Albedo from the top (ie above canopy)
Definition: MeteoObj.h:55
@ PSUM_PH
Precipitation phase, between 0 (fully solid) and 1 (fully liquid)
Definition: MeteoObj.h:44
@ RG
grain radius
Definition: MeteoObj.h:59
@ TA
Air temperature.
Definition: MeteoObj.h:34
@ RSNO
Snow mean density.
Definition: MeteoObj.h:54
@ MS_SOIL_RUNOFF
runoff at the bottom of the snow/soil column
Definition: MeteoObj.h:63
@ TSOIL1
Definition: MeteoObj.h:76
@ SOIL_RUNOFF_MAX
Definition: MeteoObj.h:77
@ MS_SURFACE_MASS_FLUX
mass flux through the soil surface
Definition: MeteoObj.h:62
@ PSUM
Water equivalent of precipitations, either solid or liquid.
Definition: MeteoObj.h:43
@ MS_WATER_SOIL
The total amount of water in the soil at the present time.
Definition: MeteoObj.h:65
@ ISWR_TERRAIN
Short wave received by terrain reflection.
Definition: MeteoObj.h:73
@ PSUM_TECH
Water equivalent precipitation from artificial snow production.
Definition: MeteoObj.h:45
@ lastparam
Definition: MeteoObj.h:78
@ TS0
Temperature soil surface.
Definition: MeteoObj.h:49
@ MNS
drifted mass (when snowdrift is enabled)
Definition: MeteoObj.h:68
@ TSOIL4
Definition: MeteoObj.h:76
@ TSOIL3
Definition: MeteoObj.h:76
@ VW
Wind velocity.
Definition: MeteoObj.h:36
@ SURF_ALB
Albedo of the surface (ie below canopy)
Definition: MeteoObj.h:56
@ RHOSNOW_AVG
Average snow density in the top xxx m.
Definition: MeteoObj.h:52
@ ISWR_DIR
Incoming short wave, direct.
Definition: MeteoObj.h:40
@ STORE
internal usage (precipitation events that are delayed because they are too small)
Definition: MeteoObj.h:69
@ RB
bond radius
Definition: MeteoObj.h:58
@ SP
sphericity
Definition: MeteoObj.h:57
@ ET
Evapotranspiration.
Definition: MeteoObj.h:72
@ HS
Height of snow.
Definition: MeteoObj.h:42
@ SOIL_RUNOFF3
Definition: MeteoObj.h:77
@ RH
Relative humidity.
Definition: MeteoObj.h:35
@ ISWR
Incoming short wave radiation.
Definition: MeteoObj.h:38
@ firstparam
Definition: MeteoObj.h:33
@ TSOIL2
Definition: MeteoObj.h:76
@ SOIL_RUNOFF2
Definition: MeteoObj.h:77
@ ISWR_DIFF
Incoming short wave, diffuse.
Definition: MeteoObj.h:39
@ GROOMING
Used as a boolean flag to decide whever a pixel is scheduled for grooming or not.
Definition: MeteoObj.h:46
@ MS_SNOWPACK_RUNOFF
runoff on the surface of the soil (vitual lysimeter)
Definition: MeteoObj.h:61
@ SOIL_RUNOFF1
Definition: MeteoObj.h:77
@ N3
grain Coordination number
Definition: MeteoObj.h:60
@ MS_WATER
The total amount of water in the snowpack at the present time.
Definition: MeteoObj.h:64
@ TSG
Temperature ground surface.
Definition: MeteoObj.h:47
@ GLACIER
mask showing the glaciated pixels
Definition: MeteoObj.h:70
@ TSOIL_MAX
Temperature within the soil, at a given depth.
Definition: MeteoObj.h:76
@ SWE
Snow Water Equivalent.
Definition: MeteoObj.h:53
@ ILWR
Incoming long wave radiation.
Definition: MeteoObj.h:41
@ ISWR_BELOW_CAN
Definition: MeteoObj.h:75
@ TSS
Temperature snow surface.
Definition: MeteoObj.h:48
@ ILWR_TERRAIN
Long wave received by terrain emission.
Definition: MeteoObj.h:74
@ SFC_SUBL
The mass loss or gain of the top element due to snow (ice) sublimating.
Definition: MeteoObj.h:67
@ SOIL_RUNOFF4
Definition: MeteoObj.h:77
@ GLACIER_EXPOSED
mask showing the exposed glaciated pixels (ie not snow covered)
Definition: MeteoObj.h:71
@ TSNOW
Snow temperature at depth xxx m.
Definition: MeteoObj.h:50