Alpine3D

Alpine3D Svn Source Tree

Root/trunk/alpine3d/MeteoObj.h

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 {
30public:
31/// \anchor SnGrids this enum provides names for possible Snowpack grids
32//Make sure you also put the parameters in the same order in SnGrids::initStaticData()!!
33enum Parameters {firstparam=0,
34 TA=firstparam, ///< Air temperature
35 RH, ///< Relative humidity
36 VW, ///< Wind velocity
37 DW, ///< Wind direction (deg)
38 ISWR, ///< Incoming short wave radiation
39 ISWR_DIFF, ///< Incoming short wave, diffuse
40 ISWR_DIR, ///< Incoming short wave, direct
41 ILWR, ///< Incoming long wave radiation
42 HS, ///< Height of snow
43 PSUM, ///< Water equivalent of precipitations, either solid or liquid
44 PSUM_PH, ///< Precipitation phase, between 0 (fully solid) and 1 (fully liquid)
45 PSUM_TECH, ///< Water equivalent precipitation from artificial snow production
46 GROOMING, ///< Used as a boolean flag to decide whever a pixel is scheduled for grooming or not
47 TSG, ///< Temperature ground surface
48 TSS, ///< Temperature snow surface
49 TS0, ///< Temperature soil surface
50 TSNOW, ///< Snow temperature at depth xxx m
51 TSNOW_AVG, ///< Average snow temperature in the top xxx m
52 RHOSNOW_AVG, ///< Average snow density in the top xxx m
53 SWE, ///< Snow Water Equivalent
54 RSNO, ///< Snow mean density
55 TOP_ALB, ///< Albedo from the top (ie above canopy)
56 SURF_ALB, ///< Albedo of the surface (ie below canopy)
57 SP, ///< sphericity
58 RB, ///< bond radius
59 RG, ///< grain radius
60 N3, ///< grain Coordination number
61 MS_SNOWPACK_RUNOFF, ///< runoff on the surface of the soil (vitual lysimeter)
62 MS_SOIL_RUNOFF, ///< runoff at the bottom of the snow/soil column
63 MS_WATER, ///< The total amount of water in the snowpack at the present time
64 SFC_SUBL, ///< The mass loss or gain of the top element due to snow (ice) sublimating
65 MNS, ///< drifted mass (when snowdrift is enabled)
66 STORE, ///< internal usage (precipitation events that are delayed because they are too small)
67 GLACIER, ///< mask showing the glaciated pixels
68 GLACIER_EXPOSED, ///< mask showing the exposed glaciated pixels (ie not snow covered)
69 ET, ///< Evapotranspiration
70 TSOIL1, TSOIL2, TSOIL3, TSOIL4, TSOIL5, ///< Temperature within the soil, at a given depth
71 lastparam=TSOIL5};
72
73
74static const size_t nrOfParameters; ///<holds the number of meteo parameters stored in MeteoData
75static const std::string& getParameterName(const size_t& parindex);
76static size_t getParameterIndex(const std::string& parname);
77
78private:
79static std::vector<std::string> paramname;
80static const bool __init; ///<helper variable to enable the init of static collection data
81static bool initStaticData();///<initialize the static map meteoparamname
82};
83
84class MeteoObj
85{
86public:
87MeteoObj(const mio::Config& config, const mio::DEMObject& in_dem);
88~MeteoObj();
89
90void setSkipWind(const bool& i_skipWind);
91void prepare(const mio::Date& in_date);
92void get(const mio::Date& in_date,
93 mio::Grid2DObject& ta,
94 mio::Grid2DObject& rh,
95 mio::Grid2DObject& psum,
96 mio::Grid2DObject& psum_ph,
97 mio::Grid2DObject& vw,
98 mio::Grid2DObject& dw,
99 mio::Grid2DObject& p,
100 mio::Grid2DObject& ilwr);
101void get(const mio::Date& in_date, std::vector<mio::MeteoData>& o_vecMeteo);
102void checkMeteoForcing(const mio::Date& calcDate);
103void setGlacierMask(const mio::Grid2DObject& glacierMask);
104double getTiming() const;
105
106private:
107static void checkLapseRate(const std::vector<mio::MeteoData>& i_vecMeteo, const mio::MeteoData::Parameters& param);
108static void checkGridRange(const mio::Date& calcDate, const mio::Grid2DObject& grid, const mio::MeteoData::Parameters& param);
109static void checkInputsRequirements(std::vector<mio::MeteoData>& vecData);
110void fillMeteoGrids(const mio::Date& calcDate);
111void getMeteo(const mio::Date& calcDate);
112
113mio::Timer timer;
114const mio::Config &config;
115mio::IOManager io;
116const mio::DEMObject &dem;
117mio::Grid2DObject ta, rh, psum, psum_ph, vw, dw, p, ilwr;
118mio::Grid2DObject sum_ta, sum_rh, sum_rh_psum, sum_psum, sum_psum_ph, sum_vw, sum_ilwr;
119std::vector<mio::MeteoData> vecMeteo;
120mio::Date date;
121Glaciers *glaciers;
122unsigned int count_sums, count_precip;
123bool skipWind; ///<should the grids be filled or only the data vectors returned?
124};
125
126#endif

Archive Download this file

Revision: HEAD