TECA
The Toolkit for Extreme Climate Analysis
teca_cartesian_mesh_regrid.h
1 #ifndef teca_cartesian_mesh_regrid_h
2 #define teca_cartesian_mesh_regrid_h
3 
4 #include "teca_config.h"
5 #include "teca_shared_object.h"
6 #include "teca_algorithm.h"
7 #include "teca_metadata.h"
8 #include "teca_variant_array.h"
9 
10 #include <string>
11 #include <vector>
12 
13 TECA_SHARED_OBJECT_FORWARD_DECL(teca_cartesian_mesh_regrid)
14 
15 /** @brief
16  * Transfers data between spatially overlapping meshes of potentially different
17  * resolutions.
18  *
19  * @details
20  * an algorithm that transfers data between cartesian meshes defined in the
21  * same world coordinate system but potentially different resolutions. nearest
22  * or linear interpolation are supported.
23  *
24  * By default the first input is the target mesh. the second input is the
25  * source mesh. This can be changed by setting the target_input property.
26  *
27  * the arrays to move from source to target can be selected using add_array api
28  * or in the request key "arrays". this is a spatial regriding operation for
29  * temporal regriding see teca_mesh_temporal_regrid.
30  */
32 {
33 public:
34  TECA_ALGORITHM_STATIC_NEW(teca_cartesian_mesh_regrid)
35  TECA_ALGORITHM_DELETE_COPY_ASSIGN(teca_cartesian_mesh_regrid)
36  TECA_ALGORITHM_CLASS_NAME(teca_cartesian_mesh_regrid)
38 
39  // report/initialize to/from Boost program options
40  // objects.
41  TECA_GET_ALGORITHM_PROPERTIES_DESCRIPTION()
42  TECA_SET_ALGORITHM_PROPERTIES()
43 
44  /** @name array
45  * set the list of arrays to move from the source to the target
46  */
47  //@{
48  TECA_ALGORITHM_VECTOR_PROPERTY(std::string, array)
49  //@}
50 
51  /** @name target_input
52  * set the input connection which provides the output geometry.
53  */
54  ///@{
55  TECA_ALGORITHM_PROPERTY(int, target_input)
56  ///@}
57 
58  /** @name interpolation_mode
59  * set the interpolation mode used in transfering data between meshes of
60  * differing resolution. in nearest mode value at the nearest grid point
61  * is used, in linear mode bi/tri linear interpolation is used.
62  */
63  //@{
64  enum {nearest=0, linear=1};
65  TECA_ALGORITHM_PROPERTY(int, interpolation_mode)
66  void set_interpolation_mode_nearest(){ interpolation_mode = nearest; }
67  void set_interpolation_mode_linear(){ interpolation_mode = linear; }
68  //@}
69 
70 
71 
72 protected:
74 
75 private:
77 
78  teca_metadata get_output_metadata(unsigned int port,
79  const std::vector<teca_metadata> &input_md) override;
80 
81  std::vector<teca_metadata> get_upstream_request(
82  unsigned int port, const std::vector<teca_metadata> &input_md,
83  const teca_metadata &request) override;
84 
85  const_p_teca_dataset execute(unsigned int port,
86  const std::vector<const_p_teca_dataset> &input_data,
87  const teca_metadata &request) override;
88 
89 private:
90  std::vector<std::string> arrays;
91  int target_input;
92  int interpolation_mode;
93 };
94 
95 #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_algorithm::get_output_metadata
virtual teca_metadata get_output_metadata(unsigned int port, const std::vector< teca_metadata > &input_md)
teca_cartesian_mesh_regrid
Transfers data between spatially overlapping meshes of potentially different resolutions.
Definition: teca_cartesian_mesh_regrid.h:31
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