UFO
ObsErrorModelStepwiseLinear.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_OBSERRORMODELSTEPWISELINEAR_H_
9 #define UFO_FILTERS_OBSFUNCTIONS_OBSERRORMODELSTEPWISELINEAR_H_
10 
11 #include <string>
12 #include <vector>
13 
14 #include "ioda/ObsDataVector.h"
15 
16 #include "oops/util/parameters/OptionalParameter.h"
17 #include "oops/util/parameters/Parameter.h"
18 #include "oops/util/parameters/Parameters.h"
19 #include "oops/util/parameters/RequiredParameter.h"
20 
23 #include "ufo/filters/Variables.h"
25 
26 namespace ufo {
27 
28 /// \brief Options controlling ObsErrorModelStepwiseLinear ObsFunction
29 class ObsErrorModelStepwiseLinearParameters : public oops::Parameters {
30  OOPS_CONCRETE_PARAMETERS(ObsErrorModelStepwiseLinearParameters, Parameters)
31 
32  public:
33  /// the name of the xvar
34  oops::RequiredParameter<Variable> xvar{"xvar", this};
35  /// vector of X-steps
36  oops::RequiredParameter<std::vector<float>> xvals{"xvals", this};
37  /// vector of error values corresponding to vector of X-steps
38  oops::RequiredParameter<std::vector<float>> errors{"errors", this};
39  /// When final answer is a multiplication factor, we need to know which variable to multiply
40  oops::OptionalParameter<Variable> scale_factor_var{"scale_factor_var", this};
41 };
42 
43 // -----------------------------------------------------------------------------
44 
45 /// \brief Parameterize the observation error as a series of steps with
46 /// linear interpolation between each step.
47 ///
48 /// This routine was designed to mimic the GSI fix-file of prepobs_errtable.txt
49 /// Input is a vector of x-values (e.g. pressures) and corresponding vector of obserrors.
50 /// Interpolation in X-coordinate requires the value of X for which the output, Y, is
51 /// calculated using linear interp of obserrors between the steps.
52 /// If the optional "scale_factor_var" exists, then the final output obserr is
53 /// calculated as a result of linear interpolation of errors times the scale_factor_var.
54 /// An example of such usage is RH obserror values between zero and one multiplied by
55 /// specific_humidity@ObsValue for final ObsError.
56 /// ~~~~
57 ///
58 /// + err_n o
59 /// | /
60 /// | /
61 /// + err_n-1 o
62 /// | /
63 /// obserr + *
64 /// | /
65 /// | /
66 /// err2 + o
67 /// | /
68 /// | /
69 /// err1 + o
70 /// | /
71 /// err0 +-----+------+---------*---+--------+
72 /// p_0, p_1, p_2,... p* p_n-1, p_n
73 ///
74 /// ~~~~
75 ///
76 /// ### example configurations for a FilterBase derived class: ###
77 ///
78 /// - Filter: {Filter Name}
79 ///
80 /// #### Example for air temperature assigned obserror by pressure (e.g., sonde data) ####
81 ///
82 /// filter variables:
83 /// - name: air_temperature
84 /// action:
85 /// name: assign error
86 /// error function:
87 /// name: ObsErrorModelStepwiseLinear@ObsFunction
88 /// options:
89 /// xvar:
90 /// name: air_pressure@ObsValue
91 /// xvals: [110000, 85000, 50000, 25000, 10000, 1] #Pressure (Pa)
92 /// errors: [1.1, 1.3, 1.8, 2.4, 4.0, 4.5]
93 ///
95  public:
96  static const std::string classname() {return "ObsErrorModelStepwiseLinear";}
97 
98  explicit ObsErrorModelStepwiseLinear(const eckit::LocalConfiguration);
100 
101  void compute(const ObsFilterData &, ioda::ObsDataVector<float> &) const;
102  const ufo::Variables & requiredVariables() const;
103  private:
106  bool isAscending_ = true;
107  bool multiplicative_ = false;
108 };
109 
110 // -----------------------------------------------------------------------------
111 
112 } // namespace ufo
113 
114 #endif // UFO_FILTERS_OBSFUNCTIONS_OBSERRORMODELSTEPWISELINEAR_H_
Parameterize the observation error as a series of steps with linear interpolation between each step.
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
ObsErrorModelStepwiseLinearParameters options_
ObsErrorModelStepwiseLinear(const eckit::LocalConfiguration)
Options controlling ObsErrorModelStepwiseLinear ObsFunction.
oops::OptionalParameter< Variable > scale_factor_var
When final answer is a multiplication factor, we need to know which variable to multiply.
oops::RequiredParameter< Variable > xvar
the name of the xvar
oops::RequiredParameter< std::vector< float > > errors
vector of error values corresponding to vector of X-steps
oops::RequiredParameter< std::vector< float > > xvals
vector of X-steps
ObsFilterData provides access to all data related to an ObsFilter.
Definition: RunCRTM.h:27