TECA
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 
21 {
22 public:
23  TECA_ALGORITHM_STATIC_NEW(teca_table_region_mask)
24  TECA_ALGORITHM_DELETE_COPY_ASSIGN(teca_table_region_mask)
25  TECA_ALGORITHM_CLASS_NAME(teca_table_region_mask)
27 
28  // report/initialize to/from Boost program options
29  // objects.
30  TECA_GET_ALGORITHM_PROPERTIES_DESCRIPTION()
31  TECA_SET_ALGORITHM_PROPERTIES()
32 
33  // set the name of the columns to use as coordinates
34  // defaults are empty which disables space based filtering
35  TECA_ALGORITHM_PROPERTY(std::string, x_coordinate_column)
36  TECA_ALGORITHM_PROPERTY(std::string, y_coordinate_column)
37 
38  // set the name of the column to store the mask in
39  // the mask is a column of 1 and 0 indicating if the
40  // row satsifies the criteria or not. the default is
41  // "region_mask"
42  TECA_ALGORITHM_PROPERTY(std::string, result_column);
43 
44  // the following group of properties define a set of
45  // polygons describing arbitrary regions. events are removed
46  // when outside of the regions. note: must explicitly include
47  // end point.
48  TECA_ALGORITHM_VECTOR_PROPERTY(unsigned long, region_size)
49  TECA_ALGORITHM_VECTOR_PROPERTY(unsigned long, region_start)
50  TECA_ALGORITHM_VECTOR_PROPERTY(double, region_x_coordinate)
51  TECA_ALGORITHM_VECTOR_PROPERTY(double, region_y_coordinate)
52 
53  // clear the list of region definitions.
54  void clear_regions();
55 
56  // load a predefined basin region by name. one can use
57  // teca_geography::get_cyclone_basin_names to obtain
58  // the list of basin names. the basin region definition
59  // is appended to the current list of regions.
60  int load_cyclone_basin(const std::string &name);
61 
62  // invert the test. when true the result will be true
63  // if the point is outside the regions
64  TECA_ALGORITHM_PROPERTY(int, invert)
65 
66 protected:
68 
69 private:
70  const_p_teca_dataset execute(unsigned int port,
71  const std::vector<const_p_teca_dataset> &input_data,
72  const teca_metadata &request) override;
73 
74 private:
75  std::string x_coordinate_column;
76  std::string y_coordinate_column;
77  std::string result_column;
78  std::vector<unsigned long> region_sizes;
79  std::vector<unsigned long> region_starts;
80  std::vector<double> region_x_coordinates;
81  std::vector<double> region_y_coordinates;
82  int invert;
83 };
84 
85 #endif
teca_metadata
Definition: teca_metadata.h:17
teca_table_region_mask
Definition: teca_table_region_mask.h:21
teca_algorithm
Definition: teca_algorithm.h:25