UFO
ProfileCheckBackgroundRelativeHumidity.cc
Go to the documentation of this file.
1 /*
2  * (C) Crown copyright 2020, Met Office
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 
9 
10 namespace ufo {
11 
12  static ProfileCheckMaker<ProfileCheckBackgroundRelativeHumidity>
13  makerProfileCheckBackgroundRelativeHumidity_("BackgroundRelativeHumidity");
14 
17  : ProfileCheckBase(options)
18  {}
19 
21  {
22  oops::Log::debug() << " Background check for relative humidity" << std::endl;
23 
24  const size_t numProfileLevels = profileDataHandler.getNumProfileLevels();
25  const bool ModelLevels = options_.modellevels.value();
26  const std::vector <float> &rhObs =
27  profileDataHandler.get<float>(ufo::VariableNames::obs_relative_humidity);
28  const std::vector <float> &rhObsErr =
29  profileDataHandler.get<float>(ufo::VariableNames::obserr_relative_humidity);
30  const std::vector <float> &rhBkg =
31  profileDataHandler.get<float>(ufo::VariableNames::hofx_relative_humidity);
32  const std::vector <float> &rhBkgErr =
34  std::vector <float> &rhPGE =
35  profileDataHandler.get<float>(ufo::VariableNames::pge_relative_humidity);
36  std::vector <float> &rhPGEBd =
37  profileDataHandler.get<float>(ufo::VariableNames::pgebd_relative_humidity);
38  std::vector <int> &rhFlags =
39  profileDataHandler.get<int>(ufo::VariableNames::qcflags_relative_humidity);
40  const std::vector <int> &timeFlags =
41  profileDataHandler.get<int>(ufo::VariableNames::qcflags_time);
42 
43  if (!oops::allVectorsSameNonZeroSize(rhObs, rhObsErr, rhBkg, rhBkgErr,
44  rhPGE, rhFlags, timeFlags)) {
45  oops::Log::warning() << "At least one vector is the wrong size. "
46  << "Check will not be performed." << std::endl;
47  oops::Log::warning() << "Vector sizes: "
48  << oops::listOfVectorSizes(rhObs, rhObsErr, rhBkg, rhBkgErr,
49  rhPGE, rhFlags, timeFlags)
50  << std::endl;
51  return;
52  }
53 
54  // Probability density of 'bad' observations.
55  std::vector <float> PdBad(numProfileLevels, options_.BkCheck_PdBad_rh.value());
56  // Local version of relative humidity background error.
57  std::vector <float> BackgrErrRH(numProfileLevels, 0.0);
58  // Local version of relative humidity observation error.
59  std::vector <float> ObErrRH(numProfileLevels, 0.0);
60 
61  // Relax QC to take account of long-tailed error distributions.
62  const float sqrt2 = std::sqrt(2.0);
63  for (int jlev = 0; jlev < numProfileLevels; ++jlev) {
64  BackgrErrRH[jlev] = missingValueFloat;
65  ObErrRH[jlev] = missingValueFloat;
66  if (rhBkgErr[jlev] != missingValueFloat)
67  BackgrErrRH[jlev] = sqrt2 * rhBkgErr[jlev];
68  if (rhObsErr[jlev] != missingValueFloat)
69  ObErrRH[jlev] = sqrt2 * rhObsErr[jlev];
70  if (timeFlags[jlev])
72  }
73 
74  // Calculate probability of gross error.
76  rhObs,
77  ObErrRH, // Used instead of rhObsErr.
78  rhBkg,
79  BackgrErrRH, // Used instead of rhBkgErr.
80  PdBad,
81  ModelLevels,
82  rhFlags,
83  rhPGE,
84  rhPGEBd,
86  }
87 } // namespace ufo
Options controlling the operation of the ConventionalProfileProcessing filter.
oops::Parameter< float > BkCheck_ErrVarMax_rh
Maximum error variance for RH.
oops::Parameter< float > BkCheck_PdBad_rh
Prior probability of 'bad' observations for RH.
ProbabilityOfGrossErrorParameters PGEParameters
Parameters related to PGE calculations.
oops::Parameter< bool > modellevels
Have the observation and model values been averaged onto model levels?
void runCheck(ProfileDataHandler &profileDataHandler) override
Run check.
ProfileCheckBackgroundRelativeHumidity(const ConventionalProfileProcessingParameters &options)
Profile QC checker base class.
const float missingValueFloat
Missing value (float)
const ConventionalProfileProcessingParameters & options_
Configurable parameters.
Retrieve and store data for individual profiles. To do this, first the vector of values in the entire...
std::vector< T > & get(const std::string &fullname)
int getNumProfileLevels() const
Return number of levels to which QC checks should be applied.
std::vector< float > & getObsDiag(const std::string &variableName)
Get ObsDiags for a particular profile.
@ PermRejectFlag
Blacklisted data.
Definition: RunCRTM.h:27
static ProfileCheckMaker< ProfileCheckBackgroundRelativeHumidity > makerProfileCheckBackgroundRelativeHumidity_("BackgroundRelativeHumidity")
void BayesianPGEUpdate(const ProbabilityOfGrossErrorParameters &options, const std::vector< float > &obsVal, const std::vector< float > &obsErr, const std::vector< float > &bkgVal, const std::vector< float > &bkgErr, const std::vector< float > &PdBad, const bool ModelLevels, std::vector< int > &flags, std::vector< float > &PGE, std::vector< float > &PGEBd, float ErrVarMax, const std::vector< float > *obsVal2, const std::vector< float > *bkgVal2)
Bayesian update of probability of gross error (PGE)
static constexpr const char *const bkgerr_relative_humidity
Definition: VariableNames.h:49
static constexpr const char *const obs_relative_humidity
Definition: VariableNames.h:20
static constexpr const char *const pge_relative_humidity
Definition: VariableNames.h:63
static constexpr const char *const qcflags_relative_humidity
static constexpr const char *const qcflags_time
static constexpr const char *const hofx_relative_humidity
Definition: VariableNames.h:40
static constexpr const char *const pgebd_relative_humidity
Definition: VariableNames.h:74
static constexpr const char *const obserr_relative_humidity
Definition: VariableNames.h:29