UFO
ObsErrorModelQuad.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2020 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_OBSERRORMODELQUAD_H_
9 #define UFO_FILTERS_OBSFUNCTIONS_OBSERRORMODELQUAD_H_
10 
11 #include <string>
12 #include <vector>
13 
14 #include "ioda/ObsDataVector.h"
15 #include "oops/util/parameters/OptionalParameter.h"
16 #include "oops/util/parameters/Parameter.h"
17 #include "oops/util/parameters/Parameters.h"
18 #include "oops/util/parameters/RequiredParameter.h"
22 #include "ufo/filters/Variables.h"
24 
25 namespace ufo {
26 
27 /// \brief Options controlling ObsErrorModelQuad ObsFunction
28 class ObsErrorModelQuadParameters : public oops::Parameters {
29  OOPS_CONCRETE_PARAMETERS(ObsErrorModelQuadParameters, Parameters)
30 
31  public:
32  /// x variable of the piece-wise function
33  oops::RequiredParameter<Variable> xvar{"xvar", this};
34  /// channels for which to calculate the ObsError for radiances
35  /// Omit channels for application to a single non-radiance filter variable.
36  /// When multiple "filter variables" are provided without channels,
37  /// they will have the same observation error.
38  oops::OptionalParameter<std::string> chlist{"channels", this};
39  /// curvature of the quadratic function
40  oops::RequiredParameter<std::vector<float>> a{"a", this};
41  /// x-coordinate of the quadratic function apex
42  oops::RequiredParameter<std::vector<float>> b{"b", this};
43  /// y-coordinate of the lower piecewise inflection point
44  oops::RequiredParameter<std::vector<float>> err0{"err0", this};
45  /// y-coordinate of the upper piecewise inflection point
46  oops::RequiredParameter<std::vector<float>> err1{"err1", this};
47  /// whether to save the xfunc values to the ObsSpace
48  oops::Parameter<bool> save{"save", false, this};
49 };
50 
51 // -----------------------------------------------------------------------------
52 
53 /// \brief Parameterize the observation error as a
54 /// piece-wise quadratic function of a ufo::Variable
55 ///
56 /// The piece-wise function includes:
57 /// -# initial constant value
58 /// -# quadratic or inverse-quadratic growth
59 /// -# final constant value
60 ///
61 /// and is specified by a, b, err0, and err1 as follows:
62 /// ~~~~
63 /// p0 * x^2 + p1 * x + p2 ≡ a * (x - b)^2 + c
64 ///
65 /// a = p0
66 /// b = p1 / 2p0
67 /// c = p2 - p1^2 / (4 * p0)
68 ///
69 /// For a < 0
70 /// c = err1 |- - _,.-----
71 /// | .' '
72 /// | ,' '
73 /// err0 |__/ '
74 /// | '
75 /// '----------+-----
76 /// '
77 /// b
78 /// For a > 0
79 /// err1 |- - - ,-----
80 /// | /
81 /// | _.'
82 /// c = err0 |___.-'
83 /// | .
84 /// '--+-------------
85 /// '
86 /// b
87 /// ~~~~
88 ///
89 /// ### example configurations for a FilterBase derived class: ###
90 ///
91 /// - Filter: {Filter Name}
92 ///
93 /// #### ABI/AHI ####
94 ///
95 /// filter variables:
96 /// - name: brightness_temperature
97 /// channels: &errassignchan 8-10
98 /// action:
99 /// name: assign error
100 /// error function:
101 /// name: ObsErrorModelQuad@ObsFunction
102 /// channels: *errassignchan
103 /// options:
104 /// channels: *errassignchan
105 /// xvar:
106 /// name: OkamotoSCIforIR@ObsFunction
107 /// channels: *errassignchan
108 /// options:
109 /// channels: *errassignchan
110 /// a: [-0.069, -0.045, -0.032]
111 /// b: [15.0, 20.0, 25.0]
112 /// err0: [ 2.5, 3.2, 3.2]
113 /// err1: [17.0, 20.5, 21.1]
114 /// {save: true}
115 ///
116 class ObsErrorModelQuad : public ObsFunctionBase<float> {
117  public:
118  static const std::string classname() {return "ObsErrorModelQuad";}
119 
120  explicit ObsErrorModelQuad(const eckit::LocalConfiguration &);
122 
123  void compute(const ObsFilterData &,
125  const ufo::Variables & requiredVariables() const;
126  private:
129 };
130 
131 // -----------------------------------------------------------------------------
132 
133 } // namespace ufo
134 
135 #endif // UFO_FILTERS_OBSFUNCTIONS_OBSERRORMODELQUAD_H_
Parameterize the observation error as a piece-wise quadratic function of a ufo::Variable.
ObsErrorModelQuad(const eckit::LocalConfiguration &)
static const std::string classname()
ObsErrorModelQuadParameters options_
const ufo::Variables & requiredVariables() const
geovals required to compute the function
void compute(const ObsFilterData &, ioda::ObsDataVector< float > &) const
compute the result of the function
Options controlling ObsErrorModelQuad ObsFunction.
oops::Parameter< bool > save
whether to save the xfunc values to the ObsSpace
oops::RequiredParameter< Variable > xvar
x variable of the piece-wise function
oops::RequiredParameter< std::vector< float > > b
x-coordinate of the quadratic function apex
oops::OptionalParameter< std::string > chlist
oops::RequiredParameter< std::vector< float > > err0
y-coordinate of the lower piecewise inflection point
oops::RequiredParameter< std::vector< float > > err1
y-coordinate of the upper piecewise inflection point
oops::RequiredParameter< std::vector< float > > a
curvature of the quadratic function
ObsFilterData provides access to all data related to an ObsFilter.
Definition: RunCRTM.h:27