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