UFO
ProfileCheckSign.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() << " Sign check/correction" << std::endl;
25 
26  const int numLevelsToCheck = profileIndices_.getNumLevelsToCheck();
27 
28  const std::vector <float> &pressures =
30  const std::vector <float> &tObs =
32  const std::vector <float> &tBkg =
34  const std::vector <float> &PstarBackgr =
36  std::vector <int> &tFlags =
38  std::vector <int> &NumAnyErrors =
40  std::vector <int> &NumSignChange =
42  std::vector <float> &tObsCorrection =
44 
45  if (!oops::allVectorsSameNonZeroSize(pressures, tObs, tBkg, PstarBackgr,
46  tFlags, tObsCorrection)) {
47  oops::Log::warning() << "At least one vector is the wrong size. "
48  << "Check will not be performed." << std::endl;
49  oops::Log::warning() << "Vector sizes: "
50  << oops::listOfVectorSizes(pressures, tObs, tBkg, PstarBackgr,
51  tFlags, tObsCorrection)
52  << std::endl;
53  return;
54  }
55 
56  for (int jlev = 0; jlev < numLevelsToCheck; ++jlev) {
57  // Ignore this level if it has been flagged as rejected.
58  if (tFlags[jlev] & ufo::MetOfficeQCFlags::Elem::FinalRejectFlag) continue;
59  if (pressures[jlev] <= PstarBackgr[jlev] - options_.SCheck_PstarThresh.value() &&
60  tObs[jlev] != missingValueFloat &&
61  std::abs(tObs[jlev] - tBkg[jlev]) >= options_.SCheck_tObstBkgThresh.value()) {
62  // Change sign of tObs in C and compare to tBkg (also in C)
63  if (std::abs(2.0 * ufo::Constants::t0c - tObs[jlev] - tBkg[jlev]) <
65  NumAnyErrors[0]++;
66  NumSignChange[0]++;
67 
69 
70  oops::Log::debug() << " -> Failed sign check for level " << jlev << std::endl;
71  oops::Log::debug() << " -> P = " << pressures[jlev] * 0.01 << "hPa, tObs = "
72  << ufo::Constants::t0c - tObs[jlev] << "C, tBkg = "
73  << tBkg[jlev] - ufo::Constants::t0c << "C" << std::endl;
74 
75  if (options_.SCheck_CorrectT.value()) {
76  // Corrected T is 2 * t0c - T (all quantities in K).
77  // The correction is 2 * (t0c - T).
78  tObsCorrection[jlev] = 2.0 * (ufo::Constants::t0c - tObs[jlev]);
79 
80  oops::Log::debug() << " -> Uncorrected tObs: " << tObs[jlev] << "C" << std::endl;
81  oops::Log::debug() << " tObs correction: "
82  << tObsCorrection[jlev] << "C" << std::endl;
83  oops::Log::debug() << " Corrected tObs: "
84  << tObs[jlev] + tObsCorrection[jlev] << "C" << std::endl;
85  } else {
86  // Observation is rejected
88  }
89  } else if (pressures[jlev] > options_.SCheck_PrintLargeTThresh.value()) {
90  // Print out information on other large T differences
91  oops::Log::debug() << " -> Passed test but have large T difference for level "
92  << jlev << ": "
93  << "P = " << pressures[jlev] * 0.01 << "hPa, tObs = "
94  << tObs[jlev] - ufo::Constants::t0c << "C, tBkg = "
95  << tBkg[jlev] - ufo::Constants::t0c << "C" << std::endl;
96  }
97  }
98  }
99  }
100 } // namespace ufo
101 
ufo::VariableNames::counter_NumAnyErrors
static constexpr const char *const counter_NumAnyErrors
Definition: VariableNames.h:101
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::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::ProfileIndices::getNumLevelsToCheck
int getNumLevelsToCheck() const
Return number of levels to which QC checks should be applied.
Definition: ProfileIndices.h:52
ufo::ProfileConsistencyCheckParameters::SCheck_PstarThresh
oops::Parameter< float > SCheck_PstarThresh
Threshold used for Pstar difference in sign check (Pa)
Definition: ProfileConsistencyCheckParameters.h:102
ufo::Constants::t0c
static constexpr double t0c
Definition: Constants.h:24
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::ProfileCheckMaker
Definition: ProfileCheckBase.h:113
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::ProfileCheckSign::runCheck
void runCheck() override
Run check.
Definition: ProfileCheckSign.cc:22
ufo::ProfileConsistencyCheckParameters::SCheck_PrintLargeTThresh
oops::Parameter< float > SCheck_PrintLargeTThresh
P threshold over which to print large T differences (Pa)
Definition: ProfileConsistencyCheckParameters.h:111
ufo::ProfileConsistencyCheckParameters::SCheck_CorrectT
oops::Parameter< bool > SCheck_CorrectT
Correct tObs in the sign check?
Definition: ProfileConsistencyCheckParameters.h:114
ProfileCheckSign.h
ufo::makerProfileCheckSign_
static ProfileCheckMaker< ProfileCheckSign > makerProfileCheckSign_("Sign")
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::hofx_air_temperature
static constexpr const char *const hofx_air_temperature
Definition: VariableNames.h:38
ufo::abs
util::Duration abs(const util::Duration &duration)
Definition: TrackCheckUtils.h:31
ufo::ProfileConsistencyCheckParameters
Options controlling the operation of the ProfileConsistencyChecks filter.
Definition: ProfileConsistencyCheckParameters.h:33
ufo::VariableNames::PstarBackgr
static constexpr const char *const PstarBackgr
Definition: VariableNames.h:82
ufo::VariableNames::counter_NumSignChange
static constexpr const char *const counter_NumSignChange
Definition: VariableNames.h:111
ufo::VariableNames::obscorrection_air_temperature
static constexpr const char *const obscorrection_air_temperature
Definition: VariableNames.h:120
ufo::ProfileCheckSign::ProfileCheckSign
ProfileCheckSign(const ProfileConsistencyCheckParameters &options, const ProfileIndices &profileIndices, ProfileDataHandler &profileDataHandler, ProfileCheckValidator &profileCheckValidator)
Definition: ProfileCheckSign.cc:15
ufo::VariableNames::qcflags_air_temperature
static constexpr const char *const qcflags_air_temperature
Definition: VariableNames.h:92
ufo::ProfileConsistencyCheckParameters::SCheck_ProfileSignTol
oops::Parameter< float > SCheck_ProfileSignTol
Tolerance used for sign check (K)
Definition: ProfileConsistencyCheckParameters.h:108
ufo::MetOfficeQCFlags::FinalRejectFlag
@ FinalRejectFlag
Final QC flag.
Definition: MetOfficeQCFlags.h:54
ufo::ProfileConsistencyCheckParameters::SCheck_tObstBkgThresh
oops::Parameter< float > SCheck_tObstBkgThresh
Threshold used for |tObs - tBkg| in sign check (K)
Definition: ProfileConsistencyCheckParameters.h:105
VariableNames.h
ufo::ProfileDataHandler::get
std::vector< T > & get(const std::string &fullname)
Definition: ProfileDataHandler.h:53
ufo::VariableNames::obs_air_temperature
static constexpr const char *const obs_air_temperature
Definition: VariableNames.h:19
ufo::MetOfficeQCFlags::DataCorrectFlag
@ DataCorrectFlag
Eg sign correction.
Definition: MetOfficeQCFlags.h:63