TECA
The Toolkit for Extreme Climate Analysis
teca_l2_norm.h
1 #ifndef teca_l2_norm_h
2 #define teca_l2_norm_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_l2_norm)
12 
13 /// An algorithm that computes L2 norm
15 {
16 public:
17  TECA_ALGORITHM_STATIC_NEW(teca_l2_norm)
18  TECA_ALGORITHM_DELETE_COPY_ASSIGN(teca_l2_norm)
19  TECA_ALGORITHM_CLASS_NAME(teca_l2_norm)
20  ~teca_l2_norm();
21 
22  // report/initialize to/from Boost program options
23  // objects.
24  TECA_GET_ALGORITHM_PROPERTIES_DESCRIPTION()
25  TECA_SET_ALGORITHM_PROPERTIES()
26 
27  /** @name component_0_variable
28  * Set the arrays that contain the vector components to compute the norm
29  * from.
30  */
31  ///@{
32  TECA_ALGORITHM_PROPERTY(std::string, component_0_variable)
33  ///@}
34 
35  /** @name component_1_variable
36  * Set the arrays that contain the vector components to compute the norm
37  * from.
38  */
39  ///@{
40  TECA_ALGORITHM_PROPERTY(std::string, component_1_variable)
41  ///@}
42 
43  /** @name component_2_variable
44  * Set the arrays that contain the vector components to compute the norm
45  * from.
46  */
47  ///@{
48  TECA_ALGORITHM_PROPERTY(std::string, component_2_variable)
49  ///@}
50 
51  /** @name l2_norm_variable
52  * set the name of the array to store the result in. the default is
53  * "l2_norm"
54  */
55  ///@{
56  TECA_ALGORITHM_PROPERTY(std::string, l2_norm_variable)
57  ///@}
58 
59 protected:
60  teca_l2_norm();
61 
62  // helpers to get the variable names from either the incoming
63  // request or the class member variable.
64  std::string get_component_0_variable(const teca_metadata &request);
65  std::string get_component_1_variable(const teca_metadata &request);
66  std::string get_component_2_variable(const teca_metadata &request);
67  std::string get_l2_norm_variable(const teca_metadata &request);
68 
69 private:
70  teca_metadata get_output_metadata(
71  unsigned int port,
72  const std::vector<teca_metadata> &input_md) override;
73 
74  std::vector<teca_metadata> get_upstream_request(
75  unsigned int port,
76  const std::vector<teca_metadata> &input_md,
77  const teca_metadata &request) override;
78 
79  const_p_teca_dataset execute(
80  unsigned int port,
81  const std::vector<const_p_teca_dataset> &input_data,
82  const teca_metadata &request) override;
83 
84 private:
85  std::string component_0_variable;
86  std::string component_1_variable;
87  std::string component_2_variable;
88  std::string l2_norm_variable;
89 };
90 
91 #endif
teca_metadata
A generic container for meta data in the form of name=value pairs.
Definition: teca_metadata.h:18
teca_l2_norm
An algorithm that computes L2 norm.
Definition: teca_l2_norm.h:14
teca_shared_object.h
teca_algorithm
The interface to TECA pipeline architecture.
Definition: teca_algorithm.h:237