UFO
CloudCostFunction.h
Go to the documentation of this file.
1 /*
2  * (C) Crown Copyright 2021 Met Office UK
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_CLOUDCOSTFUNCTION_H_
9 #define UFO_FILTERS_OBSFUNCTIONS_CLOUDCOSTFUNCTION_H_
10 
11 #include <string>
12 #include <vector>
13 
14 #include "oops/util/parameters/Parameter.h"
15 #include "oops/util/parameters/Parameters.h"
16 #include "oops/util/parameters/RequiredParameter.h"
17 
20 #include "ufo/filters/Variables.h"
23 
24 namespace ufo {
25 
26 ///
27 /// \brief Options for calculating Bayesian cost function.
28 ///
29 class CloudCostFunctionParameters : public oops::Parameters {
30  OOPS_CONCRETE_PARAMETERS(CloudCostFunctionParameters, Parameters)
31 
32  public:
33  /// Set of channels used in the calculation of the cost function
34  oops::RequiredParameter<std::string> chanlist{"cost channels list", this};
35 
36  /// Path to location of file describing the R-matrix
37  oops::RequiredParameter<std::string> rmatrix_filepath{"RMatrix", this};
38 
39  /// Path to location of file describing the B-matrix
40  oops::RequiredParameter<std::string> bmatrix_filepath{"BMatrix", this};
41 
42  /// List of geovals describing fields required from the B-matrix
43  oops::RequiredParameter<std::vector<std::string>>
44  field_names{"background fields", this};
45 
46  /// \brief B-matrix file contains error covariances for ln(qtotal in units g/kg)
47  ///
48  /// Setting this flag for qtotal requires that the following are all present
49  /// in the parameter list "background fields":
50  /// - specific_humidity
51  /// - mass_content_of_cloud_liquid_water_in_atmosphere_layer
52  /// - mass_content_of_cloud_ice_in_atmosphere_layer
53  oops::Parameter<bool> qtotal_lnq_gkg{"qtotal", false, this};
54 
55  /// Include treatment of rain when splitting total humidity into constituent phases
56  oops::Parameter<bool> qtotal_split_rain{"qtotal split rain", false, this};
57 
58  /// Include gradient due to ice in brightness temperature total humidity Jacobian
59  oops::Parameter<bool> scattering_switch{"scattering radiative transfer", false, this};
60 
61  /// Limit specific humidity to minimum value
62  oops::Parameter<float> min_q{"minimum specific humidity", 3.0e-6f, this};
63 
64  /// Jacobian vertical ordering is reverse of geovals
65  oops::Parameter<bool> reverse_Jacobian{"reverse Jacobian order", false, this};
66 
67  /// Minimum bound for ObsValue brightness temperature
68  oops::Parameter<float> minTb{"minimum ObsValue", 70.0, this};
69 
70  /// Maximum bound for ObsValue brightness temperature
71  oops::Parameter<float> maxTb{"maximum ObsValue", 340.0, this};
72 
73  /// Maximum value for final cost returned by the ObsFunction
74  oops::Parameter<float> maxCost{"maximum final cost", 1600.0, this};
75 
76  /// \brief Name of the H(x) group used in the cost function calculation.
77  ///
78  /// H(x) is assumed to be already bias corrected, the default is "HofX"
79  ///
80  /// Example: use
81  ///
82  /// HofX group: MetOfficeBiasCorrHofX
83  oops::Parameter<std::string> HofXGroup{"HofX group", "HofX", this};
84 };
85 
86 ///
87 /// \brief Bayesian cost function for detecting cloud-affected radiances.
88 ///
89 /// The cloud cost, Jc, is calculated from observation-H(x) departures, y, via
90 ///
91 /// Jc = (0.5/Nchan) * y.W.y^T
92 ///
93 /// where Nchan is the number of channels in the calculation and
94 /// W is the inverse of (H.B.H^T + R):
95 ///
96 /// H is the Jacobian matrix;
97 /// B is a background error covariance matrix;
98 /// R is an observation error covariance matrix.
99 ///
100 /// The heritage of this code is the Met Office routine Ops_SatRad_CloudCost.
101 ///
102 /// Implementation here follows Met Office usage, with a static (latitude-varying)
103 /// B-matrix and a fixed, diagonal R-matrix.
104 ///
105 /// Reference: S.J. English, J.R. Eyre and J.A. Smith.
106 /// A cloud‐detection scheme for use with satellite sounding radiances in the
107 /// context of data assimilation for numerical weather prediction support of
108 /// nowcasting applications.
109 /// Quart. J. Royal Meterol. Soc., Vol. 125, pp. 2359-2378 (1999).
110 /// https://doi.org/10.1002/qj.49712555902
111 
112 class CloudCostFunction : public ObsFunctionBase<float> {
113  public:
114  explicit CloudCostFunction(const eckit::LocalConfiguration &
115  = eckit::LocalConfiguration());
116  void compute(const ObsFilterData &,
118  const ufo::Variables & requiredVariables() const;
119 
120  private:
122  std::vector<int> channels_;
123  std::vector<std::string> fields_;
125 };
126 
127 
128 // -----------------------------------------------------------------------------
129 
130 } // namespace ufo
131 
132 #endif // UFO_FILTERS_OBSFUNCTIONS_CLOUDCOSTFUNCTION_H_
Bayesian cost function for detecting cloud-affected radiances.
std::vector< std::string > fields_
std::vector< int > channels_
CloudCostFunctionParameters 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
CloudCostFunction(const eckit::LocalConfiguration &=eckit::LocalConfiguration())
Options for calculating Bayesian cost function.
oops::RequiredParameter< std::vector< std::string > > field_names
List of geovals describing fields required from the B-matrix.
oops::Parameter< bool > qtotal_split_rain
Include treatment of rain when splitting total humidity into constituent phases.
oops::Parameter< bool > qtotal_lnq_gkg
B-matrix file contains error covariances for ln(qtotal in units g/kg)
oops::Parameter< bool > reverse_Jacobian
Jacobian vertical ordering is reverse of geovals.
oops::Parameter< float > maxTb
Maximum bound for ObsValue brightness temperature.
oops::RequiredParameter< std::string > chanlist
Set of channels used in the calculation of the cost function.
oops::RequiredParameter< std::string > rmatrix_filepath
Path to location of file describing the R-matrix.
oops::Parameter< std::string > HofXGroup
Name of the H(x) group used in the cost function calculation.
oops::Parameter< float > maxCost
Maximum value for final cost returned by the ObsFunction.
oops::Parameter< float > min_q
Limit specific humidity to minimum value.
oops::RequiredParameter< std::string > bmatrix_filepath
Path to location of file describing the B-matrix.
oops::Parameter< float > minTb
Minimum bound for ObsValue brightness temperature.
oops::Parameter< bool > scattering_switch
Include gradient due to ice in brightness temperature total humidity Jacobian.
ObsFilterData provides access to all data related to an ObsFilter.
Definition: RunCRTM.h:27