Alpine3D

Alpine3D Svn Source Tree

Root/trunk/alpine3d/TechSnowA3D.h

1/***********************************************************************************/
2/* Copyright 2018-2018 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 TECHSNOWA3D_H
19#define TECHSNOWA3D_H
20
21class SnowpackInterfaceWorker;
22
23#include <meteoio/MeteoIO.h>
24#include <snowpack/libsnowpack.h>
25#include <alpine3d/MeteoObj.h>
26
27/**
28 * @page techsnowA3D Technical Snow
29 * @details
30 * Implementation of technical snow production and grooming. Slopes are tagged in a provided 2D grid
31 * (same geolocalization as the DEM) where each pixel either has its slope number or nodata.
32 * Then different snow production priorities (1, 2, 3 etc) are available and can be attributed to
33 * the individual ski slopes. The number of priorities is unlimited, their relative order has no
34 * special meaning but it is not possible to have gaps in the numbering when defining the properties
35 * of the priorities (see below for the configuration keys).Please also keep in mind that during
36 * the ski season, snow is only produced when the slopes are closed to the public.
37 *
38 * This module works hand in hand with the Snowpack TechSnow module, so it also uses the configuration keys defined in
39 * <a href="https://models.slf.ch/docserver/snowpack/html/classTechSnow.html">Snowpack::TechSnow</a> to control the grooming.
40 *
41 * Then, it relies on the following configuration keys, all in the [TechSnow] section:
42 * - SNOW_PRODUCTION: if set to true, enables this module (default: false);
43 * - SKIRUNS_FILE: the grid where all the pixels are tagged either with their slope number or nodata;
44 * - SLOPE_CONDITIONS: CSV file that gives the properties of each slope
45 * - SEASON_OPENING: Ski resort opening dates of the skiing season
46 * - SEASON_CLOSING: Ski resort ending dates of the skiing season
47 * - SLOPE_OPEN: at what local time do the slopes open to the public?
48 * - SLOPE_CLOSED: at what local time do the slopes close to the public?
49 * - MAX_SNOWGUN_WATER: max l/s that a snogun can provide
50 *
51 * For each snow production priority, the following keys are defined (unlimited number of priorities
52 * but please, no gaps in the numbering!):
53 * - PRIO\#\::start_prod: snow production starting date
54 * - PRIO\#\::end_prod: date of the end of snow production
55 * - PRIO\#\::start_aim: Snow production aim in snow height [m] until ski resort opening (factor x snow_prod_min)
56 * - PRIO\#\::end_aim: Snow production aim in snow height [m] until ski resort ending (factor x snow_prod_min)
57 * - PRIO\#\::gun_operation: Percentage of snow gun operation [%]
58 *
59 * The *slope conditions* file is a CSV file (the '#' or ';' characters are used to comment a line or part of it) that
60 * contains the following: the slope number, the slope area, the number of snow guns, its priority, the minimum snow
61 * height and wetbulb threshold temperature that should be present on the slope. For example:
62 * @code
63 * #slope_numbernr_snowgunspriorityminimum_hswetbulb_threshold
64 * #[-] [-][-][m][°C]
65 * 11010.6-2.0
66 * @endcode
67 *
68 *@author Mathias Bavay, Pirmin Ebner and others
69 */
70class TechSnowA3D
71{
72public:
73TechSnowA3D(const mio::Config& cfg, const mio::DEMObject& dem);
74
75void setMeteo(const mio::Grid2DObject& ta,
76 const mio::Grid2DObject& rh,
77 const mio::Grid2DObject& hs,
78 const mio::Date& timestamp);
79
80mio::Grid2DObject getGrid(const SnGrids::Parameters& param) const;
81
82static std::string getGridsRequirements() { return "TA RH HS"; }
83
84private:
85typedef struct CONDITION {
86CONDITION()
87 : slope_area(0.), number_snowguns(0), priority(mio::IOUtils::unodata), min_height(0.) {}
88
89void setUserProperties(const unsigned int& nr_snowguns, const unsigned int& i_priority, const double& i_min_height, const double& wb_thresh) {
90number_snowguns = nr_snowguns;
91priority = i_priority;
92min_height = i_min_height;
93wet_bulb_thresh = wb_thresh;
94}
95
96const std::string toString() {std::ostringstream os; os << "[" << slope_area << "m², " << number_snowguns << " snowguns, " << priority << " priority, " << min_height << "m min, min wbt: " << wet_bulb_thresh << "°C]"; return os.str();}
97
98double slope_area;//area of the slope section
99unsigned int number_snowguns;//number of snow guns per slope section
100unsigned int priority;//snow production priority for this slope
101double min_height;//minimum snow height for technical snow production
102double wet_bulb_thresh;//wet bulb temperature threshold (°C) below which snow can be produced
103} condition;
104
105typedef struct SNOWSTRATEGY {
106SNOWSTRATEGY() : startProd(), endProd(), startAim(0.), endAim(0.), gunOperation(0.) {}
107const std::string toString() {std::ostringstream os; os << "[" << startProd.toString(mio::Date::ISO) << "-" << endProd.toString(mio::Date::ISO) << " aim: " << startAim << " -> " << endAim << " @ " << gunOperation << "]"; return os.str();}
108
109mio::Date startProd;//start date of snow production
110mio::Date endProd;//end date of snow production
111double startAim;//snow production aim in snow height [m] until ski resort opening (factor x snow_prod_min)
112double endAim;//snow production aim in snow height [m] between ski resort opening and end date of snow production (factor x snow_prod_min)
113double gunOperation;//percentage of snow gun operation
114} snowStrategy;
115
116static TechSnowA3D::snowStrategy setSnowStrategy(const mio::Config& cfg, const double& TZ, const unsigned int& nr);
117void setSlopeConditions(const std::string& filename);
118static size_t getSlopeNumber(const double& dbl_code);
119double setPriority(const mio::Date& date, const TechSnowA3D::snowStrategy &ppt, const double& snow_height, const TechSnowA3D::condition& slope, const int date_hour) const;
120
121mio::Grid2DObject skiRunsMap; ///< All ski runs pixels are tagged by ski run and section number
122mio::Grid2DObject psum_tech;
123
124std::map<size_t, condition> slope_conditions;
125mio::Date start_season, end_season;///< start and end of ski season (snow is only produced at off hours during ski season)
126mio::Date earliest_production;///< this is only used to optimize the processing
127std::vector<snowStrategy> priorities;
128
129double max_snowgun_water;///< max l/s that a snogun can provide
130const double mean_elevation;
131int slope_open, slope_closed; ///< local hour for slope opening / closing
132};
133
134#endif

Archive Download this file

Revision: HEAD