TECA
The Toolkit for Extreme Climate Analysis
teca_regional_moisture_flux.h
1 #ifndef teca_regional_moisture_flux_h
2 #define teca_regional_moisture_flux_h
3 
4 #include "teca_shared_object.h"
5 #include "teca_algorithm.h"
6 #include "teca_metadata.h"
7 #include "teca_metadata.h"
8 
9 #include <string>
10 #include <vector>
11 
12 TECA_SHARED_OBJECT_FORWARD_DECL(teca_regional_moisture_flux)
13 
14 /// Computes moisture flux from IVT over a geographic region
15 /** Computes moisture flux from IVT over a geographic region.
16  *
17  * The net transport of water vapor \f$F\f$ into/out of the atmosphere above a
18  * region enclosed by the closed curve \f$C\f$ is given by:
19  *
20  * \f[
21  * F = - r_e \iint\limits_{C} \left( \frac{\partial}{\partial\phi} \left[ IVT_{\phi} \; sin \phi \right] + \frac{\partial}{\partial\theta} [ IVT_{\theta} ] \right) \; d\theta \, d\phi
22  * \f]
23  *
24  * where:
25  *
26  * \f$IVT_{\theta}\f$ : longitudinal component of the IVT vector in units of \f$kg\, m^{-1} \, s^{-1}\f$ <br>
27  * \f$IVT_{\phi}\f$ : latitudinal component of the IVT vector in units of \f$kg \, m^{-1} \, s^{-1}\f$ <br>
28  * \f$\phi\f$ : \f$(90 - \f$degrees latitude\f$) \frac{\pi}{180}\f$ radians <br>
29  * \f$\theta\f$ : \f$(\f$degrees longitude\f$) \frac{\pi}{180}\f$ radians <br>
30  * \f$C\f$ : a curve enclosing a region on the surface of the Earth <br>
31  * \f$r_e\f$ : the radius of the Earth (6378100) \f$m\f$ <br>
32  *
33  * Note: the minus sign out front is because we flip the limits of integration
34  * when going from latitude to \f$\phi\f$ coordinates.
35  *
36  * Requires:
37  * 1. IVT vector components in units of \f$kg s^{-1} m^{-1}\f$
38  * 2. A 2D mask where the non-zero entries define an arbitrary region of
39  * interest on the surface of the Earth. ::teca_shape_file_mask is an
40  * algorithm that can be used to generate such a mask from an ESRI
41  * shapefile.
42  *
43  * Produces:
44  * A table with a column for the net moisture flux over the region as well as
45  * collumns for time and time step.
46  *
47  * @attention This algorithm is not suitable for general atmospheric flux
48  * calculations due to simplifications made in the derivation that only apply
49  * when caclulating moisture flux.
50  *
51  * @attention This algorithm does not currently handle missing values.
52  *
53  */
55 {
56 public:
57  TECA_ALGORITHM_STATIC_NEW(teca_regional_moisture_flux)
58  TECA_ALGORITHM_DELETE_COPY_ASSIGN(teca_regional_moisture_flux)
59  TECA_ALGORITHM_CLASS_NAME(teca_regional_moisture_flux)
61 
62  // report/initialize to/from Boost program options
63  // objects.
64  TECA_GET_ALGORITHM_PROPERTIES_DESCRIPTION()
65  TECA_SET_ALGORITHM_PROPERTIES()
66 
67  /** @name ivt_u_variable
68  * Set the name of the variable containing the longitudinal component of
69  * IVT.
70  */
71  ///@{
72  TECA_ALGORITHM_PROPERTY(std::string, ivt_u_variable)
73  ///@}
74 
75  /** @name ivt_v_variable
76  * Set the name of the variable containing the latitudinal component of
77  * IVT.
78  */
79  ///@{
80  TECA_ALGORITHM_PROPERTY(std::string, ivt_v_variable)
81  ///@}
82 
83  /** @name region_mask_variable
84  * Set the name of the variable containing the mask defining the region of
85  * interest.
86  */
87  ///@{
88  TECA_ALGORITHM_PROPERTY(std::string, region_mask_variable)
89  ///@}
90 
91  /** @name regional_moisture_flux_variable
92  * Set the name of the array to store the result in. the default is
93  * "regional_moisture_flux"
94  */
95  ///@{
96  TECA_ALGORITHM_PROPERTY(std::string, moisture_flux_variable)
97  ///@}
98 
99 
100 protected:
102 /*
103  // helpers to get the variable names from either the incoming
104  // request or the class member variable.
105  std::string get_ivt_u_variable(const teca_metadata &request);
106  std::string get_ivt_v_variable(const teca_metadata &request);
107  std::string get_component_2_variable(const teca_metadata &request);
108  std::string get_regional_moisture_flux_variable(const teca_metadata &request);
109 */
110 private:
111  using teca_algorithm::get_output_metadata;
112 
113  teca_metadata get_output_metadata(
114  unsigned int port,
115  const std::vector<teca_metadata> &input_md) override;
116 
117  std::vector<teca_metadata> get_upstream_request(
118  unsigned int port,
119  const std::vector<teca_metadata> &input_md,
120  const teca_metadata &request) override;
121 
122  const_p_teca_dataset execute(
123  unsigned int port,
124  const std::vector<const_p_teca_dataset> &input_data,
125  const teca_metadata &request) override;
126 
127 private:
128  std::string ivt_u_variable;
129  std::string ivt_v_variable;
130  std::string region_mask_variable;
131  std::string moisture_flux_variable;
132  teca_metadata moisture_flux_attributes;
133 };
134 
135 #endif
136 
The interface to TECA pipeline architecture.
Definition: teca_algorithm.h:244
A generic container for meta data in the form of name=value pairs.
Definition: teca_metadata.h:22
Computes moisture flux from IVT over a geographic region.
Definition: teca_regional_moisture_flux.h:55
p_teca_error_handler error_handler TECA_EXPORT
The global error handler instance.