UFO
ObsCategorical.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2021 UK Met Office
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  */
7 
8 #ifndef UFO_CATEGORICALOPER_OBSCATEGORICAL_H_
9 #define UFO_CATEGORICALOPER_OBSCATEGORICAL_H_
10 
11 #include <map>
12 #include <memory>
13 #include <ostream>
14 #include <string>
15 #include <vector>
16 
17 #include "oops/base/Variables.h"
18 #include "oops/util/ObjectCounter.h"
19 
21 #include "ufo/ObsOperatorBase.h"
22 
23 /// Forward declarations
24 namespace ioda {
25  class ObsSpace;
26  class ObsVector;
27 }
28 
29 namespace ufo {
30  class GeoVaLs;
31  class Locations;
32  class ObsDiagnostics;
33 
34 /// \brief Categorical observation operator.
35 ///
36 /// The Categorical operator can be used to run several observation operators,
37 /// each of which produces a vector of H(x) values.
38 /// The Categorical operator then creates a final H(x) vector by selecting the
39 /// observation operator at each location according to a categorical variable.
40 ///
41 /// The choice of observation operator at each location is governed by the `categorical variable`
42 /// parameter, which must be an integer or string variable in the MetaData group.
43 ///
44 /// The `categorised operators` map is used to produce a correspondence between values of the
45 /// categorical variable and the operator used.
46 ///
47 /// The `fallback operator` parameter governs the observation operator that will be used
48 /// whenever a particular value of the categorical variable does not exist in
49 /// `categorised operators`.
50 ///
51 /// The `operator configurations` parameter governs the configuration of each of the operators
52 /// to be used.
53 /// If either the fallback operator or one of the categorised operators have not been configured,
54 /// an exception will be thrown.
55 ///
56 /// An example yaml configuration is as follows:
57 /// obs operator:
58 /// name: Categorical
59 /// categorical variable: station_id
60 /// fallback operator: "Composite"
61 /// categorised operators: {"47418": "Composite", "54857": "Identity"}
62 /// operator configurations:
63 /// - name: Identity
64 /// - name: Composite
65 /// components:
66 /// - name: Identity
67 /// variables:
68 /// - name: air_temperature
69 /// - name: surface_pressure
70 /// - name: VertInterp
71 /// variables:
72 /// - name: northward_wind
73 /// - name: eastward_wind
74 ///
75 /// This operator uses station_id@MetaData as the categorical variable.
76 /// Both the Identity and Composite operators are used to produce H(x) vectors.
77 /// Then, at each location in the ObsSpace:
78 /// - if station_id@MetaData is equal to 47418 then the Composite H(x) is selected;
79 /// - if station_id@MetaData is equal to 54857 then the Identity H(x) is selected;
80 /// - otherwise, the fallback operator (also Composite in this case) H(x) is selected.
82  private util::ObjectCounter<ObsCategorical> {
83  public:
84  /// The type of parameters accepted by the constructor of this operator.
85  /// This typedef is used by the ObsOperatorFactory.
87 
88  static const std::string classname() {return "ufo::ObsCategorical";}
89 
90  ObsCategorical(const ioda::ObsSpace &, const Parameters_ &);
91  ~ObsCategorical() override;
92 
93  void simulateObs(const GeoVaLs &, ioda::ObsVector &, ObsDiagnostics &) const override;
94 
95  const oops::Variables & requiredVars() const override { return data_.requiredVars(); }
96 
97  private:
98  void print(std::ostream &) const override;
99 
100  private:
101  /// ObsSpace.
102  const ioda::ObsSpace& odb_;
103 
104  /// Data handler for the Categorical operator and TL/AD code.
106 };
107 
108 // -----------------------------------------------------------------------------
109 
110 } // namespace ufo
111 #endif // UFO_CATEGORICALOPER_OBSCATEGORICAL_H_
GeoVaLs: geophysical values at locations.
Data handler for the Categorical observation operator and TL/AD code.
Categorical observation operator.
const ioda::ObsSpace & odb_
ObsSpace.
~ObsCategorical() override
static const std::string classname()
ObsCategoricalData< ObsOperatorBase > data_
Data handler for the Categorical operator and TL/AD code.
void simulateObs(const GeoVaLs &, ioda::ObsVector &, ObsDiagnostics &) const override
Obs Operator.
const oops::Variables & requiredVars() const override
Operator input required from Model.
ObsCategoricalParameters Parameters_
void print(std::ostream &) const override
ObsCategorical(const ioda::ObsSpace &, const Parameters_ &)
Configuration options recognized by the Categorical operator.
Forward declarations.
Definition: ObsAodExt.h:25
Definition: RunCRTM.h:27