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 
16  (const ProfileConsistencyCheckParameters &options,
17  const ProfileIndices &profileIndices,
18  ProfileDataHandler &profileDataHandler,
19  ProfileCheckValidator &profileCheckValidator)
20  : ProfileCheckBase(options, profileIndices, profileDataHandler, profileCheckValidator)
21  {}
22 
24  {
25  oops::Log::debug() << " Background check for relative humidity" << std::endl;
26 
27  const size_t numLevelsToCheck = profileIndices_.getNumLevelsToCheck();
28  const bool ModelLevels = options_.modellevels.value();
29  const std::vector <float> &rhObs =
31  const std::vector <float> &rhObsErr =
33  const std::vector <float> &rhBkg =
35  const std::vector <float> &rhBkgErr =
37  std::vector <float> &rhPGE =
39  std::vector <float> &rhPGEBd =
41  std::vector <int> &rhFlags =
43  const std::vector <int> &timeFlags =
45 
46  if (!oops::allVectorsSameNonZeroSize(rhObs, rhObsErr, rhBkg, rhBkgErr,
47  rhPGE, rhFlags, timeFlags)) {
48  oops::Log::warning() << "At least one vector is the wrong size. "
49  << "Check will not be performed." << std::endl;
50  oops::Log::warning() << "Vector sizes: "
51  << oops::listOfVectorSizes(rhObs, rhObsErr, rhBkg, rhBkgErr,
52  rhPGE, rhFlags, timeFlags)
53  << std::endl;
54  return;
55  }
56 
57  // Probability density of 'bad' observations.
58  std::vector <float> PdBad(numLevelsToCheck, options_.BkCheck_PdBad_rh.value());
59  // Local version of relative humidity background error.
60  std::vector <float> BackgrErrRH(numLevelsToCheck, 0.0);
61  // Local version of relative humidity observation error.
62  std::vector <float> ObErrRH(numLevelsToCheck, 0.0);
63 
64  // Relax QC to take account of long-tailed error distributions.
65  const float sqrt2 = std::sqrt(2.0);
66  for (int jlev = 0; jlev < numLevelsToCheck; ++jlev) {
67  BackgrErrRH[jlev] = missingValueFloat;
68  ObErrRH[jlev] = missingValueFloat;
69  if (rhBkgErr[jlev] != missingValueFloat)
70  BackgrErrRH[jlev] = sqrt2 * rhBkgErr[jlev];
71  if (rhObsErr[jlev] != missingValueFloat)
72  ObErrRH[jlev] = sqrt2 * rhObsErr[jlev];
73  if (timeFlags[jlev])
75  }
76 
77  // Calculate probability of gross error.
79  rhObs,
80  ObErrRH, // Used instead of rhObsErr.
81  rhBkg,
82  BackgrErrRH, // Used instead of rhBkgErr.
83  PdBad,
84  ModelLevels,
85  rhFlags,
86  rhPGE,
87  rhPGEBd,
89  }
90 } // namespace ufo
ufo::ProfileDataHandler
Retrieve and store data for individual profiles. To do this, first the vector of values in the entire...
Definition: ProfileDataHandler.h:40
ProfileCheckBackgroundRelativeHumidity.h
ufo::MetOfficeQCFlags::PermRejectFlag
@ PermRejectFlag
Blacklisted data.
Definition: MetOfficeQCFlags.h:57
ufo::ProfileCheckBase::profileIndices_
const ProfileIndices & profileIndices_
Indices of profile's observations in the entire sample.
Definition: ProfileCheckBase.h:74
ufo::ProfileIndices
Determine indices of observations making up individual profiles. The indices are computed with respec...
Definition: ProfileIndices.h:39
ufo::ProfileCheckBase::profileDataHandler_
ProfileDataHandler & profileDataHandler_
Profile data handler.
Definition: ProfileCheckBase.h:77
ufo::VariableNames::hofx_relative_humidity
static constexpr const char *const hofx_relative_humidity
Definition: VariableNames.h:40
ufo::VariableNames::obserr_relative_humidity
static constexpr const char *const obserr_relative_humidity
Definition: VariableNames.h:29
ufo::ProfileIndices::getNumLevelsToCheck
int getNumLevelsToCheck() const
Return number of levels to which QC checks should be applied.
Definition: ProfileIndices.h:52
ufo::VariableNames::pgebd_relative_humidity
static constexpr const char *const pgebd_relative_humidity
Definition: VariableNames.h:69
ufo::ProfileCheckValidator
Profile QC check validator.
Definition: ProfileCheckValidator.h:27
ufo_radiancerttov_utils_mod::debug
logical, public debug
Definition: ufo_radiancerttov_utils_mod.F90:100
ufo::ProfileConsistencyCheckParameters::PGEParameters
ProbabilityOfGrossErrorParameters PGEParameters
Parameters related to PGE calculations.
Definition: ProfileConsistencyCheckParameters.h:329
ufo::VariableNames::qcflags_relative_humidity
static constexpr const char *const qcflags_relative_humidity
Definition: VariableNames.h:93
ufo::BayesianPGEUpdate
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) for scalar (1D) or vector (2D) observables....
Definition: ProbabilityOfGrossError.cc:11
ufo
Definition: RunCRTM.h:27
ufo::ProfileConsistencyCheckParameters::modellevels
oops::Parameter< bool > modellevels
Have the observation and model values been averaged onto model levels?
Definition: ProfileConsistencyCheckParameters.h:54
ufo::ProfileCheckBackgroundRelativeHumidity::ProfileCheckBackgroundRelativeHumidity
ProfileCheckBackgroundRelativeHumidity(const ProfileConsistencyCheckParameters &options, const ProfileIndices &profileIndices, ProfileDataHandler &profileDataHandler, ProfileCheckValidator &profileCheckValidator)
Definition: ProfileCheckBackgroundRelativeHumidity.cc:16
ufo::ProfileCheckBase
Profile QC checker base class.
Definition: ProfileCheckBase.h:40
ufo::ProfileCheckBase::options_
const ProfileConsistencyCheckParameters & options_
Configurable parameters.
Definition: ProfileCheckBase.h:71
ufo::ProfileConsistencyCheckParameters::BkCheck_PdBad_rh
oops::Parameter< float > BkCheck_PdBad_rh
Prior probability of 'bad' observations for RH.
Definition: ProfileConsistencyCheckParameters.h:269
ufo::ProfileConsistencyCheckParameters::BkCheck_ErrVarMax_rh
oops::Parameter< float > BkCheck_ErrVarMax_rh
Maximum error variance for RH.
Definition: ProfileConsistencyCheckParameters.h:295
ufo::ProfileCheckBase::missingValueFloat
const float missingValueFloat
Missing value (float)
Definition: ProfileCheckBase.h:83
ufo::ProfileCheckBackgroundRelativeHumidity::runCheck
void runCheck() override
Run check.
Definition: ProfileCheckBackgroundRelativeHumidity.cc:23
ufo::VariableNames::bkgerr_relative_humidity
static constexpr const char *const bkgerr_relative_humidity
Definition: VariableNames.h:48
ufo::VariableNames::qcflags_time
static constexpr const char *const qcflags_time
Definition: VariableNames.h:97
ufo::ProfileConsistencyCheckParameters
Options controlling the operation of the ProfileConsistencyChecks filter.
Definition: ProfileConsistencyCheckParameters.h:33
ufo::makerProfileCheckBackgroundRelativeHumidity_
static ProfileCheckMaker< ProfileCheckBackgroundRelativeHumidity > makerProfileCheckBackgroundRelativeHumidity_("BackgroundRelativeHumidity")
ufo::VariableNames::obs_relative_humidity
static constexpr const char *const obs_relative_humidity
Definition: VariableNames.h:20
ufo::ProfileDataHandler::get
std::vector< T > & get(const std::string &fullname)
Definition: ProfileDataHandler.h:53
ufo::VariableNames::pge_relative_humidity
static constexpr const char *const pge_relative_humidity
Definition: VariableNames.h:58