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:
63 
64  teca_metadata get_output_metadata(
65  unsigned int port,
66  const std::vector<teca_metadata> &input_md) override;
67 
68  std::vector<teca_metadata> get_upstream_request(
69  unsigned int port,
70  const std::vector<teca_metadata> &input_md,
71  const teca_metadata &request) override;
72 
73  const_p_teca_dataset execute(
74  unsigned int port,
75  const std::vector<const_p_teca_dataset> &input_data,
76  const teca_metadata &request) override;
77 
78 private:
79  std::vector<double> bounds;
80  bool cover_bounds;
81 
82  // internals
83  std::vector<unsigned long> extent;
84 };
85 
86 #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:21
teca_algorithm::get_output_metadata
virtual teca_metadata get_output_metadata(unsigned int port, const std::vector< teca_metadata > &input_md)
teca_shared_object.h
teca_error::TECA_EXPORT
p_teca_error_handler error_handler TECA_EXPORT
The global error handler instance.
teca_algorithm
The interface to TECA pipeline architecture.
Definition: teca_algorithm.h:237