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  * 3. the z-axis units are in Pa. Conversion from hPa is supported.
23  *
24  * These transformations are automatically applied and can be enabled or
25  * disbaled as needed. The properties enable_unit_conversions, enable_periodic_shift
26  * and enable_y_axis_ascending provide a way to enable/disable the transforms.
27  *
28  * Subset requests are not implemented when the periodic shift is enabled. When
29  * a request is made for data that crosses the periodic boundary, the request
30  * is modified to request the entire x-axis.
31  *
32  * If data point opn the periodic boundary is duplicated, the data at 180 is
33  * dropped and a warning is issued.g
34  */
36 {
37 public:
38  TECA_ALGORITHM_STATIC_NEW(teca_normalize_coordinates)
39  TECA_ALGORITHM_DELETE_COPY_ASSIGN(teca_normalize_coordinates)
40  TECA_ALGORITHM_CLASS_NAME(teca_normalize_coordinates)
42 
43  // report/initialize to/from Boost program options
44  // objects.
45  TECA_GET_ALGORITHM_PROPERTIES_DESCRIPTION()
46  TECA_SET_ALGORITHM_PROPERTIES()
47 
48  /** @name enable_periodic_shift_x
49  * If set, this enables an automatic transformation of the x-axis
50  * coordinates and data from [-180, 180] to [0, 360]. When enabled, the
51  * transformation is applied if the lowest x coordinate is less than 0 and
52  * skipped otherwise.
53  */
54  ///@{
55  TECA_ALGORITHM_PROPERTY(int, enable_periodic_shift_x)
56  ///@}
57 
58  /** @name enable_y_axis_ascending
59  * If set, this enables an automatic transformation of the y-axis
60  * coordinates and data from descending to ascending order. The
61  * transformation is applied if the lowest y coordinate is greater than the
62  * highest y coordinate skipped otherwise. Many TECA algorithms are written
63  * to process data with y-axis coordinates in ascending order, thus the
64  * transform is enabled by default. Setting this to 0 disables the
65  * transform for cases where it is desirable to pass data through
66  * unmodified.
67  */
68  ///@{
69  TECA_ALGORITHM_PROPERTY(int, enable_y_axis_ascending)
70  ///@}
71 
72  /** @name enable_unit_conversions
73  * If set, this enables an automatic conversions of units of the axes.
74  */
75  ///@{
76  TECA_ALGORITHM_PROPERTY(int, enable_unit_conversions)
77  ///@}
78 
79 protected:
81 
82 private:
83  using teca_algorithm::get_output_metadata;
84 
85  teca_metadata get_output_metadata(unsigned int port,
86  const std::vector<teca_metadata> &input_md) override;
87 
88  std::vector<teca_metadata> get_upstream_request(
89  unsigned int port, const std::vector<teca_metadata> &input_md,
90  const teca_metadata &request) override;
91 
92  const_p_teca_dataset execute(unsigned int port,
93  const std::vector<const_p_teca_dataset> &input_data,
94  const teca_metadata &request) override;
95 
96 private:
97  int enable_periodic_shift_x;
98  int enable_y_axis_ascending;
99  int enable_unit_conversions;
100 };
101 
102 #endif
The interface to TECA pipeline architecture.
Definition: teca_algorithm.h:244
A generic container for meta data in the form of name=value pairs.
Definition: teca_metadata.h:22
An algorithm to ensure that Cartesian mesh coordinates follow conventions.
Definition: teca_normalize_coordinates.h:36
p_teca_error_handler error_handler TECA_EXPORT
The global error handler instance.