TECA
The Toolkit for Extreme Climate Analysis
teca_table_region_mask.h
1 #ifndef teca_table_region_mask_h
2 #define teca_table_region_mask_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_table_region_mask)
12 
13 /** @brief
14  * An algorithm that identifies rows in the table that are
15  * inside the list of regions provided.
16  *
17  * @details
18  * A new column, called the mask column is created.
19  * It has 1's if the row is in the set of regions,
20  * otherwise 0's. The invert property
21  * can be used to invert the result.
22  */
24 {
25 public:
26  TECA_ALGORITHM_STATIC_NEW(teca_table_region_mask)
27  TECA_ALGORITHM_DELETE_COPY_ASSIGN(teca_table_region_mask)
28  TECA_ALGORITHM_CLASS_NAME(teca_table_region_mask)
30 
31  // report/initialize to/from Boost program options
32  // objects.
33  TECA_GET_ALGORITHM_PROPERTIES_DESCRIPTION()
34  TECA_SET_ALGORITHM_PROPERTIES()
35 
36  // set the name of the columns to use as coordinates
37  // defaults are empty which disables space based filtering
38  TECA_ALGORITHM_PROPERTY(std::string, x_coordinate_column)
39  TECA_ALGORITHM_PROPERTY(std::string, y_coordinate_column)
40 
41  // set the name of the column to store the mask in
42  // the mask is a column of 1 and 0 indicating if the
43  // row satisfies the criteria or not. the default is
44  // "region_mask"
45  TECA_ALGORITHM_PROPERTY(std::string, result_column);
46 
47  // the following group of properties define a set of
48  // polygons describing arbitrary regions. events are removed
49  // when outside of the regions. note: must explicitly include
50  // end point.
51  TECA_ALGORITHM_VECTOR_PROPERTY(unsigned long, region_size)
52  TECA_ALGORITHM_VECTOR_PROPERTY(unsigned long, region_start)
53  TECA_ALGORITHM_VECTOR_PROPERTY(double, region_x_coordinate)
54  TECA_ALGORITHM_VECTOR_PROPERTY(double, region_y_coordinate)
55 
56  // clear the list of region definitions.
57  void clear_regions();
58 
59  // load a predefined basin region by name. one can use
60  // teca_geography::get_cyclone_basin_names to obtain
61  // the list of basin names. the basin region definition
62  // is appended to the current list of regions.
63  int load_cyclone_basin(const std::string &name);
64 
65  // invert the test. when true the result will be true
66  // if the point is outside the regions
67  TECA_ALGORITHM_PROPERTY(int, invert)
68 
69 protected:
71 
72 private:
73  const_p_teca_dataset execute(unsigned int port,
74  const std::vector<const_p_teca_dataset> &input_data,
75  const teca_metadata &request) override;
76 
77 private:
78  std::string x_coordinate_column;
79  std::string y_coordinate_column;
80  std::string result_column;
81  std::vector<unsigned long> region_sizes;
82  std::vector<unsigned long> region_starts;
83  std::vector<double> region_x_coordinates;
84  std::vector<double> region_y_coordinates;
85  int invert;
86 };
87 
88 #endif
teca_metadata
A generic container for meta data in the form of name=value pairs.
Definition: teca_metadata.h:18
teca_table_region_mask
An algorithm that identifies rows in the table that are inside the list of regions provided.
Definition: teca_table_region_mask.h:23
teca_shared_object.h
teca_algorithm
The interface to TECA pipeline architecture.
Definition: teca_algorithm.h:237