TECA
The Toolkit for Extreme Climate Analysis
teca_cartesian_mesh_coordinate_transform.h
1 #ifndef teca_cartesian_mesh_coordinate_transform_h
2 #define teca_cartesian_mesh_coordinate_transform_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_coordinate_transform)
13 
14 /** @breif Transforms the coordinate axes of a stretched Cartesian mesh without
15  * modifying the fields on the mesh.
16  *
17  * @details
18  * Transform the spatial coorindate axes of an input dataset such that a given
19  * target bounding box is covered by the output mesh. The relative spacing of
20  * the input coordinates are maintained. The target bounding box must be
21  * provided as a 6-tuple in the form [x0, x1, y0, y1, z0, z1] where 3
22  * consecutive 2-tuples define the bounds in each coordinate direction. If any
23  * of the 2-tuples are set such that the low bound is greater than the high
24  * bound the transform is skipped in that direction and existing coordinate
25  * axis array is passed through. The transform only modifies the coodinate
26  * axis arrays, not the fields defined on the mesh. The coordinate axes may
27  * optionally be renamed and new units provided.
28  */
30 {
31 public:
32  TECA_ALGORITHM_STATIC_NEW(teca_cartesian_mesh_coordinate_transform)
33  TECA_ALGORITHM_DELETE_COPY_ASSIGN(teca_cartesian_mesh_coordinate_transform)
34  TECA_ALGORITHM_CLASS_NAME(teca_cartesian_mesh_coordinate_transform)
36 
37  // report/initialize to/from Boost program options
38  // objects.
39  TECA_GET_ALGORITHM_PROPERTIES_DESCRIPTION()
40  TECA_SET_ALGORITHM_PROPERTIES()
41 
42  /** @name target_bounds
43  * 6 double precision values that define the output coordinate axis
44  * bounds, specified in the following order : [x0 x1 y0 y1 z0 z1].
45  * The Cartesian mesh is transformed such that its coordinatres span
46  * the specified target bounds while maintaining relative spacing of
47  * original input coordinate points. Pass [1, 0] for each axis that
48  * should not be transformed.
49  */
50  ///@{
51  TECA_ALGORITHM_VECTOR_PROPERTY(double, target_bound)
52 
53  /** set the target bounds from a metadata object following conventions
54  * defined by the teca_cf_reader. returns 0 if sccessful or nonzero if
55  * the metadata object is missing the requisite keys.
56  */
57  int set_target_bounds(const teca_metadata &md);
58  ///@}
59 
60  /** @name x_axis_variable
61  * Set the name of the variable to use for the x coordinate axis. When set
62  * to an empty string (the default) the existing name is passed through.
63  */
64  ///@{
65  TECA_ALGORITHM_PROPERTY(std::string, x_axis_variable)
66  ///@}
67 
68  /** @name y_axis_variable
69  * Set the name of the variable to use for the y coordinate axis. When set
70  * to an empty string (the default) the existing name is passed through.
71  * Set the name of the variable to use for the y coordinate axis. An empty
72  * string disables the renaming of this dimension passing through the
73  * original name.
74  */
75  ///@{
76  TECA_ALGORITHM_PROPERTY(std::string, y_axis_variable)
77  ///@}
78  /** @name z_axis_variable
79  * Set the name of the variable to use for the z coordinate axis. When set
80  * to an empty string (the default) the existing name is passed through.
81  */
82  ///@{
83  TECA_ALGORITHM_PROPERTY(std::string, z_axis_variable)
84  ///@}
85 
86  /** @name x_axis_units
87  * Set the units for the x coordinate axis. When set to an empty string
88  * (the default) existing uints if any are passed through unmodified.
89  */
90  ///@{
91  TECA_ALGORITHM_PROPERTY(std::string, x_axis_units)
92  ///@}
93 
94  /** @name y_axis_units
95  * Set the units for the y coordinate axis. When set to an empty string
96  * (the default) existing uints if any are passed through unmodified.
97  */
98  ///@{
99  TECA_ALGORITHM_PROPERTY(std::string, y_axis_units)
100  ///@}
101 
102  /** @name z_axis_units
103  * Set the units for the z coordinate axis. When set to an empty string
104  * (the default) existing uints if any are passed through unmodified.
105  */
106  ///@{
107  TECA_ALGORITHM_PROPERTY(std::string, z_axis_units)
108  ///@}
109 
110 protected:
112 
113  void set_modified() override;
114 
115 private:
116  using teca_algorithm::get_output_metadata;
117 
118  teca_metadata get_output_metadata(
119  unsigned int port,
120  const std::vector<teca_metadata> &input_md) override;
121 
122  std::vector<teca_metadata> get_upstream_request(
123  unsigned int port,
124  const std::vector<teca_metadata> &input_md,
125  const teca_metadata &request) override;
126 
127  const_p_teca_dataset execute(
128  unsigned int port,
129  const std::vector<const_p_teca_dataset> &input_data,
130  const teca_metadata &request) override;
131 
132 private:
133  std::vector<double> target_bounds;
134  std::string x_axis_variable;
135  std::string y_axis_variable;
136  std::string z_axis_variable;
137  std::string x_axis_units;
138  std::string y_axis_units;
139  std::string z_axis_units;
140 
141  struct internals_t;
142  internals_t *internals;
143 };
144 
145 #endif
teca_variant_array.h
teca_metadata
A generic container for meta data in the form of name=value pairs.
Definition: teca_metadata.h:21
teca_cartesian_mesh_coordinate_transform
Definition: teca_cartesian_mesh_coordinate_transform.h:29
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