SNOWPACK  SNOWPACK-3.6.0
Hazard.h
Go to the documentation of this file.
1 /* **********************************************************************************************/
2 /* stand-alone */
3 /* Derived from RESEARCH VERSION 9.0 */
4 /* **********************************************************************************************/
5 /* **********************************************************************************/
6 /* Copyright WSL Institute for Snow and Avalanche Research SLF-DAVOS */
7 /* **********************************************************************************/
8 /* This file is part of Snowpack.
9  Snowpack is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  Snowpack is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with Snowpack. If not, see <http://www.gnu.org/licenses/>.
21 */
22 
29 #ifndef HAZARD_H
30 #define HAZARD_H
31 
32 #include <meteoio/MeteoIO.h>
33 #include <snowpack/DataClasses.h>
34 #include <vector>
35 
37 struct ProcessDat {
39  ch(0.), swe(0.), tot_lwc(0.), runoff(0.), dewpt_def(0.), hoar_size(0.), hoar_ind6(0.), hoar_ind24(0.),
40  wind_trans(0.), wind_trans24(0.),
41  hn_half_hour(0.), hn3(0.), hn6(0.), hn12(0.), hn24(0.), hn72(0.), hn72_24(0.),
42  psum_half_hour(0.), psum3(0.), psum6(0.), psum12(0.), psum24(0.), psum72(0.),
43  stab_class1(0), stab_class2(0),
45  crust(0.), en_bal(0.), sw_net(0.), t_top1(0.), t_top2(0.), lwi_N(0.), lwi_S(0.),
46  dhs_corr(0.), mass_corr(0.)
47  {}
48 
49  mio::Date date;
50  unsigned int nHz;
51  std::string stat_abbrev;
52  unsigned char loc_for_snow;
53  unsigned char loc_for_wind;
54  // Data
55  double ch;
56  double swe;
57  double tot_lwc;
58  double runoff;
59  double dewpt_def;
60  double hoar_size;
61  double hoar_ind6;
62  double hoar_ind24;
63  double wind_trans;
64  double wind_trans24;
65  double hn_half_hour;
66  double hn3;
67  double hn6;
68  double hn12;
69  double hn24;
70  double hn72;
71  double hn72_24;
72  double psum_half_hour;
73  double psum3;
74  double psum6;
75  double psum12;
76  double psum24;
77  double psum72;
78  signed char stab_class1;
79  signed char stab_class2;
80  double stab_index1;
81  double stab_height1;
82  double stab_index2;
83  double stab_height2;
84  double stab_index3;
85  double stab_height3;
86  double stab_index4;
87  double stab_height4;
88  double stab_index5;
89  double stab_height5;
90  // Special parameters
91  double crust;
92  double en_bal;
93  double sw_net;
94  double t_top1, t_top2;
95  double lwi_N, lwi_S;
96  // Control parameters
97  double dhs_corr;
98  double mass_corr;
99 };
100 
101 struct ProcessInd {
103  ch(true), swe(true), tot_lwc(true), runoff(true), dewpt_def(true),
104  hoar_size(true), hoar_ind6(true), hoar_ind24(true),
105  wind_trans(true), wind_trans24(true),
106  hn3(true), hn6(true), hn12(true), hn24(true), hn72(true), hn72_24(true), psum3(true), psum6(true), psum12(true), psum24(true), psum72(true),
107  stab_class1(true), stab_class2(true),
108  stab_index1(true), stab_height1(true), stab_index2(true), stab_height2(true), stab_index3(true), stab_height3(true), stab_index4(true), stab_height4(true), stab_index5(true), stab_height5(true),
109  crust(true), en_bal(true), sw_net(true), t_top1(true), t_top2(true), lwi_N(true), lwi_S(true)
110  {}
111 
115  // Data
116  bool ch;
117  bool swe;
118  bool tot_lwc;
119  bool runoff;
120  bool dewpt_def;
121  bool hoar_size;
124  bool hn3, hn6, hn12, hn24, hn72;
125  bool hn72_24;
133  bool crust;
134  bool en_bal;
135  bool sw_net;
136  bool t_top1, t_top2;
137  bool lwi_N, lwi_S;
138 };
139 
144 class Hazard {
145  public:
146  Hazard(const SnowpackConfig& cfg, const double duration);
147 
148  void initializeHazard(std::vector<double>& vecDrift, double slope_angle,
149  std::vector<ProcessDat>& Hdata, std::vector<ProcessInd>& Hdata_ind);
150 
151  void getHazardDataMainStation(ProcessDat& Hdata, ProcessInd& Hdata_ind,
152  ZwischenData& Zdata, const double& newDrift, const bool stationDriftIndex,
153  const SnowStation& Xdata, const CurrentMeteo& Mdata, const SurfaceFluxes& Sdata);
154 
155  void getHazardDataSlope(ProcessDat& Hdata, ProcessInd& Hdata_ind,
156  std::vector<double>& drift24, const double& newDrift, const SnowStation& Xdata,
157  const bool luvDriftIndex, const bool north, const bool south);
158 
159  static const double typical_slope_length, wind_slab_density;
160  static const double minimum_drift, maximum_drift;
161 
162  private:
163  enum ActVec {
164  noAction=0, // neither shift nor overwite index values
165  overwrite, // overwrite <index>[0] w/o shifting
166  pushOverwrite // push vector values and overwrite <index>[0]
167  };
168 
169  void actOnVector(std::vector<double>& oldVector, const double& newValue, const ActVec& action);
170 
171  double compDriftIndex(std::vector<double>& vecDrift, const double& drift, const double& rho,
172  const unsigned int& nHours, const double& slope_angle, const ActVec& action);
173 
174  void getDriftIndex(ProcessDat& Hdata, ProcessInd& Hdata_ind,
175  std::vector<double>& vecDrift, const double& newDriftValue, const double slope_angle);
176 
177  double compHoarIndex(std::vector<double> &oldHoar, const double& newHoar,
178  const unsigned int& nHours, const ActVec& action);
179 
180  double compDewPointDeficit(double TA, double TSS, double RH);
181 
182  void compMeltFreezeCrust(const SnowStation& Xdata, ProcessDat& Hdata, ProcessInd& Hdata_ind);
183 
184  bool research_mode, enforce_measured_snow_heights, force_rh_water;
185  unsigned int nHz, hazard_steps_between;
186  double sn_dt;
187  double hoar_density_surf, hoar_min_size_surf;
188 };
189 
190 #endif
double lwi_N
Definition: Hazard.h:95
double stab_index5
none
Definition: Hazard.h:88
bool tot_lwc
Definition: Hazard.h:118
bool hn72_24
Definition: Hazard.h:125
bool ch
Definition: Hazard.h:116
bool stab_index2
Definition: Hazard.h:129
ZwischenData contains "memory" information mainly for operational use It is used to prepare some para...
Definition: DataClasses.h:63
double stab_index1
deformation index Sdef
Definition: Hazard.h:80
bool hn72
Definition: Hazard.h:124
signed char stab_class1
stability classes 1,3,5
Definition: Hazard.h:78
double tot_lwc
total liquid water content (kg m-2)
Definition: Hazard.h:57
Definition: SnowpackConfig.h:28
std::string stat_abbrev
Definition: Hazard.h:51
double en_bal
internal energy change (kJ m-2)
Definition: Hazard.h:92
ProcessDat()
Definition: Hazard.h:38
mio::Date date
Process date.
Definition: Hazard.h:49
bool hoar_ind6
Definition: Hazard.h:122
Definition: Hazard.h:144
double psum6
6 h new snow water equivalent (kg m-2)
Definition: Hazard.h:74
double hn3
3 h depth of snowfall (cm)
Definition: Hazard.h:66
double sw_net
surface energy input (kJ m-2)
Definition: Hazard.h:93
double psum_half_hour
half_hour new snow water equivalent (kg m-2)
Definition: Hazard.h:72
ProcessInd()
Definition: Hazard.h:102
bool psum72
Definition: Hazard.h:126
double stab_index3
skier stability index Sk38
Definition: Hazard.h:84
bool stab_index5
Definition: Hazard.h:132
bool t_top2
Definition: Hazard.h:136
bool stab_index4
Definition: Hazard.h:131
double ch
height of snow HS (cm)
Definition: Hazard.h:55
double stab_height4
depth of stab_index4 (cm)
Definition: Hazard.h:87
unsigned char loc_for_wind
Definition: Hazard.h:53
Definition: DataClasses.h:589
double psum24
24 h new snow water equivalent (kg m-2)
Definition: Hazard.h:76
double stab_height5
depth of stab_index5 (cm)
Definition: Hazard.h:89
unsigned int nHz
Number of hazard steps.
Definition: Hazard.h:50
double psum72
72 h new snow water equivalent (kg m-2)
Definition: Hazard.h:77
double stab_height1
depth of stab_index1 (cm)
Definition: Hazard.h:81
bool swe
Definition: Hazard.h:117
double hn24
24 depth of snowfall (cm)
Definition: Hazard.h:69
double hoar_ind6
6 h surface hoar index (kg m-2)
Definition: Hazard.h:61
bool stab_index1
Definition: Hazard.h:128
CurrentMeteo is the class of interpolated meteo data for the current calculation time step It contai...
Definition: DataClasses.h:81
bool dewpt_def
Definition: Hazard.h:120
double t_top2
snow temperatures at depth 1 & 2, respectively (degC)
Definition: Hazard.h:94
double psum3
3 h new snow water equivalent (kg m-2)
Definition: Hazard.h:73
double lwi_S
liquid water index for northerly and southerly slopes, respectively.
Definition: Hazard.h:95
double wind_trans
6 h drifting snow index (cm)
Definition: Hazard.h:63
double mass_corr
mass correction from either forced erosion and squeezing (neg) or blowing up (pos) (cm) ...
Definition: Hazard.h:98
double hn72
72 depth of snowfall (cm)
Definition: Hazard.h:70
bool sw_net
Definition: Hazard.h:135
double hn12
12 h depth of snowfall (cm)
Definition: Hazard.h:68
double wind_trans24
24 h drifting snow index (cm)
Definition: Hazard.h:64
static const double wind_slab_density
Definition: Hazard.h:159
double t_top1
Definition: Hazard.h:94
double hn_half_hour
half_hour depth of snowfall (cm)
Definition: Hazard.h:65
unsigned char loc_for_snow
Definition: Hazard.h:52
bool stat_abbrev
Definition: Hazard.h:112
signed char stab_class2
profile type 0..10
Definition: Hazard.h:79
double hoar_ind24
24 h surface hoar index (kg m-2)
Definition: Hazard.h:62
double dhs_corr
snow depth correction in case of squezzing or blow-up (cm)
Definition: Hazard.h:97
bool loc_for_snow
Definition: Hazard.h:113
double swe
snow water equivalent SWE (kg m-2)
Definition: Hazard.h:56
bool runoff
Definition: Hazard.h:119
bool stab_index3
Definition: Hazard.h:130
bool hoar_size
Definition: Hazard.h:121
Structure of double values for output to SDB.
Definition: Hazard.h:37
Station data including all information on snowpack layers (elements and nodes) and on canopy This is...
Definition: DataClasses.h:468
double hn72_24
3 d sum of 24 h depth of snowfall (cm)
Definition: Hazard.h:71
double psum12
12 h new snow water equivalent (kg m-2)
Definition: Hazard.h:75
double dewpt_def
dew point deficit (degC)
Definition: Hazard.h:59
double stab_index2
natural stability index Sn38
Definition: Hazard.h:82
double stab_index4
structural stability index SSI
Definition: Hazard.h:86
bool crust
Definition: Hazard.h:133
static const double minimum_drift
Definition: Hazard.h:160
bool stab_class2
Definition: Hazard.h:127
double stab_height2
depth of stab_index2 (cm)
Definition: Hazard.h:83
double hn6
6 h depth of snowfall (cm)
Definition: Hazard.h:67
bool en_bal
Definition: Hazard.h:134
double stab_height3
depth of stab_index3 (cm)
Definition: Hazard.h:85
double hoar_size
24 h surface hoar size (mm)
Definition: Hazard.h:60
double crust
height of melt-freeze crust on southern slope (cm)
Definition: Hazard.h:91
bool wind_trans24
Definition: Hazard.h:123
double runoff
runoff (kg m-2)
Definition: Hazard.h:58
bool loc_for_wind
Definition: Hazard.h:114
bool lwi_S
Definition: Hazard.h:137
Definition: Hazard.h:101