TECA
The Toolkit for Extreme Climate Analysis
teca_rename_variables.h
1 #ifndef teca_rename_variables_h
2 #define teca_rename_variables_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_rename_variables)
12 
13 /// An algorithm that renames variables.
15 {
16 public:
17  TECA_ALGORITHM_STATIC_NEW(teca_rename_variables)
18  TECA_ALGORITHM_DELETE_COPY_ASSIGN(teca_rename_variables)
19  TECA_ALGORITHM_CLASS_NAME(teca_rename_variables)
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 original_variable_names
28  * Set the list of variables to rename. For each variable to rename a new
29  * name must be specified at the same index in the new_variable_names
30  * list. The two lists must be the same length.
31  */
32  ///@{
33  TECA_ALGORITHM_VECTOR_PROPERTY(std::string, original_variable_name)
34  ///@}
35 
36  /** @name new_variable_names
37  * Set the names of the renamed variables. The new names are applied to the
38  * list of variables to rename in the same order and the two lists must be
39  * the same length.
40  */
41  ///@{
42  TECA_ALGORITHM_VECTOR_PROPERTY(std::string, new_variable_name)
43  ///@}
44 
45 protected:
47 
48 private:
49  using teca_algorithm::get_output_metadata;
50 
51  teca_metadata get_output_metadata(
52  unsigned int port,
53  const std::vector<teca_metadata> &input_md) override;
54 
55  std::vector<teca_metadata> get_upstream_request(
56  unsigned int port,
57  const std::vector<teca_metadata> &input_md,
58  const teca_metadata &request) override;
59 
60  const_p_teca_dataset execute(
61  unsigned int port,
62  const std::vector<const_p_teca_dataset> &input_data,
63  const teca_metadata &request) override;
64 
65 private:
66  std::vector<std::string> original_variable_names;
67  std::vector<std::string> new_variable_names;
68 };
69 
70 #endif
The interface to TECA pipeline architecture.
Definition: teca_algorithm.h:244
A generic container for meta data in the form of name=value pairs.
Definition: teca_metadata.h:22
An algorithm that renames variables.
Definition: teca_rename_variables.h:15
p_teca_error_handler error_handler TECA_EXPORT
The global error handler instance.