TECA
The Toolkit for Extreme Climate Analysis
teca_saffir_simpson.h
Go to the documentation of this file.
1 #ifndef teca_saffir_simpson
2 #define teca_saffir_simpson
3 
4 /// @file
5 
6 #include <limits>
7 
8 /// Codes dealing with the Saffir-Simpson scale
10 {
11 /** Saffir-Simpson scale prescribes the following limits:
12  * CAT wind km/h
13  * -1: 0- 63 : Tropical depression
14  * 0: 63-119 : Tropical storm
15  * 1: 119-153 km/h
16  * 2: 154-177 km/h
17  * 3: 178-208 km/h
18  * 4: 209-251 km/h
19  * 5: 252 km/h or higher
20  */
21 constexpr double low_wind_bound_kmph[] = {0.0, 63.0,
22  119.0, 154.0, 178.0, 209.0, 252.0};
23 
24 /// get the high bound for the given class of storm
25 constexpr double high_wind_bound_kmph[] = {63.0,
26  119.0, 154.0, 178.0, 209.0, 252.0,
27  std::numeric_limits<double>::max()};
28 
29 /// get the lower bound for the given class of storm
30 template<typename n_t>
31 constexpr n_t get_lower_bound_kmph(int c)
32 {
33  return low_wind_bound_kmph[++c];
34 }
35 
36 /// get the higher bound for the given class of storm
37 template<typename n_t>
38 constexpr n_t get_upper_bound_kmph(int c)
39 {
40  return high_wind_bound_kmph[++c];
41 }
42 
43 /** given wind speed in km/hr return Saffir-Simpson category
44  * NOTE: there is some ambiguity in the above as
45  * it's defined using integers. we are not converting
46  * to integer here.
47  * get the low bound for the given class of storm
48  */
49 template<typename n_t>
50 int classify_kmph(n_t w)
51 {
52  if (w < n_t(high_wind_bound_kmph[0]))
53  return -1;
54  else
55  if (w < n_t(high_wind_bound_kmph[1]))
56  return 0;
57  else
58  if (w < n_t(high_wind_bound_kmph[2]))
59  return 1;
60  else
61  if (w < n_t(high_wind_bound_kmph[3]))
62  return 2;
63  else
64  if (w < n_t(high_wind_bound_kmph[4]))
65  return 3;
66  else
67  if (w < n_t(high_wind_bound_kmph[5]))
68  return 4;
69  return 5;
70 }
71 
72 /// get the low bound for the given class of storm
73 template<typename n_t>
74 constexpr n_t get_lower_bound_mps(int c)
75 {
76  return get_lower_bound_kmph<n_t>(c)/n_t(3.6);
77 }
78 
79 /// get the high bound for the given class of storm
80 template<typename n_t>
81 constexpr n_t get_upper_bound_mps(int c)
82 {
83  return get_upper_bound_kmph<n_t>(c)/n_t(3.6);
84 }
85 
86 /** given wind speed in km/hr return Saffir-Simpson category
87  * NOTE: there is some ambiguity in the above as
88  * it's defined using integers. we are not converting
89  * to integer here.
90  * get the low bound for the given class of storm
91  */
92 template<typename n_t>
93 int classify_mps(n_t w)
94 {
95  // 1 m/s -> 3.6 Km/h
96  if (w < n_t(high_wind_bound_kmph[0]/3.6))
97  return -1;
98  else
99  if (w < n_t(high_wind_bound_kmph[1]/3.6))
100  return 0;
101  else
102  if (w < n_t(high_wind_bound_kmph[2]/3.6))
103  return 1;
104  else
105  if (w < n_t(high_wind_bound_kmph[3]/3.6))
106  return 2;
107  else
108  if (w < n_t(high_wind_bound_kmph[4]/3.6))
109  return 3;
110  else
111  if (w < n_t(high_wind_bound_kmph[5]/3.6))
112  return 4;
113  return 5;
114 }
115 };
116 
117 #endif
teca_saffir_simpson::get_lower_bound_mps
constexpr n_t get_lower_bound_mps(int c)
get the low bound for the given class of storm
Definition: teca_saffir_simpson.h:74
teca_saffir_simpson::get_upper_bound_kmph
constexpr n_t get_upper_bound_kmph(int c)
get the higher bound for the given class of storm
Definition: teca_saffir_simpson.h:38
teca_saffir_simpson
Codes dealing with the Saffir-Simpson scale.
Definition: teca_saffir_simpson.h:9
teca_saffir_simpson::low_wind_bound_kmph
constexpr double low_wind_bound_kmph[]
Definition: teca_saffir_simpson.h:21
teca_saffir_simpson::high_wind_bound_kmph
constexpr double high_wind_bound_kmph[]
get the high bound for the given class of storm
Definition: teca_saffir_simpson.h:25
teca_saffir_simpson::get_upper_bound_mps
constexpr n_t get_upper_bound_mps(int c)
get the high bound for the given class of storm
Definition: teca_saffir_simpson.h:81
teca_saffir_simpson::classify_mps
int classify_mps(n_t w)
Definition: teca_saffir_simpson.h:93
teca_saffir_simpson::classify_kmph
int classify_kmph(n_t w)
Definition: teca_saffir_simpson.h:50
teca_saffir_simpson::get_lower_bound_kmph
constexpr n_t get_lower_bound_kmph(int c)
get the lower bound for the given class of storm
Definition: teca_saffir_simpson.h:31