TECA
The Toolkit for Extreme Climate Analysis
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.h"
8 
9 #include <string>
10 #include <vector>
11 
12 TECA_SHARED_OBJECT_FORWARD_DECL(teca_cartesian_mesh_subset)
13 
14 /// applies a subset given in world coordinates to the upstream request
15 /**
16  * an algorithm that applies a subset specified in
17  * world coordinates to upstream requests. the subset
18  * is specified as bounding box of the form [x_low to x_high,
19  * y_low to y_high, z_low to z_high]. The subset can be either
20  * the smallest subset containing the bounding box or the
21  * largest set contained by the bounding box, and is controled
22  * by the cover_bounds property.
23 */
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  /** @name bounds
38  * define the bounding box of the subset this algorithm converts this into
39  * an extent into the upstream dataset.
40  */
41  ///@{
42  TECA_ALGORITHM_PROPERTY(std::vector<double>, bounds)
43 
44  void set_bounds(double low_x, double high_x,
45  double low_y, double high_y, double low_z, double high_z)
46  { this->set_bounds({low_x, high_x, low_y, high_y, low_z, high_z}); }
47  ///@}
48 
49  /** @name cover_bounds
50  * control how bounds are converted. if true smallest subset covering the
51  * bounding box is used. if false the largest subset contained by the
52  * bounding box is used.
53  */
54  ///@{
55  TECA_ALGORITHM_PROPERTY(bool, cover_bounds)
56  ///@}
57 
58 protected:
60 
61 private:
62  teca_metadata get_output_metadata(
63  unsigned int port,
64  const std::vector<teca_metadata> &input_md) override;
65 
66  std::vector<teca_metadata> get_upstream_request(
67  unsigned int port,
68  const std::vector<teca_metadata> &input_md,
69  const teca_metadata &request) override;
70 
71  const_p_teca_dataset execute(
72  unsigned int port,
73  const std::vector<const_p_teca_dataset> &input_data,
74  const teca_metadata &request) override;
75 
76 private:
77  std::vector<double> bounds;
78  bool cover_bounds;
79 
80  // internals
81  std::vector<unsigned long> extent;
82 };
83 
84 #endif
teca_variant_array.h
teca_cartesian_mesh_subset
applies a subset given in world coordinates to the upstream request
Definition: teca_cartesian_mesh_subset.h:24
teca_metadata
A generic container for meta data in the form of name=value pairs.
Definition: teca_metadata.h:18
teca_shared_object.h
teca_algorithm
The interface to TECA pipeline architecture.
Definition: teca_algorithm.h:237