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