UFO
ObsErrorModelRamp.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2019 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_OBSERRORMODELRAMP_H_
9 #define UFO_FILTERS_OBSFUNCTIONS_OBSERRORMODELRAMP_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/Variable.h"
23 #include "ufo/filters/Variables.h"
25 
26 namespace ufo {
27 
28 // -----------------------------------------------------------------------------
29 
30 /// \brief Options controlling the ObsErrorModelRamp ObsFunction
31 class ObsErrorModelRampParameters : public oops::Parameters {
32  OOPS_CONCRETE_PARAMETERS(ObsErrorModelRampParameters, Parameters)
33 
34  public:
35  /// x variable of the piece-wise function
36  oops::RequiredParameter<Variable> xvar{"xvar", this};
37  /// channels; channels for which to calculate the ObsError for radiances
38  /// Omit channels for application to a single non-radiance filter variable.
39  /// When multiple "filter variables" are provided without channels,
40  /// they will have the same observation error.
41  oops::OptionalParameter<std::string> chlist{"channels", this};
42  /// x-coordinate of the lower ramp inflection point
43  oops::RequiredParameter<std::vector<float>> x0{"x0", this};
44  /// x-coordinate of the upper ramp inflection point
45  oops::RequiredParameter<std::vector<float>> x1{"x1", this};
46  /// (optinal) an extra upper ramp.
47  oops::OptionalParameter<std::vector<float>> x2{"x2", this};
48  /// y-coordinate of the lower ramp inflection point
49  oops::RequiredParameter<std::vector<float>> err0{"err0", this};
50  /// y-coordinate of the upper ramp inflection point
51  oops::RequiredParameter<std::vector<float>> err1{"err1", this};
52  /// (optional) an extra error value.
53  oops::OptionalParameter<std::vector<float>> err2{"err2", this};
54  /// whether to save xvar values to the ObsSpace
55  oops::Parameter<bool> save{"save", false, this};
56 };
57 
58 // -----------------------------------------------------------------------------
59 
60 /// \brief Parameterize the observation error as a
61 /// piece-wise linear function of a ufo::Variable
62 ///
63 /// The output function is specified by the coordinates of the
64 /// inflection points and includes:
65 /// -# initial constant value
66 /// -# linear growth or decay (ramp)
67 /// -# final constant value
68 ///
69 /// ~~~~
70 /// err1 |- - - *---
71 /// | ,'.
72 /// | ,' .
73 /// | ,' .
74 /// err0 |--*' .
75 /// | . .
76 /// '--+-------+---
77 /// ' '
78 /// x0 x1
79 /// ~~~~
80 /// In case there are x2 and err2 values:
81 ///
82 /// err2 |- - - - - - - *---
83 /// | , ' .
84 /// | , ' .
85 /// | , ' .
86 /// err1 |- - - *--- .
87 /// | ,'. .
88 /// | ,' . .
89 /// | ,' . .
90 /// err0 |--*' . .
91 /// | . . .
92 /// '--+-------+---------------
93 /// ' ' '
94 /// x0 x1 x2
95 /// ~~~~
96 ///
97 /// Notes:
98 /// - for a decaying ramp, set err1 < err0 and/or err2 < err1.
99 /// - for a step function starting at either the first or second inflection point, set x0 == x1
100 /// or x2 == x1, respectively.
101 ///
102 /// ### example configurations for a FilterBase derived class: ###
103 ///
104 /// - Filter: {Filter Name}
105 ///
106 /// #### AMSUA ####
107 ///
108 /// filter variables:
109 /// - name: brightness_temperature
110 /// channels: &errassignchan 1-15
111 /// action:
112 /// name: assign error
113 /// error function:
114 /// name: ObsErrorModelRamp@ObsFunction
115 /// channels: *errassignchan
116 /// options:
117 /// channels: *errassignchan
118 /// xvar:
119 /// name: CLWRetMean@ObsFunction
120 /// options:
121 /// clwret_ch238: 1
122 /// clwret_ch314: 2
123 /// clwret_types: [ObsValue, HofX]
124 /// bias_application: HofX
125 /// x0: [ 0.050, 0.030, 0.030, 0.020, 0.000,
126 /// 0.100, 0.000, 0.000, 0.000, 0.000,
127 /// 0.000, 0.000, 0.000, 0.000, 0.030]
128 /// x1: [ 0.600, 0.450, 0.400, 0.450, 1.000,
129 /// 1.500, 0.000, 0.000, 0.000, 0.000,
130 /// 0.000, 0.000, 0.000, 0.000, 0.200]
131 /// err0: [ 2.500, 2.200, 2.000, 0.550, 0.300,
132 /// 0.230, 0.230, 0.250, 0.250, 0.350,
133 /// 0.400, 0.550, 0.800, 3.000, 3.500]
134 /// err1: [20.000, 18.000, 12.000, 3.000, 0.500,
135 /// 0.300, 0.230, 0.250, 0.250, 0.350,
136 /// 0.400, 0.550, 0.800, 3.000, 18.000]
137 /// {save: true}
138 ///
139 /// #### ABI/AHI ####
140 ///
141 /// filter variables:
142 /// - name: brightness_temperature
143 /// channels: &errassignchan 8-10
144 /// action:
145 /// name: assign error
146 /// error function:
147 /// name: ObsErrorModelRamp@ObsFunction
148 /// channels: *errassignchan
149 /// options:
150 /// channels: *errassignchan
151 /// xvar:
152 /// name: SymmCldImpactIR@ObsFunction
153 /// channels: *errassignchan
154 /// options:
155 /// channels: *errassignchan
156 /// x0: [ 0.0, 0.0, 1.0]
157 /// x1: [15.0, 20.0, 25.0]
158 /// err0: [ 2.5, 3.2, 3.2]
159 /// err1: [17.0, 20.5, 21.1]
160 ///
161 /// #### Non-radiance ObsTypes ####
162 ///
163 /// filter variables:
164 /// - name: {filter variable name}
165 /// action:
166 /// name: assign error
167 /// error function:
168 /// name: ObsErrorModelRamp@ObsFunction
169 /// options:
170 /// xvar:
171 /// name: {xvar}@[ObsFunction, GeoVaLs, ObsDiag, ObsValue, etc...]
172 /// options: {xvar options}
173 /// x0: [{X0}]
174 /// x1: [{X1}]
175 /// err0: [{ERR0}]
176 /// err1: [{ERR1}]
177 ///
178 class ObsErrorModelRamp : public ObsFunctionBase<float> {
179  public:
180  static const std::string classname() {return "ObsErrorModelRamp";}
181 
182  explicit ObsErrorModelRamp(const eckit::LocalConfiguration);
183  ~ObsErrorModelRamp();
184 
185  void compute(const ObsFilterData &,
187  const ufo::Variables & requiredVariables() const;
188  private:
189  ufo::Variables invars_;
190  ObsErrorModelRampParameters options_;
191 };
192 
193 // -----------------------------------------------------------------------------
194 
195 } // namespace ufo
196 
197 #endif // UFO_FILTERS_OBSFUNCTIONS_OBSERRORMODELRAMP_H_
Options controlling the ObsErrorModelRamp ObsFunction.
oops::RequiredParameter< std::vector< float > > err1
y-coordinate of the upper ramp inflection point
oops::OptionalParameter< std::vector< float > > x2
(optinal) an extra upper ramp.
oops::RequiredParameter< std::vector< float > > x1
x-coordinate of the upper ramp inflection point
oops::RequiredParameter< std::vector< float > > err0
y-coordinate of the lower ramp inflection point
oops::RequiredParameter< Variable > xvar
x variable of the piece-wise function
oops::Parameter< bool > save
whether to save xvar values to the ObsSpace
oops::OptionalParameter< std::string > chlist
oops::OptionalParameter< std::vector< float > > err2
(optional) an extra error value.
oops::RequiredParameter< std::vector< float > > x0
x-coordinate of the lower ramp inflection point
Definition: RunCRTM.h:27