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