TECA
The Toolkit for Extreme Climate Analysis
teca_integrated_vapor_transport.h
1 #ifndef teca_integrated_vapor_transport_h
2 #define teca_integrated_vapor_transport_h
3 
4 #include "teca_config.h"
5 #include "teca_shared_object.h"
6 #include "teca_vertical_reduction.h"
7 #include "teca_metadata.h"
8 
9 #include <string>
10 #include <vector>
11 
12 TECA_SHARED_OBJECT_FORWARD_DECL(teca_integrated_vapor_transport)
13 
14 /// An algorithm that computes integrated vapor transport (IVT)
15 /**
16  * Compute integrated vapor transport (IVT) from wind vector and
17  * specific humidity.
18  *
19  * \f[
20  * \vec{IVT} = \frac{1}{g} \int_{p_{sfc}}^{p_{top}} \vec{v} \, q \; dp
21  * \f]
22  *
23  * where \f$q\f$ is the specific humidity, and \f$\vec{v} = (u, v)\f$ are the
24  * longitudinal and latitudinal components of wind.
25  *
26  * This calculation is an instance of a vertical reduction where
27  * a 3D mesh is transformed into a 2D one.
28  *
29  * This algorithm handles missing values.
30  */
32 {
33 public:
34  TECA_ALGORITHM_STATIC_NEW(teca_integrated_vapor_transport)
35  TECA_ALGORITHM_DELETE_COPY_ASSIGN(teca_integrated_vapor_transport)
36  TECA_ALGORITHM_CLASS_NAME(teca_integrated_vapor_transport)
38 
39  /** @name program_options
40  * report/initialize to/from Boost program options objects.
41  */
42  ///@{
43  TECA_GET_ALGORITHM_PROPERTIES_DESCRIPTION()
44  TECA_SET_ALGORITHM_PROPERTIES()
45  ///@}
46 
47  /** @name wind_u_variable
48  * set the name of the varaiable that contains the longitudinal component
49  * of the wind vector ("ua")
50  */
51  ///@{
52  TECA_ALGORITHM_PROPERTY(std::string, wind_u_variable)
53  ///@}
54 
55  /** @name wind_v_variable
56  * set the name of the varaiable that contains the latitudinal component of
57  * the wind vector ("va")
58  */
59  ///@{
60  TECA_ALGORITHM_PROPERTY(std::string, wind_v_variable)
61  ///@}
62 
63  /** @name specific_humidity_variable
64  * set the name of the variable that contains the specific humidity ("hus")
65  */
66  ///@{
67  TECA_ALGORITHM_PROPERTY(std::string, specific_humidity_variable)
68  ///@}
69 
70  /** @name ivt_u_variable
71  * set the name of the varaiable that contains the longitudinal component
72  * of the ivt vector ("ivt_u")
73  */
74  ///@{
75  TECA_ALGORITHM_PROPERTY(std::string, ivt_u_variable)
76  ///@}
77 
78  /** @name ivt_v_variable
79  * set the name of the varaiable that contains the latitudinal component of
80  * the ivt vector ("ivt_v")
81  */
82  ///@{
83  TECA_ALGORITHM_PROPERTY(std::string, ivt_v_variable)
84  ///@}
85 
86  /** @name fill_value
87  * set the _fillValue attribute for the output data. default 1.0e20
88  */
89  ///@{
90  TECA_ALGORITHM_PROPERTY(double, fill_value)
91  ///@}
92 
93  /** @name surface_pressure
94  * set the surface pressure, default 101235. only used when not using
95  * trapezoid integration. See set_use_trapezoid_rule.
96  */
97  ///@{
98  TECA_ALGORITHM_PROPERTY(double, surface_pressure)
99  ///@}
100 
101  /** @name top_pressure
102  * set the top pressure, default 0. only used when not using
103  * trapezoid integration. See set_use_trapezoid_rule.
104  */
105  ///@{
106  TECA_ALGORITHM_PROPERTY(double, top_pressure)
107  ///@}
108 
109  /** @name use_trapezoid_rule
110  * if set then trapezoid rule is used for integration. This is a higher
111  * order scheme than the default but the pressure level thickness is
112  * calculated between cell centers.
113  */
114  ///@{
115  TECA_ALGORITHM_PROPERTY(int, use_trapezoid_rule)
116  ///@}
117 
118 protected:
120 
121 private:
122  using teca_algorithm::get_output_metadata;
123 
124  teca_metadata get_output_metadata(
125  unsigned int port,
126  const std::vector<teca_metadata> &input_md) override;
127 
128  std::vector<teca_metadata> get_upstream_request(
129  unsigned int port,
130  const std::vector<teca_metadata> &input_md,
131  const teca_metadata &request) override;
132 
133  const_p_teca_dataset execute(
134  unsigned int port,
135  const std::vector<const_p_teca_dataset> &input_data,
136  const teca_metadata &request) override;
137 
138 private:
139  std::string wind_u_variable;
140  std::string wind_v_variable;
141  std::string specific_humidity_variable;
142  std::string ivt_u_variable;
143  std::string ivt_v_variable;
144  double fill_value;
145  double surface_pressure;
146  double top_pressure;
147  int use_trapezoid_rule;
148 };
149 
150 #endif
The interface to TECA pipeline architecture.
Definition: teca_algorithm.h:244
An algorithm that computes integrated vapor transport (IVT)
Definition: teca_integrated_vapor_transport.h:32
A generic container for meta data in the form of name=value pairs.
Definition: teca_metadata.h:22
The base class for vertical reducitons.
Definition: teca_vertical_reduction.h:21
p_teca_error_handler error_handler TECA_EXPORT
The global error handler instance.