UFO
ObsFunctionLinearCombination.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2021 UCAR
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_FILTERS_OBSFUNCTIONS_OBSFUNCTIONLINEARCOMBINATION_H_
9 #define UFO_FILTERS_OBSFUNCTIONS_OBSFUNCTIONLINEARCOMBINATION_H_
10 
11 #include <string>
12 #include <vector>
13 
14 #include "oops/util/parameters/Parameters.h"
15 #include "oops/util/parameters/RequiredParameter.h"
16 
19 #include "ufo/filters/Variable.h"
20 #include "ufo/filters/Variables.h"
22 
23 namespace ufo {
24 
25 /// \brief Options controlling ObsFunctionLinearCombination ObsFunction
26 class LinearCombinationParameters : public oops::Parameters {
27  OOPS_CONCRETE_PARAMETERS(LinearCombinationParameters, Parameters)
28 
29  public:
30  /// Input variables of the linear combination
31  oops::RequiredParameter<std::vector<Variable>> variables{"variables", this};
32  /// coefficient associated with the above variables
33  oops::RequiredParameter<std::vector<float>> coefs{"coefs", this};
34 };
35 
36 // -----------------------------------------------------------------------------
37 
38 /// \brief Outputs a linear combination of variables
39 ///
40 /// Example 1
41 ///
42 /// obs function:
43 /// name: LinearCombination@ObsFunction
44 /// options:
45 /// variables: [representation_error@GeoVaLs,
46 /// sea_water_temperature@ObsError]
47 /// coefs: [0.1,
48 /// 1.0]
49 ///
50 /// will return 0.1 * representation_error@GeoVaLs +
51 /// 1.0 * sea_water_temperature@ObsError
52 ///
53 /// Example 2 - multi-channel
54 ///
55 /// obs function:
56 /// name: LinearCombination@ObsFunction
57 /// channels: &select_chans 6-15, 18-22 # this line may be needed depending on the filter used
58 /// options:
59 /// variables:
60 /// - name: brightness_temperature@ObsValue
61 /// channels: *select_chans
62 /// - name: brightness_temperature@ObsError
63 /// channels: *select_chans
64 /// coefs: [1.0,
65 /// 0.5]
66 ///
67 /// will return 1.0 * brightness_temperature_<channel>@ObsValue +
68 /// 0.5 * brightness_temperature_<channel>@ObsError
69 ///
70 
71 class LinearCombination : public ObsFunctionBase<float> {
72  public:
73  explicit LinearCombination(const eckit::LocalConfiguration &);
75 
76  void compute(const ObsFilterData &,
78  const ufo::Variables & requiredVariables() const;
79  private:
82 };
83 
84 // -----------------------------------------------------------------------------
85 
86 } // namespace ufo
87 
88 #endif // UFO_FILTERS_OBSFUNCTIONS_OBSFUNCTIONLINEARCOMBINATION_H_
Outputs a linear combination of variables.
LinearCombinationParameters options_
const ufo::Variables & requiredVariables() const
geovals required to compute the function
LinearCombination(const eckit::LocalConfiguration &)
void compute(const ObsFilterData &, ioda::ObsDataVector< float > &) const
compute the result of the function
Options controlling ObsFunctionLinearCombination ObsFunction.
oops::RequiredParameter< std::vector< Variable > > variables
Input variables of the linear combination.
oops::RequiredParameter< std::vector< float > > coefs
coefficient associated with the above variables
ObsFilterData provides access to all data related to an ObsFilter.
Definition: RunCRTM.h:27