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