TECA
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 
29 {
30 public:
31  TECA_ALGORITHM_STATIC_NEW(teca_latitude_damper)
32  TECA_ALGORITHM_DELETE_COPY_ASSIGN(teca_latitude_damper)
33  TECA_ALGORITHM_CLASS_NAME(teca_latitude_damper)
35 
36  // report/initialize to/from Boost program options
37  // objects.
38  TECA_GET_ALGORITHM_PROPERTIES_DESCRIPTION()
39  TECA_SET_ALGORITHM_PROPERTIES()
40 
41  // set the center of the Gaussian in units of degress latitude.
42  // default is 0.0 deg lat
43  TECA_ALGORITHM_PROPERTY(double, center)
44 
45  // set the half width of the Gaussian in units of degrees latitude.
46  // default is 45.0 deg lat
47  TECA_ALGORITHM_PROPERTY(double, half_width_at_half_max)
48 
49  // set the names of the arrays that the filter will apply on
50  TECA_ALGORITHM_VECTOR_PROPERTY(std::string, damped_variable)
51 
52  // a string to be appended to the name of each output variable
53  // setting this to an empty string will result in the damped array
54  // replacing the input array in the output. default is an empty
55  // string ""
56  TECA_ALGORITHM_PROPERTY(std::string, variable_post_fix)
57 
58 protected:
60 
61  // helpers to get parameters defining the Gaussian used by the
62  // the filter. if the user has not specified a value then the
63  // request is probed. a return of zero indicates success
64  int get_sigma(const teca_metadata &request, double &sigma);
65  int get_mu(const teca_metadata &request, double &mu);
66 
67  // helper to get the list of variables to apply the filter on
68  // if the user provided none, then the request is probed. a
69  // return of 0 indicates success
70  int get_damped_variables(std::vector<std::string> &vars);
71 
72 private:
73  teca_metadata get_output_metadata(
74  unsigned int port,
75  const std::vector<teca_metadata> &input_md) override;
76 
77  std::vector<teca_metadata> get_upstream_request(
78  unsigned int port, const std::vector<teca_metadata> &input_md,
79  const teca_metadata &request) override;
80 
81  const_p_teca_dataset execute(unsigned int port,
82  const std::vector<const_p_teca_dataset> &input_data,
83  const teca_metadata &request) override;
84 
85 private:
86  double center;
87  double half_width_at_half_max;
88  std::vector<std::string> damped_variables;
89  std::string variable_post_fix;
90 };
91 
92 #endif
teca_metadata
Definition: teca_metadata.h:17
teca_latitude_damper
Definition: teca_latitude_damper.h:29
teca_algorithm
Definition: teca_algorithm.h:25