TECA
The Toolkit for Extreme Climate Analysis
teca_table_remove_rows.h
1 #ifndef teca_table_remove_rows_h
2 #define teca_table_remove_rows_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_table_remove_rows)
13 
14 /** @brief
15  * An algorithm that removes rows from a table where
16  * a given expression evaluates to true.
17  *
18  * @details
19  * The expression parser supports the following operations:
20  * +,-,*,/,%,<.<=,>,>=,==,!=,&&,||.!,?
21  *
22  * Grouping in the expression is denoted in the usual
23  * way: ()
24  *
25  * Constants in the expression are expanded to full length
26  * arrays and can be typed. The supported types are:
27  * d,f,L,l,i,s,c
28  * Corresponding to double,float, long long, long, int,
29  * short and char respectively. Integer types can be
30  * unsigned by including u after the code.
31  */
33 {
34 public:
35  TECA_ALGORITHM_STATIC_NEW(teca_table_remove_rows)
36  TECA_ALGORITHM_DELETE_COPY_ASSIGN(teca_table_remove_rows)
37  TECA_ALGORITHM_CLASS_NAME(teca_table_remove_rows)
39 
40  // report/initialize to/from Boost program options
41  // objects.
42  TECA_GET_ALGORITHM_PROPERTIES_DESCRIPTION()
43  TECA_SET_ALGORITHM_PROPERTIES()
44 
45  /** @name mask_expression
46  * set the expression to use to determine which rows are removed. rows are
47  * removed where the expression evaluates true.
48  */
49  ///@{
50  /// Set the mask expression
51  void set_mask_expression(const std::string &expr);
52 
53  /// Get the mask expression
54  std::string get_mask_expression()
55  { return this->mask_expression; }
56  ///@}
57 
58  /** @name remove_dependent_variables
59  * when set columns used in the calculation are removed from the output.
60  * default off.
61  */
62  ///@{
63  TECA_ALGORITHM_PROPERTY(int, remove_dependent_variables)
64  ///@}
65 
66 
67 protected:
69 
70 private:
71  const_p_teca_dataset execute(unsigned int port,
72  const std::vector<const_p_teca_dataset> &input_data,
73  const teca_metadata &request) override;
74 
75 private:
76  std::string mask_expression;
77  std::string postfix_expression;
78  std::set<std::string> dependent_variables;
79  int remove_dependent_variables;
80 };
81 
82 #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 removes rows from a table where a given expression evaluates to true.
Definition: teca_table_remove_rows.h:33
p_teca_error_handler error_handler TECA_EXPORT
The global error handler instance.