TECA
The Toolkit for Extreme Climate Analysis
teca_elevation_mask.h
1 #ifndef teca_elevation_mask_h
2 #define teca_elevation_mask_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_elevation_mask)
12 
13 /** @brief
14  * Generates a mask indicating where mesh points with a vertical pressure
15  * coordinate lie above the surface of the Earth. The mask is set to 1 where
16  * data is above the Earth's surface and 0 otherwise.
17  *
18  * @details
19  * Given a 3D height field containing the altitude of each point in meters
20  * above mean sea level, and a 2D height field corresponding to height in
21  * meters above mean sea level of the surface of the Earth, generate a mask
22  * that is 1 where the 3D point is on or above the surface of the Earth and 0
23  * where it is below.
24  *
25  * The name of the 3D height field is specified by the mesh_height_variable
26  * property. The name of the 2D height field conntaining elveation of the
27  * Earth's surface is specified by the surface_elevation_variable property.
28  *
29  * The 3D mesh height field must be provided on input 0, and the 2D surface
30  * height field on input 1. Use the mask_names property to name the output
31  * mask. If more than one name is provided each name will reference a pointer
32  * to the mask. Consider using names of the form X_valid in which case the
33  * output is compatible with the teca_valid_value_mask and will be treated
34  * as missing values by down stream algorithms.
35  *
36  * If the simulation does not provide the 3D height field, for simulations
37  * where the acceleration due to the Earth's gravity is assumed constant,
38  * teca_geopotential_height can generate the 3D height field.
39  *
40  * The primary use case of this algorithm is when dealing with calculations on
41  * 3D meshes with a vertical pressure coordinate and there is a need to
42  * identify and treat specially the mesh points that are below the surface of
43  * the Earth. There are a number of alternatives available depending on the
44  * data. If your data has a _FillValue where data is below the surface then
45  * use teca_valid_value_mask instead of this algorithm. If your data has
46  * surface pressure field use teca_pressure_level_mask instead of this
47  * algorithm. If your dataset has surface temperature, and mean sea level
48  * pressure fields then use teca_surface_pressure to generate the surface
49  * pressure field and use teca_pressure_level_mask instead of this algorithm.
50  */
52 {
53 public:
54  TECA_ALGORITHM_STATIC_NEW(teca_elevation_mask)
55  TECA_ALGORITHM_DELETE_COPY_ASSIGN(teca_elevation_mask)
56  TECA_ALGORITHM_CLASS_NAME(teca_elevation_mask)
58 
59  /** @name program_options
60  * report/initialize to/from Boost program options objects.
61  */
62  ///@{
63  TECA_GET_ALGORITHM_PROPERTIES_DESCRIPTION()
64  TECA_SET_ALGORITHM_PROPERTIES()
65  ///@}
66 
67  /** @name mesh_height_variable
68  * Set the name of the 3D height field
69  */
70  ///@{
71  TECA_ALGORITHM_PROPERTY(std::string, mesh_height_variable)
72  ///@}
73 
74  /** @name surface_elevation_variable
75  * Set the name of the variable containing the elevation of the Earth's
76  * surface.
77  */
78  ///@{
79  TECA_ALGORITHM_PROPERTY(std::string, surface_elevation_variable)
80  ///@}
81 
82  /** @name mask_variables
83  * set the names of the variables to store the generated mask in
84  * each variable will contain a reference to the mask
85  */
86  ///@{
87  TECA_ALGORITHM_VECTOR_PROPERTY(std::string, mask_variable)
88  ///@}
89 
90 protected:
92 
93 private:
94  teca_metadata get_output_metadata(
95  unsigned int port,
96  const std::vector<teca_metadata> &input_md) override;
97 
98  std::vector<teca_metadata> get_upstream_request(
99  unsigned int port,
100  const std::vector<teca_metadata> &input_md,
101  const teca_metadata &request) override;
102 
103  const_p_teca_dataset execute(
104  unsigned int port,
105  const std::vector<const_p_teca_dataset> &input_data,
106  const teca_metadata &request) override;
107 
108 private:
109  std::string mesh_height_variable;
110  std::string surface_elevation_variable;
111  std::vector<std::string> mask_variables;
112  struct internals_t;
113 };
114 
115 #endif
teca_metadata
A generic container for meta data in the form of name=value pairs.
Definition: teca_metadata.h:18
teca_elevation_mask
Generates a mask indicating where mesh points with a vertical pressure coordinate lie above the surfa...
Definition: teca_elevation_mask.h:51
teca_shared_object.h
teca_algorithm
The interface to TECA pipeline architecture.
Definition: teca_algorithm.h:237