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 
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 temperature" << std::endl;
26 
27  const size_t numLevelsToCheck = profileIndices_.getNumLevelsToCheck();
28  const bool ModelLevels = options_.modellevels.value();
29  const std::vector <float> &Latitude =
31  const std::vector <float> &pressures =
33  const std::vector <float> &tObs =
35  const std::vector <float> &tObsErr =
37  const std::vector <float> &tBkg =
39  const std::vector <float> &tBkgErr =
41  std::vector <float> &tPGE =
43  std::vector <float> &tPGEBd =
45  std::vector <int> &tFlags =
47  const std::vector <int> &timeFlags =
49  const std::vector <float> &tObsCorrection =
51 
52  if (!oops::allVectorsSameNonZeroSize(Latitude, pressures,
53  tObs, tObsErr, tBkg, tBkgErr,
54  tPGE, tFlags, timeFlags, tObsCorrection)) {
55  oops::Log::warning() << "At least one vector is the wrong size. "
56  << "Check will not be performed." << std::endl;
57  oops::Log::warning() << "Vector sizes: "
58  << oops::listOfVectorSizes(Latitude, pressures,
59  tObs, tObsErr, tBkg, tBkgErr,
60  tPGE, tFlags, timeFlags, tObsCorrection)
61  << std::endl;
62  return;
63  }
64 
65  std::vector <float> tObsFinal;
66  correctVector(tObs, tObsCorrection, tObsFinal);
67 
68  // Probability density of 'bad' observations.
69  std::vector <float> PdBad(numLevelsToCheck, options_.BkCheck_PdBad_t.value());
70  // Local version of temperature background error.
71  std::vector <float> BackgrErrT(numLevelsToCheck, 0);
72  for (int jlev = 0; jlev < numLevelsToCheck; ++jlev) {
73  BackgrErrT[jlev] = tBkgErr[jlev];
74  }
75  // Extra representivity error for data on reported levels.
76  if (!ModelLevels) {
77  const float Psplit =
78  std::fabs(Latitude[0]) < options_.BkCheck_Psplit_latitude_tropics ?
81  for (int jlev = 0; jlev < numLevelsToCheck; ++jlev) {
82  if (pressures[jlev] <= Psplit) {
83  BackgrErrT[jlev] = tBkgErr[jlev] == missingValueFloat ?
85  tBkgErr[jlev] * options_.BkCheck_ErrorInflationBelowPsplit.value();
86  } else {
87  BackgrErrT[jlev] = tBkgErr[jlev] == missingValueFloat ?
89  tBkgErr[jlev] * options_.BkCheck_ErrorInflationAbovePsplit.value();
90  }
91  }
92  }
93 
94  // Modify observation PGE if certain flags have been set.
95  for (int jlev = 0; jlev < numLevelsToCheck; ++jlev) {
97  tPGE[jlev] = 0.5 + 0.5 * tPGE[jlev];
99  tPGE[jlev] = 0.5 + 0.5 * tPGE[jlev];
101  tPGE[jlev] = 0.5 + 0.5 * tPGE[jlev];
102  if (timeFlags[jlev])
104  }
105 
106  // Calculate probability of gross error.
108  tObsFinal,
109  tObsErr,
110  tBkg,
111  BackgrErrT, // Used instead of tBkgErr.
112  PdBad,
113  ModelLevels,
114  tFlags,
115  tPGE,
116  tPGEBd);
117  }
118 } // namespace ufo
ProfileCheckBackgroundTemperature.h
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::VariableNames::pgebd_air_temperature
static constexpr const char *const pgebd_air_temperature
Definition: VariableNames.h:67
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::ProfileCheckBase::profileDataHandler_
ProfileDataHandler & profileDataHandler_
Profile data handler.
Definition: ProfileCheckBase.h:77
ufo::ProfileCheckBackgroundTemperature::runCheck
void runCheck() override
Run check.
Definition: ProfileCheckBackgroundTemperature.cc:23
ufo::ProfileIndices::getNumLevelsToCheck
int getNumLevelsToCheck() const
Return number of levels to which QC checks should be applied.
Definition: ProfileIndices.h:52
ufo::VariableNames::bkgerr_air_temperature
static constexpr const char *const bkgerr_air_temperature
Definition: VariableNames.h:47
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::ProfileConsistencyCheckParameters::BkCheck_Psplit_latitude_tropics
oops::Parameter< float > BkCheck_Psplit_latitude_tropics
Definition: ProfileConsistencyCheckParameters.h:277
ufo::VariableNames::pge_air_temperature
static constexpr const char *const pge_air_temperature
Definition: VariableNames.h:57
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
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
ufo::ProfileConsistencyCheckParameters::BkCheck_PdBad_t
oops::Parameter< float > BkCheck_PdBad_t
Prior probability of 'bad' observations for T.
Definition: ProfileConsistencyCheckParameters.h:266
ufo::MetOfficeQCFlags::SuperadiabatFlag
@ SuperadiabatFlag
Superadiabatic check flag.
Definition: MetOfficeQCFlags.h:88
ufo::ProfileCheckBase::options_
const ProfileConsistencyCheckParameters & options_
Configurable parameters.
Definition: ProfileCheckBase.h:71
ufo::ProfileConsistencyCheckParameters::BkCheck_Psplit_tropics
oops::Parameter< float > BkCheck_Psplit_tropics
Pressure threshold above which extra representivity error occurs in tropics (Pa).
Definition: ProfileConsistencyCheckParameters.h:284
ufo::VariableNames::Latitude
static constexpr const char *const Latitude
Definition: VariableNames.h:84
ufo::ProfileCheckBackgroundTemperature::ProfileCheckBackgroundTemperature
ProfileCheckBackgroundTemperature(const ProfileConsistencyCheckParameters &options, const ProfileIndices &profileIndices, ProfileDataHandler &profileDataHandler, ProfileCheckValidator &profileCheckValidator)
Definition: ProfileCheckBackgroundTemperature.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::obserr_air_temperature
static constexpr const char *const obserr_air_temperature
Definition: VariableNames.h:28
ufo::VariableNames::hofx_air_temperature
static constexpr const char *const hofx_air_temperature
Definition: VariableNames.h:38
ufo::VariableNames::qcflags_time
static constexpr const char *const qcflags_time
Definition: VariableNames.h:97
ufo::ProfileConsistencyCheckParameters::BkCheck_Psplit_extratropics
oops::Parameter< float > BkCheck_Psplit_extratropics
Pressure threshold above which extra representivity error occurs in extratropics (Pa).
Definition: ProfileConsistencyCheckParameters.h:281
ufo::ProfileConsistencyCheckParameters
Options controlling the operation of the ProfileConsistencyChecks filter.
Definition: ProfileConsistencyCheckParameters.h:33
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::makerProfileCheckBackgroundTemperature_
static ProfileCheckMaker< ProfileCheckBackgroundTemperature > makerProfileCheckBackgroundTemperature_("BackgroundTemperature")
ufo::VariableNames::obscorrection_air_temperature
static constexpr const char *const obscorrection_air_temperature
Definition: VariableNames.h:120
ufo::MetOfficeQCFlags::HydrostaticFlag
@ HydrostaticFlag
Hydrostatic check flag.
Definition: MetOfficeQCFlags.h:86
ufo::VariableNames::qcflags_air_temperature
static constexpr const char *const qcflags_air_temperature
Definition: VariableNames.h:92
ufo::MetOfficeQCFlags::InterpolationFlag
@ InterpolationFlag
Interpolation check flag.
Definition: MetOfficeQCFlags.h:87
ufo::ProfileConsistencyCheckParameters::BkCheck_ErrorInflationAbovePsplit
oops::Parameter< float > BkCheck_ErrorInflationAbovePsplit
Error inflation factor above Psplit.
Definition: ProfileConsistencyCheckParameters.h:292
ufo::ProfileConsistencyCheckParameters::BkCheck_ErrorInflationBelowPsplit
oops::Parameter< float > BkCheck_ErrorInflationBelowPsplit
Error inflation factor below Psplit.
Definition: ProfileConsistencyCheckParameters.h:288
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