TECA
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 
18 {
19 public:
20  TECA_ALGORITHM_STATIC_NEW(teca_l2_norm)
21  TECA_ALGORITHM_DELETE_COPY_ASSIGN(teca_l2_norm)
22  TECA_ALGORITHM_CLASS_NAME(teca_l2_norm)
23  ~teca_l2_norm();
24 
25  // report/initialize to/from Boost program options
26  // objects.
27  TECA_GET_ALGORITHM_PROPERTIES_DESCRIPTION()
28  TECA_SET_ALGORITHM_PROPERTIES()
29 
30  // set the arrays that contain the vector components
31  // to compute norm from
32  TECA_ALGORITHM_PROPERTY(std::string, component_0_variable)
33  TECA_ALGORITHM_PROPERTY(std::string, component_1_variable)
34  TECA_ALGORITHM_PROPERTY(std::string, component_2_variable)
35 
36  // set the name of the array to store the result in.
37  // the default is "l2_norm"
38  TECA_ALGORITHM_PROPERTY(std::string, l2_norm_variable)
39 
40 protected:
41  teca_l2_norm();
42 
43  std::string get_component_0_variable(const teca_metadata &request);
44  std::string get_component_1_variable(const teca_metadata &request);
45  std::string get_component_2_variable(const teca_metadata &request);
46  std::string get_l2_norm_variable(const teca_metadata &request);
47 
48 private:
49  teca_metadata get_output_metadata(
50  unsigned int port,
51  const std::vector<teca_metadata> &input_md) override;
52 
53  std::vector<teca_metadata> get_upstream_request(
54  unsigned int port,
55  const std::vector<teca_metadata> &input_md,
56  const teca_metadata &request) override;
57 
58  const_p_teca_dataset execute(
59  unsigned int port,
60  const std::vector<const_p_teca_dataset> &input_data,
61  const teca_metadata &request) override;
62 
63 private:
64  std::string component_0_variable;
65  std::string component_1_variable;
66  std::string component_2_variable;
67  std::string l2_norm_variable;
68 };
69 
70 #endif
teca_metadata
Definition: teca_metadata.h:17
teca_l2_norm
an algorithm that computes L2 norm
Definition: teca_l2_norm.h:18
teca_algorithm
Definition: teca_algorithm.h:25