TECA
teca_cartesian_mesh_subset.h
1 #ifndef teca_cartesian_mesh_subset_h
2 #define teca_cartesian_mesh_subset_h
3 
4 #include "teca_shared_object.h"
5 #include "teca_algorithm.h"
6 #include "teca_metadata.h"
7 #include "teca_variant_array_fwd.h"
8 
9 #include <string>
10 #include <vector>
11 
12 TECA_SHARED_OBJECT_FORWARD_DECL(teca_cartesian_mesh_subset)
13 
14 
25 {
26 public:
27  TECA_ALGORITHM_STATIC_NEW(teca_cartesian_mesh_subset)
28  TECA_ALGORITHM_DELETE_COPY_ASSIGN(teca_cartesian_mesh_subset)
29  TECA_ALGORITHM_CLASS_NAME(teca_cartesian_mesh_subset)
31 
32  // report/initialize to/from Boost program options
33  // objects.
34  TECA_GET_ALGORITHM_PROPERTIES_DESCRIPTION()
35  TECA_SET_ALGORITHM_PROPERTIES()
36 
37  // define the bounding box of the subset
38  // this algorithm converts this into an
39  // extent into the upstream dataset.
40  TECA_ALGORITHM_PROPERTY(std::vector<double>, bounds);
41 
42  void set_bounds(double low_x, double high_x,
43  double low_y, double high_y, double low_z, double high_z)
44  { this->set_bounds({low_x, high_x, low_y, high_y, low_z, high_z}); }
45 
46  // control how bounds are converted. if true
47  // smallest subset covering the bounding box is
48  // used. if false the largest subset contained
49  // by the bounding box is used.
50  TECA_ALGORITHM_PROPERTY(bool, cover_bounds)
51 
52 protected:
54 
55 private:
56  teca_metadata get_output_metadata(
57  unsigned int port,
58  const std::vector<teca_metadata> &input_md) override;
59 
60  std::vector<teca_metadata> get_upstream_request(
61  unsigned int port,
62  const std::vector<teca_metadata> &input_md,
63  const teca_metadata &request) override;
64 
65  const_p_teca_dataset execute(
66  unsigned int port,
67  const std::vector<const_p_teca_dataset> &input_data,
68  const teca_metadata &request) override;
69 
70 private:
71  std::vector<double> bounds;
72  bool cover_bounds;
73 
74  // internals
75  std::vector<unsigned long> extent;
76 };
77 
78 #endif
teca_cartesian_mesh_subset
applies a subset given in world coordinates to the upstream request
Definition: teca_cartesian_mesh_subset.h:25
teca_metadata
Definition: teca_metadata.h:17
teca_algorithm
Definition: teca_algorithm.h:25