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