UFO
ProfileCheckBackgroundGeopotentialHeight.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<ProfileCheckBackgroundGeopotentialHeight>
13  makerProfileCheckBackgroundGeopotentialHeight_("BackgroundGeopotentialHeight");
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 geopotential height" << std::endl;
26 
27  const size_t numLevelsToCheck = profileIndices_.getNumLevelsToCheck();
28  const bool ModelLevels = options_.modellevels.value();
29  const std::vector <float> &Zstation =
31  const std::vector <float> &pressures =
33  const std::vector <float> &zObs =
35  const std::vector <float> &zObsErr =
37  const std::vector <float> &zBkg =
39  std::vector <float> &zBkgErr =
41  std::vector <float> &zPGE =
43  std::vector <float> &zPGEBd =
45  std::vector <int> &zFlags =
47  const std::vector <int> &tFlags =
49  const std::vector <float> &zObsCorrection =
51  const std::vector <int> &timeFlags =
53 
54  if (!oops::allVectorsSameNonZeroSize(Zstation, pressures,
55  zObs, zObsErr, zBkg,
56  zPGE, zFlags, zObsCorrection,
57  tFlags, timeFlags)) {
58  oops::Log::warning() << "At least one vector is the wrong size. "
59  << "Check will not be performed." << std::endl;
60  oops::Log::warning() << "Vector sizes: "
61  << oops::listOfVectorSizes(Zstation, pressures,
62  zObs, zObsErr, zBkg,
63  zPGE, zFlags, zObsCorrection,
64  tFlags, timeFlags)
65  << std::endl;
66  return;
67  }
68 
69  std::vector <float> zObsFinal;
70  correctVector(zObs, zObsCorrection, zObsFinal);
71 
72  // Probability density of 'bad' observations.
73  std::vector <float> PdBad(numLevelsToCheck, 0);
74  // The z background error may not have been set before this point.
75  if (zBkgErr.empty())
76  zBkgErr.assign(numLevelsToCheck, missingValueFloat);
77  // Background error estimates are taken from ECMWF Research Manual 1
78  // (ECMWF Data Assimilation Scientific Documentation, 3/92, 3rd edition), table 2.1.
79  // They are then multiplied by 1.2.
80  for (int jlev = 0; jlev < numLevelsToCheck; ++jlev) {
81  if (zObsFinal[jlev] != missingValueFloat) {
82  // Permanently reject any levels at/below surface
84  zObsFinal[jlev] <= Zstation[jlev]) {
86  }
87  const float Plevel = pressures[jlev] / 100.0; // hPa
88  const std::vector<float> zBkgErrs = options_.BkCheck_zBkgErrs.value();
89  const std::vector<float> zBadPGEs = options_.BkCheck_zBadPGEs.value();
90  size_t idx = 0;
91  for (const auto& PlevelThreshold : options_.BkCheck_PlevelThresholds.value()) {
92  if (Plevel > PlevelThreshold) {
93  zBkgErr[jlev] = 1.2 * zBkgErrs[idx];
94  PdBad[jlev] = zBadPGEs[idx];
95  break;
96  }
97  idx++;
98  }
99  }
100  }
101 
102  // Modify observation PGE if certain flags have been set.
103  for (int jlev = 0; jlev < numLevelsToCheck; ++jlev) {
105  zPGE[jlev] = 0.5 + 0.5 * zPGE[jlev];
107  zPGE[jlev] = 0.5 + 0.5 * zPGE[jlev];
108  if (timeFlags[jlev])
110  }
111 
112  // Calculate probability of gross error.
114  zObsFinal,
115  zObsErr,
116  zBkg,
117  zBkgErr,
118  PdBad,
119  ModelLevels,
120  zFlags,
121  zPGE,
122  zPGEBd);
123  }
124 } // 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
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::VariableNames::Zstation
static constexpr const char *const Zstation
Definition: VariableNames.h:87
ufo::ProfileCheckBase::profileDataHandler_
ProfileDataHandler & profileDataHandler_
Profile data handler.
Definition: ProfileCheckBase.h:77
ufo::ProfileIndices::getNumLevelsToCheck
int getNumLevelsToCheck() const
Return number of levels to which QC checks should be applied.
Definition: ProfileIndices.h:52
ufo::VariableNames::hofx_geopotential_height
static constexpr const char *const hofx_geopotential_height
Definition: VariableNames.h:39
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::pge_geopotential_height
static constexpr const char *const pge_geopotential_height
Definition: VariableNames.h:62
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::VariableNames::qcflags_geopotential_height
static constexpr const char *const qcflags_geopotential_height
Definition: VariableNames.h:94
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::ProfileCheckBase
Profile QC checker base class.
Definition: ProfileCheckBase.h:40
ProfileCheckBackgroundGeopotentialHeight.h
ufo::ProfileCheckBase::options_
const ProfileConsistencyCheckParameters & options_
Configurable parameters.
Definition: ProfileCheckBase.h:71
ufo::ProfileCheckBackgroundGeopotentialHeight::ProfileCheckBackgroundGeopotentialHeight
ProfileCheckBackgroundGeopotentialHeight(const ProfileConsistencyCheckParameters &options, const ProfileIndices &profileIndices, ProfileDataHandler &profileDataHandler, ProfileCheckValidator &profileCheckValidator)
Definition: ProfileCheckBackgroundGeopotentialHeight.cc:16
ufo::VariableNames::obs_air_pressure
static constexpr const char *const obs_air_pressure
Definition: VariableNames.h:18
ufo::ProfileCheckBase::missingValueFloat
const float missingValueFloat
Missing value (float)
Definition: ProfileCheckBase.h:83
ufo::VariableNames::bkgerr_geopotential_height
static constexpr const char *const bkgerr_geopotential_height
Definition: VariableNames.h:51
ufo::ProfileCheckBackgroundGeopotentialHeight::runCheck
void runCheck() override
Run check.
Definition: ProfileCheckBackgroundGeopotentialHeight.cc:23
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::VariableNames::obscorrection_geopotential_height
static constexpr const char *const obscorrection_geopotential_height
Definition: VariableNames.h:121
ufo::ProfileCheckBase::correctVector
void correctVector(const std::vector< T > &v1, const std::vector< T > &v2, std::vector< T > &vout)
Apply correction to vector of values.
Definition: ProfileCheckBase.h:60
ufo::MetOfficeQCFlags::HydrostaticFlag
@ HydrostaticFlag
Hydrostatic check flag.
Definition: MetOfficeQCFlags.h:86
ufo::VariableNames::obs_geopotential_height
static constexpr const char *const obs_geopotential_height
Definition: VariableNames.h:23
ufo::VariableNames::qcflags_air_temperature
static constexpr const char *const qcflags_air_temperature
Definition: VariableNames.h:92
ufo::ProfileConsistencyCheckParameters::BkCheck_PlevelThresholds
oops::Parameter< std::vector< float > > BkCheck_PlevelThresholds
Definition: ProfileConsistencyCheckParameters.h:299
ufo::MetOfficeQCFlags::InterpolationFlag
@ InterpolationFlag
Interpolation check flag.
Definition: MetOfficeQCFlags.h:87
ufo::ProfileDataHandler::get
std::vector< T > & get(const std::string &fullname)
Definition: ProfileDataHandler.h:53
ufo::makerProfileCheckBackgroundGeopotentialHeight_
static ProfileCheckMaker< ProfileCheckBackgroundGeopotentialHeight > makerProfileCheckBackgroundGeopotentialHeight_("BackgroundGeopotentialHeight")
ufo::VariableNames::pgebd_geopotential_height
static constexpr const char *const pgebd_geopotential_height
Definition: VariableNames.h:75
ufo::ProfileConsistencyCheckParameters::BkCheck_zBkgErrs
oops::Parameter< std::vector< float > > BkCheck_zBkgErrs
Definition: ProfileConsistencyCheckParameters.h:305
ufo::ProfileConsistencyCheckParameters::BkCheck_zBadPGEs
oops::Parameter< std::vector< float > > BkCheck_zBadPGEs
Definition: ProfileConsistencyCheckParameters.h:311
ufo::MetOfficeQCFlags::SurfaceLevelFlag
@ SurfaceLevelFlag
Surface Level.
Definition: MetOfficeQCFlags.h:89
ufo::VariableNames::obserr_geopotential_height
static constexpr const char *const obserr_geopotential_height
Definition: VariableNames.h:32