TECA
The Toolkit for Extreme Climate Analysis
teca_normalize_coordinates.h
1 #ifndef teca_normalize_coordinates_h
2 #define teca_normalize_coordinates_h
3 
4 #include "teca_shared_object.h"
5 #include "teca_algorithm.h"
6 #include "teca_metadata.h"
7 
8 #include <string>
9 #include <vector>
10 
11 TECA_SHARED_OBJECT_FORWARD_DECL(teca_normalize_coordinates)
12 
13 /** @brief
14  * An algorithm to ensure that Cartesian mesh coordinates follow conventions
15  *
16  * @details
17  * When enabled, transformations of coordinates and data are applied such that
18  * Cartesian meshes are follow the conventions:
19  *
20  * 1. the x-axis coordinates are in the range of 0 to 360.
21  * 2. the y-axis coordinate are in ascending order.
22  *
23  * These transformations are automatically applied and can be enabled or
24  * disbaled as needed. The properties enable_periodic_shift and
25  * enable_y_axis_ascending provide a way to enable/disable the transforms.
26  *
27  * Subset requests are not implemented when the periodic shift is enabled. When
28  * a request is made for data that crosses the periodic boundary, the request
29  * is modified to request the entire x-axis.
30  *
31  * If data point opn the periodic boundary is duplicated, the data at 180 is
32  * dropped and a warning is issued.g
33  */
35 {
36 public:
37  TECA_ALGORITHM_STATIC_NEW(teca_normalize_coordinates)
38  TECA_ALGORITHM_DELETE_COPY_ASSIGN(teca_normalize_coordinates)
39  TECA_ALGORITHM_CLASS_NAME(teca_normalize_coordinates)
41 
42  // report/initialize to/from Boost program options
43  // objects.
44  TECA_GET_ALGORITHM_PROPERTIES_DESCRIPTION()
45  TECA_SET_ALGORITHM_PROPERTIES()
46 
47  /** @name enable_periodic_shift_x
48  * If set, this enables an automatic transformation of the x-axis
49  * coordinates and data from [-180, 180] to [0, 360]. When enabled, the
50  * transformation is applied if the lowest x coordinate is less than 0 and
51  * skipped otherwise.
52  */
53  ///@{
54  TECA_ALGORITHM_PROPERTY(int, enable_periodic_shift_x)
55  ///@}
56 
57  /** @name enable_y_axis_ascending
58  * If set, this enables an automatic transformation of the y-axis
59  * coordinates and data from descending to ascending order. The
60  * transformation is applied if the lowest y coordinate is greater than the
61  * highest y coordinate skipped otherwise. Many TECA algorithms are written
62  * to process data with y-axis coordinates in ascending order, thus the
63  * transform is enabled by default. Setting this to 0 disables the
64  * transform for cases where it is desirable to pass data through
65  * unmodified.
66  */
67  ///@{
68  TECA_ALGORITHM_PROPERTY(int, enable_y_axis_ascending)
69  ///@}
70 
71 protected:
73 
74 private:
75  using teca_algorithm::get_output_metadata;
76 
77  teca_metadata get_output_metadata(unsigned int port,
78  const std::vector<teca_metadata> &input_md) override;
79 
80  std::vector<teca_metadata> get_upstream_request(
81  unsigned int port, const std::vector<teca_metadata> &input_md,
82  const teca_metadata &request) override;
83 
84  const_p_teca_dataset execute(unsigned int port,
85  const std::vector<const_p_teca_dataset> &input_data,
86  const teca_metadata &request) override;
87 
88 private:
89  int enable_periodic_shift_x;
90  int enable_y_axis_ascending;
91 };
92 
93 #endif
teca_metadata
A generic container for meta data in the form of name=value pairs.
Definition: teca_metadata.h:21
teca_normalize_coordinates
An algorithm to ensure that Cartesian mesh coordinates follow conventions.
Definition: teca_normalize_coordinates.h:34
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