TECA
The Toolkit for Extreme Climate Analysis
teca_tc_wind_radii.h
1 #ifndef teca_tc_wind_radii_h
2 #define teca_tc_wind_radii_h
3 
4 #include "teca_shared_object.h"
5 #include "teca_algorithm.h"
6 #include "teca_metadata.h"
7 
8 #include <string>
9 #include <vector>
10 
11 TECA_SHARED_OBJECT_FORWARD_DECL(teca_tc_wind_radii)
12 
13 /// computes wind radius at the specified coordinates
14 /**
15  * Compute storm size and adds it to the table. There are two inputs, the first
16  * serves up tables of storms to compute the storm radius for. One must set the
17  * names of the columns that contain storm ids, x-coordnates, y-coordinates,
18  * and time coordinate. For each event the wind radius is computed.
19  * Computations are parallelized over storm id. The second input serves up wind
20  * velocity data most likely this will be from a NetCDF CF2 simulation dataset.
21  * By default radius is computed at the transitions on the Saffir-Simpson
22  * scale.
23 */
25 {
26 public:
27  TECA_ALGORITHM_STATIC_NEW(teca_tc_wind_radii)
28  TECA_ALGORITHM_DELETE_COPY_ASSIGN(teca_tc_wind_radii)
29  TECA_ALGORITHM_CLASS_NAME(teca_tc_wind_radii)
31 
32  // report/initialize to/from Boost program options
33  // objects.
34  TECA_GET_ALGORITHM_PROPERTIES_DESCRIPTION()
35  TECA_SET_ALGORITHM_PROPERTIES()
36 
37  /** @name storm_id_column
38  * set the name of the column that defines the track ids if set the
39  * specified column is coppied into the output metadata and accessed with
40  * the key event_id
41  */
42  ///@{
43  TECA_ALGORITHM_PROPERTY(std::string, storm_id_column)
44  ///@}
45 
46  /** @name storm_x_coordinate_column
47  * set the name of the columns that define the event position if set the
48  * columns are coppied into the output metadata and accessed with the keys
49  * storm_x_coordinate, storm_y_coordinate
50  */
51  ///@{
52  TECA_ALGORITHM_PROPERTY(std::string, storm_x_coordinate_column)
53  ///@}
54 
55  /** @name storm_y_coordinate_column
56  * set the name of the columns that define the event position if set the
57  * columns are coppied into the output metadata and accessed with the keys
58  * storm_x_coordinate, storm_y_coordinate
59  */
60  ///@{
61  TECA_ALGORITHM_PROPERTY(std::string, storm_y_coordinate_column)
62  ///@}
63 
64  /** @name storm_wind_speed_column
65  * set the name of the column containing peak instantanious surface wind
66  * speed
67  */
68  ///@{
69  TECA_ALGORITHM_PROPERTY(std::string, storm_wind_speed_column)
70  ///@}
71 
72  /** @name storm_time_column
73  * set the name of the column that defines the event time if set the
74  * specified column is coppied into the output metadata and accessed with
75  * the key event_time
76  */
77  ///@{
78  TECA_ALGORITHM_PROPERTY(std::string, storm_time_column)
79  ///@}
80 
81  // set the name of the wind variable components
82  /** @name wind_u_variable
83  */
84  ///@{
85  TECA_ALGORITHM_PROPERTY(std::string, wind_u_variable)
86  ///@}
87 
88  /** @name wind_v_variable
89  */
90  ///@{
91  TECA_ALGORITHM_PROPERTY(std::string, wind_v_variable)
92  ///@}
93 
94  /** @name search_radius
95  * set the radius in degrees of latitude to sample the wind field
96  */
97  ///@{
98  TECA_ALGORITHM_PROPERTY(double, search_radius)
99  ///@}
100 
101  /** @name core_radius
102  * set the radius in degrees of latitude beyond which to terminate the
103  * search for peak wind speed. if the peak lies beyond this distance search
104  * is terminated and a warning is displayed.
105  */
106  ///@{
107  TECA_ALGORITHM_PROPERTY(double, core_radius)
108  ///@}
109 
110  /** @name number_of_radial_bins
111  * number of bins to discetize by in the radial direction
112  */
113  ///@{
114  TECA_ALGORITHM_PROPERTY(int, number_of_radial_bins)
115  ///@}
116 
117  /** @name critical_wind_speed
118  * set the wind speeds (in m/s) to find the radius of. the defualt values
119  * are the transition speeds of the Saffir-Simpson scale.
120  */
121  ///@{
122  TECA_ALGORITHM_VECTOR_PROPERTY(double, critical_wind_speed)
123  ///@}
124 
125  /** @name profile_type
126  * Set the profile type. PROFILE_MAX uses the maximum wind speed on each
127  * interval of the discretization, while PROFILE_AVERAGE uses the average
128  * on each interval
129  */
130  ///@{
131  /// Profile types
132  enum {PROFILE_MAX = 0, PROFILE_AVERAGE = 1};
133 
134  TECA_ALGORITHM_PROPERTY(int, profile_type)
135  ///@}
136 
137  /** override the input connections because we are going to take the first
138  * input and use it to generate metadata. the second input then becomes
139  * the only one the pipeline knows about.
140  */
141  void set_input_connection(unsigned int id,
142  const teca_algorithm_output_port &port) override;
143 
144 protected:
146 
147 private:
148  teca_metadata get_output_metadata(unsigned int port,
149  const std::vector<teca_metadata> &input_md) override;
150 
151  std::vector<teca_metadata> get_upstream_request(
152  unsigned int port, const std::vector<teca_metadata> &input_md,
153  const teca_metadata &request) override;
154 
155  const_p_teca_dataset execute(unsigned int port,
156  const std::vector<const_p_teca_dataset> &input_data,
157  const teca_metadata &request) override;
158 
159  void set_modified() override;
160 
161 private:
162  // for the metadata input
163  std::string storm_id_column;
164  std::string storm_x_coordinate_column;
165  std::string storm_y_coordinate_column;
166  std::string storm_wind_speed_column;
167  std::string storm_time_column;
168 
169  // for netcdf cf data input
170  std::string wind_u_variable;
171  std::string wind_v_variable;
172 
173  std::vector<double> critical_wind_speeds;
174  double search_radius;
175  double core_radius;
176  int number_of_radial_bins;
177  int profile_type;
178 
179  class internals_t;
180  internals_t *internals;
181 };
182 
183 #endif
teca_metadata
A generic container for meta data in the form of name=value pairs.
Definition: teca_metadata.h:18
teca_shared_object.h
teca_tc_wind_radii
computes wind radius at the specified coordinates
Definition: teca_tc_wind_radii.h:24
teca_algorithm
The interface to TECA pipeline architecture.
Definition: teca_algorithm.h:237