UFO
ProfileCheckBackgroundTemperature.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<ProfileCheckBackgroundTemperature>
13  makerProfileCheckBackgroundTemperature_("BackgroundTemperature");
14 
17  : ProfileCheckBase(options)
18  {}
19 
21  {
22  oops::Log::debug() << " Background check for temperature" << std::endl;
23 
24  const size_t numProfileLevels = profileDataHandler.getNumProfileLevels();
25  const bool ModelLevels = options_.modellevels.value();
26  const std::vector <float> &Latitude =
27  profileDataHandler.get<float>(ufo::VariableNames::Latitude);
28  const std::vector <float> &pressures =
29  profileDataHandler.get<float>(ufo::VariableNames::obs_air_pressure);
30  const std::vector <float> &tObs =
31  profileDataHandler.get<float>(ufo::VariableNames::obs_air_temperature);
32  const std::vector <float> &tObsErr =
33  profileDataHandler.get<float>(ufo::VariableNames::obserr_air_temperature);
34  const std::vector <float> &tBkg =
35  profileDataHandler.get<float>(ufo::VariableNames::hofx_air_temperature);
36  const std::vector <float> &tBkgErr =
38  std::vector <float> &tPGE =
39  profileDataHandler.get<float>(ufo::VariableNames::pge_air_temperature);
40  std::vector <float> &tPGEBd =
41  profileDataHandler.get<float>(ufo::VariableNames::pgebd_air_temperature);
42  std::vector <int> &tFlags =
43  profileDataHandler.get<int>(ufo::VariableNames::qcflags_air_temperature);
44  const std::vector <int> &timeFlags =
45  profileDataHandler.get<int>(ufo::VariableNames::qcflags_time);
46  const std::vector <float> &tObsCorrection =
47  profileDataHandler.get<float>(ufo::VariableNames::obscorrection_air_temperature);
48 
49  if (!oops::allVectorsSameNonZeroSize(Latitude, pressures,
50  tObs, tObsErr, tBkg, tBkgErr,
51  tPGE, tFlags, timeFlags, tObsCorrection)) {
52  oops::Log::warning() << "At least one vector is the wrong size. "
53  << "Check will not be performed." << std::endl;
54  oops::Log::warning() << "Vector sizes: "
55  << oops::listOfVectorSizes(Latitude, pressures,
56  tObs, tObsErr, tBkg, tBkgErr,
57  tPGE, tFlags, timeFlags, tObsCorrection)
58  << std::endl;
59  return;
60  }
61 
62  std::vector <float> tObsFinal;
63  correctVector(tObs, tObsCorrection, tObsFinal);
64 
65  // Probability density of 'bad' observations.
66  std::vector <float> PdBad(numProfileLevels, options_.BkCheck_PdBad_t.value());
67  // Local version of temperature background error.
68  std::vector <float> BackgrErrT(numProfileLevels, 0);
69  for (int jlev = 0; jlev < numProfileLevels; ++jlev) {
70  BackgrErrT[jlev] = tBkgErr[jlev];
71  }
72  // Extra representivity error for data on reported levels.
73  if (!ModelLevels) {
74  const float Psplit =
75  std::fabs(Latitude[0]) < options_.BkCheck_Psplit_latitude_tropics ?
78  for (int jlev = 0; jlev < numProfileLevels; ++jlev) {
79  if (pressures[jlev] <= Psplit) {
80  BackgrErrT[jlev] = tBkgErr[jlev] == missingValueFloat ?
82  tBkgErr[jlev] * options_.BkCheck_ErrorInflationBelowPsplit.value();
83  } else {
84  BackgrErrT[jlev] = tBkgErr[jlev] == missingValueFloat ?
86  tBkgErr[jlev] * options_.BkCheck_ErrorInflationAbovePsplit.value();
87  }
88  }
89  }
90 
91  // Modify observation PGE if certain flags have been set.
92  for (int jlev = 0; jlev < numProfileLevels; ++jlev) {
94  tPGE[jlev] = 0.5 + 0.5 * tPGE[jlev];
96  tPGE[jlev] = 0.5 + 0.5 * tPGE[jlev];
98  tPGE[jlev] = 0.5 + 0.5 * tPGE[jlev];
99  if (timeFlags[jlev])
101  }
102 
103  // Calculate probability of gross error.
105  tObsFinal,
106  tObsErr,
107  tBkg,
108  BackgrErrT, // Used instead of tBkgErr.
109  PdBad,
110  ModelLevels,
111  tFlags,
112  tPGE,
113  tPGEBd);
114  }
115 } // namespace ufo
Options controlling the operation of the ConventionalProfileProcessing filter.
oops::Parameter< float > BkCheck_Psplit_extratropics
Pressure threshold above which extra representivity error occurs in extratropics (Pa).
oops::Parameter< float > BkCheck_Psplit_tropics
Pressure threshold above which extra representivity error occurs in tropics (Pa).
oops::Parameter< float > BkCheck_ErrorInflationAbovePsplit
Error inflation factor above Psplit.
oops::Parameter< float > BkCheck_PdBad_t
Prior probability of 'bad' observations for T.
ProbabilityOfGrossErrorParameters PGEParameters
Parameters related to PGE calculations.
oops::Parameter< bool > modellevels
Have the observation and model values been averaged onto model levels?
oops::Parameter< float > BkCheck_ErrorInflationBelowPsplit
Error inflation factor below Psplit.
void runCheck(ProfileDataHandler &profileDataHandler) override
Run check.
ProfileCheckBackgroundTemperature(const ConventionalProfileProcessingParameters &options)
Profile QC checker base class.
const float missingValueFloat
Missing value (float)
const ConventionalProfileProcessingParameters & options_
Configurable parameters.
void correctVector(const std::vector< T > &v1, const std::vector< T > &v2, std::vector< T > &vout)
Apply correction to vector of values.
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.
std::vector< float > & getObsDiag(const std::string &variableName)
Get ObsDiags for a particular profile.
@ InterpolationFlag
Interpolation check flag.
@ SuperadiabatFlag
Superadiabatic check flag.
@ HydrostaticFlag
Hydrostatic check flag.
@ PermRejectFlag
Blacklisted data.
Definition: RunCRTM.h:27
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)
static ProfileCheckMaker< ProfileCheckBackgroundTemperature > makerProfileCheckBackgroundTemperature_("BackgroundTemperature")
static constexpr const char *const obserr_air_temperature
Definition: VariableNames.h:28
static constexpr const char *const hofx_air_temperature
Definition: VariableNames.h:38
static constexpr const char *const obs_air_temperature
Definition: VariableNames.h:19
static constexpr const char *const Latitude
Definition: VariableNames.h:88
static constexpr const char *const pge_air_temperature
Definition: VariableNames.h:62
static constexpr const char *const pgebd_air_temperature
Definition: VariableNames.h:72
static constexpr const char *const qcflags_time
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 obscorrection_air_temperature
static constexpr const char *const bkgerr_air_temperature
Definition: VariableNames.h:47