UFO
ObsErrorFactorConventional.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_OBSERRORFACTORCONVENTIONAL_H_
9 #define UFO_FILTERS_OBSFUNCTIONS_OBSERRORFACTORCONVENTIONAL_H_
10 
11 #include <memory>
12 #include <string>
13 #include <vector>
14 
15 #include "ioda/ObsDataVector.h"
16 
17 #include "oops/util/parameters/OptionalParameter.h"
18 #include "oops/util/parameters/Parameter.h"
19 #include "oops/util/parameters/Parameters.h"
20 #include "oops/util/parameters/RequiredParameter.h"
21 
24 #include "ufo/filters/Variables.h"
26 
27 namespace ufo {
28 
29 /// \brief Options controlling ObsErrorFactorConventional ObsFunction
30 class ObsErrorFactorConventionalParameters : public oops::Parameters {
31  OOPS_CONCRETE_PARAMETERS(ObsErrorFactorConventionalParameters, Parameters)
32 
33  public:
34  /// Inflate variables
35  oops::RequiredParameter<std::vector<std::string>> inflatevars{"inflate variables", this};
36  /// Name of the data group to which the QC flag is applied (default is QCflagsData)
37  oops::Parameter<std::string> testQCflag{"test QCflag", "QCflagsData", this};
38  oops::OptionalParameter<int> qcthreshold{"test QCthreshold", this};
39 };
40 
41 // -----------------------------------------------------------------------------
42 
43 /// \brief Inflate the observation error for conventional as done by GSI-Observer.
44 ///
45 /// This routine was designed to mimic the GSI observer code (i.e., subroutine errormod in
46 /// qcmod.f90) to inflate the observation error for conventional/satwinds using the
47 /// qc flags generated from a filter or from the input files with a group name
48 /// (test QCflag) defined in the yaml. The inflation factor is determined by the obseravtion
49 /// vertical spacing (in pressure) relative to the corresponding model pressure interval.
50 /// This error inflation obsFuction is used in GSI for temperature, moiture, and winds from
51 /// conventional obs as well as some of satellite retrievels, e.g., radiosonde/other conventional
52 /// temperature, moisture, and wind, SCAT winds, VAD winds, and potentially aircraft ascent
53 /// and descent profiles.
54 ///
55 /// Notes:
56 /// (1) If using this obs function in a filter, please
57 /// make sure the "filter variables" and "inflate variables" prescribed
58 /// with the same variable name.
59 /// (2) This obs funciton requires each of the obs profiles are sorted by pressure
60 /// in descending order
61 ///
62 /// ### example configurations for testing this obs function: ###
63 ///
64 /// obs function:
65 /// name: ObsErrorFactorConventional@ObsFunction
66 /// variables: [eastward_wind] # Variable name for output
67 /// tolerance: 1.e-6
68 /// options:
69 /// inflate variables: [eastward_wind] # Ok to be multiple dimensions for running
70 /// # this obsFunction only (not within a filter)
71 /// test QCflag: PreQC # Optional. If not defined, use QCflags from prior filters
72 /// test QCthreshold: 2 # Optonal, only when PreQC is used
73 /// # Default is 3 for PreQC
74 /// # In GSI(PreQC): if noiqc (no oiqc)=true, QCthreshold=7;
75 /// if noiqc=false, QCthreshold=3
76 ///
77 /// ### example configurations for using this obs function in a filter: ###
78 /// - filter: BlackList
79 /// filter variables:
80 /// - name: virtual_temperature # Have to be consistent with "inflate
81 /// # variables". Therefore, only one variable allowed
82 /// # while running with this obsFunc
83 /// action:
84 /// name: inflate error
85 /// inflation variable:
86 /// name: ObsErrorFactorConventional@ObsFunction
87 /// options:
88 /// inflate variables: [virtual_temperature] # Have to be consistent with "filter
89 /// # variables". Therefore, only one
90 /// # variable allowed
91 ///
92 /// ### example configurations for using obsgrouping: ###
93 ///
94 /// obsgrouping:
95 /// group variables: ["station_id", "datetime"] # Choose parameteres to identify each of
96 /// # the obs profiles
97 /// sort variable: "air_pressure"
98 /// sort order: "descending"
99 ///
101  public:
102  static const std::string classname() {return "ObsErrorFactorConventional";}
103 
104  explicit ObsErrorFactorConventional(const eckit::Configuration &config);
106 
107  void compute(const ObsFilterData &, ioda::ObsDataVector<float> &) const;
108  const ufo::Variables & requiredVariables() const;
109  private:
111  std::unique_ptr<ObsErrorFactorConventionalParameters> options_;
112 };
113 
114 // -----------------------------------------------------------------------------
115 
116 } // namespace ufo
117 
118 #endif // UFO_FILTERS_OBSFUNCTIONS_OBSERRORFACTORCONVENTIONAL_H_
Inflate the observation error for conventional as done by GSI-Observer.
void compute(const ObsFilterData &, ioda::ObsDataVector< float > &) const
compute the result of the function
ObsErrorFactorConventional(const eckit::Configuration &config)
std::unique_ptr< ObsErrorFactorConventionalParameters > options_
const ufo::Variables & requiredVariables() const
geovals required to compute the function
Options controlling ObsErrorFactorConventional ObsFunction.
oops::Parameter< std::string > testQCflag
Name of the data group to which the QC flag is applied (default is QCflagsData)
oops::RequiredParameter< std::vector< std::string > > inflatevars
Inflate variables.
ObsFilterData provides access to all data related to an ObsFilter.
Definition: RunCRTM.h:27