TECA
The Toolkit for Extreme Climate Analysis
teca_bayesian_ar_detect.h
1 #ifndef teca_bayesian_ar_detect_h
2 #define teca_bayesian_ar_detect_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_bayesian_ar_detect)
12 
13 /// The TECA BARD atmospheric river detector.
14 /**
15  * Given a point wise IVT (integrated vapor transport) field and a training
16  * parameter table computes the point wise probability of an atmospheric river
17  * using the TECA BARD algorithm.
18  *
19  * Required inputs:
20  *
21  * 1. IVT (integrated vapor transport) array on a Cartesian nesh.
22  * 2. a compatible parameter table. columns of which are : min IVT,
23  * component area, HWHM lattitude
24  *
25  * The names of the input varibale and columns can be specified at run time
26  * through algorithm properties.
27  *
28  * Produces:
29  *
30  * A Cartesian mesh with probability of an AR stored in the point centered
31  * array named "ar_probability". The diagnostic quantites "ar_count" amd
32  * "parameter_table_row" are stored in information arrays.
33  *
34  * For more information see:
35  *
36  * O’Brien, T. A., Risser, M. D., Loring, B., Elbashandy, A. A., Krishnan, H.,
37  * Johnson, J., Patricola, C. M., O’Brien, J. P., Mahesh, A., Arriaga Ramirez,
38  * S., Rhoades, A. M., Charn, A., Inda Díaz, H., & Collins, W. D. (2020).
39  * Detection of atmospheric rivers with inline uncertainty quantification:
40  * TECA-BARD v1.0.1. Geoscientific Model Development, 13(12), 6131–6148.
41  * https://doi.org/10.5194/gmd-13-6131-2020
42 */
44 {
45 public:
46  TECA_ALGORITHM_STATIC_NEW(teca_bayesian_ar_detect)
47  TECA_ALGORITHM_DELETE_COPY_ASSIGN(teca_bayesian_ar_detect)
48  TECA_ALGORITHM_CLASS_NAME(teca_bayesian_ar_detect)
50 
51  // report/initialize to/from Boost program options
52  // objects.
53  TECA_GET_ALGORITHM_PROPERTIES_DESCRIPTION()
54  TECA_SET_ALGORITHM_PROPERTIES()
55 
56  /** @name ivt_variable
57  * Sets the name of the array containing the IVT field to detect ARs in.
58  */
59  ///@{
60  TECA_ALGORITHM_PROPERTY(std::string, ivt_variable)
61  ///@}
62 
63  /** @name min_ivt_variable
64  * Set the names of the minimum IVT column in the parameter table.
65  */
66  ///@{
67  TECA_ALGORITHM_PROPERTY(std::string, min_ivt_variable)
68  ///@}
69 
70  /** @name min_component_area_variable
71  * Set the names of the minimum area column in the parameter table.
72  */
73  ///@{
74  TECA_ALGORITHM_PROPERTY(std::string, min_component_area_variable)
75  ///@}
76 
77  /** @name hwhm_latitude_variable
78  * Set the names of the HWHM column in the parameter table.
79  */
80  ///@{
81  TECA_ALGORITHM_PROPERTY(std::string, hwhm_latitude_variable)
82  ///@}
83 
84  /** @name probability variable
85  * Set the name of the variable to store output probability as.
86  */
87  ///@{
88  TECA_ALGORITHM_PROPERTY(std::string, ar_probability_variable)
89  ///@}
90 
91  /** Set the number of threads in the pool. Setting to -1 results in a
92  * thread per core factoring in all MPI ranks running on the node. the
93  * default is -1.
94  */
95  void set_thread_pool_size(int n_threads);
96 
97  /// Get the number of threads in the pool.
98  unsigned int get_thread_pool_size() const noexcept;
99 
100  /** override the input connections because we are going to take the first
101  * input and use it to generate metadata. the second input then becomes
102  * the only one the pipeline knows about.
103  */
104  void set_input_connection(unsigned int id,
105  const teca_algorithm_output_port &port) override;
106 
107 protected:
109 
110  std::string get_label_variable(const teca_metadata &request);
111 
112 private:
113  teca_metadata get_output_metadata(unsigned int port,
114  const std::vector<teca_metadata> &input_md) override;
115 
116  std::vector<teca_metadata> get_upstream_request(
117  unsigned int port, const std::vector<teca_metadata> &input_md,
118  const teca_metadata &request) override;
119 
120  const_p_teca_dataset execute(unsigned int port,
121  const std::vector<const_p_teca_dataset> &input_data,
122  const teca_metadata &request) override;
123 
124  void set_modified() override;
125 
126 private:
127  std::string ivt_variable;
128  std::string min_component_area_variable;
129  std::string min_ivt_variable;
130  std::string hwhm_latitude_variable;
131  std::string ar_probability_variable;
132  int thread_pool_size;
133 
134  struct internals_t;
135  internals_t *internals;
136 };
137 
138 #endif
teca_metadata
A generic container for meta data in the form of name=value pairs.
Definition: teca_metadata.h:18
teca_bayesian_ar_detect
The TECA BARD atmospheric river detector.
Definition: teca_bayesian_ar_detect.h:43
teca_shared_object.h
teca_algorithm
The interface to TECA pipeline architecture.
Definition: teca_algorithm.h:237