UFO
ProfileCheckBasic.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 
10 
11 namespace ufo {
12 
14 
16  : ProfileCheckBase(options)
17  {}
18 
20  {
21  oops::Log::debug() << " Basic checks" << std::endl;
22 
23  // Set basic check result to true
24  result_ = true;
25 
26  // Skip this routine if specifically requested
27  if (options_.BChecks_Skip.value())
28  {
29  oops::Log::debug() << "Skipping basic checks" << std::endl;
30  return;
31  }
32 
33  const int numProfileLevels = profileDataHandler.getNumProfileLevels();
34  const std::vector <float> &pressures =
35  profileDataHandler.get<float>(ufo::VariableNames::obs_air_pressure);
36  // All QC flags are retrieved for the basic checks.
37  // (Some might be empty; that is checked before they are used.)
38  std::vector <int> &tFlags = profileDataHandler.get<int>
40  std::vector <int> &zFlags = profileDataHandler.get<int>
42  std::vector <int> &uFlags = profileDataHandler.get<int>
44 
45  // Warn and exit if pressures vector is empty
46  if (pressures.empty()) {
47  result_ = false;
48  oops::Log::debug() << "Pressures vector is empty" << std::endl;
49  return;
50  }
51 
52  // Is the number of levels to check OK?
53  bool numProfileLevelsOK = (numProfileLevels > 0);
54 
55  // Are any levels in the wrong order?
56  bool pressOrderOK = true;
57  for (int jlev = 0; jlev < numProfileLevels - 1; ++jlev) {
58  pressOrderOK = pressOrderOK && (pressures[jlev] >= pressures[jlev + 1]);
59  if (!pressOrderOK) break;
60  }
61 
62  // Is the pressure at the first level > maximum value pressure?
63  bool maxPressOK = (pressures.size() > 0 ?
64  pressures.front() <= options_.BChecks_maxValidP.value() :
65  false);
66 
67  // Is the pressure at the final level < minimum value pressure?
68  bool minPressOK = (pressures.size() > 0 ?
69  pressures.back() > options_.BChecks_minValidP.value() :
70  false);
71 
72  oops::Log::debug() << " -> numProfileLevelsOK: " << numProfileLevelsOK << std::endl;
73  oops::Log::debug() << " -> pressOrderOK: " << pressOrderOK << std::endl;
74  oops::Log::debug() << " -> maxPressOK: " << maxPressOK << std::endl;
75  oops::Log::debug() << " -> minPressOK: " << minPressOK << std::endl;
76 
77  result_ = numProfileLevelsOK && pressOrderOK && maxPressOK && minPressOK;
78  oops::Log::debug() << " -> basicResult: " << result_ << std::endl;
79 
80  // If the basic checks are failed, set reject flags
81  // This is not done in the OPS sonde consistency checks, but is done in Ops_SondeAverage.inc
82  if (options_.flagBasicChecksFail.value() && !result_) {
83  for (int jlev = 0; jlev < numProfileLevels; ++jlev) {
84  if (!tFlags.empty()) tFlags[jlev] |= ufo::MetOfficeQCFlags::Elem::FinalRejectFlag;
85  if (!zFlags.empty()) zFlags[jlev] |= ufo::MetOfficeQCFlags::Elem::FinalRejectFlag;
86  if (!uFlags.empty()) uFlags[jlev] |= ufo::MetOfficeQCFlags::Elem::FinalRejectFlag;
87  }
88  }
89  }
90 } // namespace ufo
91 
Options controlling the operation of the ConventionalProfileProcessing filter.
oops::Parameter< float > BChecks_maxValidP
Maximum value of pressure (Pa)
oops::Parameter< float > BChecks_minValidP
Minimum value of pressure (Pa)
oops::Parameter< bool > flagBasicChecksFail
Set flags for failed basic checks?
Profile QC checker base class.
const ConventionalProfileProcessingParameters & options_
Configurable parameters.
ProfileCheckBasic(const ConventionalProfileProcessingParameters &options)
bool result_
Result of basic checks.
void runCheck(ProfileDataHandler &profileDataHandler) override
Run check.
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.
@ FinalRejectFlag
Final QC flag.
Definition: RunCRTM.h:27
static ProfileCheckMaker< ProfileCheckBasic > makerProfileCheckBasic_("Basic")
static constexpr const char *const qcflags_eastward_wind
static constexpr const char *const obs_air_pressure
Definition: VariableNames.h:18
static constexpr const char *const qcflags_air_temperature
Definition: VariableNames.h:99
static constexpr const char *const qcflags_geopotential_height