TECA
The Toolkit for Extreme Climate Analysis
teca_latitude_damper.h
1 #ifndef teca_latitude_damper_h
2 #define teca_latitude_damper_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_latitude_damper)
12 
13 /// Inverted Gaussian damper for scalar fields.
14 /**
15  * Damps the specified scalar field(s) using an inverted Gaussian centered on a
16  * given latitude with a half width specified in degrees latitude. The
17  * parameters defining the Gaussian (center, half width at half max) can be
18  * specified by the user directly or by down stream algorithm via the
19  * following keys in the request.
20  *
21  * request keys:
22  *
23  * teca_latitude_damper::damped_variables
24  * teca_latitude_damper::half_width_at_half_max
25  * teca_latitude_damper::center
26  *
27  * @note
28  * User specified values take precedence over request keys. When
29  * using request keys be sure to include the variable post-fix.
30  */
32 {
33 public:
34  TECA_ALGORITHM_STATIC_NEW(teca_latitude_damper)
35  TECA_ALGORITHM_DELETE_COPY_ASSIGN(teca_latitude_damper)
36  TECA_ALGORITHM_CLASS_NAME(teca_latitude_damper)
38 
39  // report/initialize to/from Boost program options
40  // objects.
41  TECA_GET_ALGORITHM_PROPERTIES_DESCRIPTION()
42  TECA_SET_ALGORITHM_PROPERTIES()
43 
44  // set the center of the Gaussian in units of degrees latitude.
45  // default is 0.0 deg lat
46  TECA_ALGORITHM_PROPERTY(double, center)
47 
48  // set the half width of the Gaussian in units of degrees latitude.
49  // default is 45.0 deg lat
50  TECA_ALGORITHM_PROPERTY(double, half_width_at_half_max)
51 
52  // set the names of the arrays that the filter will apply on
53  TECA_ALGORITHM_VECTOR_PROPERTY(std::string, damped_variable)
54 
55  // a string to be appended to the name of each output variable
56  // setting this to an empty string will result in the damped array
57  // replacing the input array in the output. default is an empty
58  // string ""
59  TECA_ALGORITHM_PROPERTY(std::string, variable_post_fix)
60 
61 protected:
63 
64  // helpers to get parameters defining the Gaussian used by the
65  // the filter. if the user has not specified a value then the
66  // request is probed. a return of zero indicates success
67  int get_sigma(const teca_metadata &request, double &sigma);
68  int get_mu(const teca_metadata &request, double &mu);
69 
70  // helper to get the list of variables to apply the filter on
71  // if the user provided none, then the request is probed. a
72  // return of 0 indicates success
73  int get_damped_variables(std::vector<std::string> &vars);
74 
75 private:
76  teca_metadata get_output_metadata(
77  unsigned int port,
78  const std::vector<teca_metadata> &input_md) override;
79 
80  std::vector<teca_metadata> get_upstream_request(
81  unsigned int port, const std::vector<teca_metadata> &input_md,
82  const teca_metadata &request) override;
83 
84  const_p_teca_dataset execute(unsigned int port,
85  const std::vector<const_p_teca_dataset> &input_data,
86  const teca_metadata &request) override;
87 
88 private:
89  double center;
90  double half_width_at_half_max;
91  std::vector<std::string> damped_variables;
92  std::string variable_post_fix;
93 };
94 
95 #endif
teca_metadata
A generic container for meta data in the form of name=value pairs.
Definition: teca_metadata.h:18
teca_latitude_damper
Inverted Gaussian damper for scalar fields.
Definition: teca_latitude_damper.h:31
teca_shared_object.h
teca_algorithm
The interface to TECA pipeline architecture.
Definition: teca_algorithm.h:237