UFO
ProfileCheckBackgroundWindSpeed.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<ProfileCheckBackgroundWindSpeed>
13  makerProfileCheckBackgroundWindSpeed_("BackgroundWindSpeed");
14 
17  : ProfileCheckBase(options)
18  {}
19 
21  {
22  oops::Log::debug() << " Background check for wind velocity" << std::endl;
23 
24  const size_t numProfileLevels = profileDataHandler.getNumProfileLevels();
25  const bool ModelLevels = options_.modellevels.value();
26  const std::vector <float> &uObs =
27  profileDataHandler.get<float>(ufo::VariableNames::obs_eastward_wind);
28  const std::vector <float> &uObsErr =
29  profileDataHandler.get<float>(ufo::VariableNames::obserr_eastward_wind);
30  const std::vector <float> &uBkg =
31  profileDataHandler.get<float>(ufo::VariableNames::hofx_eastward_wind);
32  const std::vector <float> &uBkgErr =
34  std::vector <float> &uPGE =
35  profileDataHandler.get<float>(ufo::VariableNames::pge_eastward_wind);
36  std::vector <float> &uPGEBd =
37  profileDataHandler.get<float>(ufo::VariableNames::pgebd_eastward_wind);
38  std::vector <int> &uFlags =
39  profileDataHandler.get<int>(ufo::VariableNames::qcflags_eastward_wind);
40  const std::vector <float> &vObs =
41  profileDataHandler.get<float>(ufo::VariableNames::obs_northward_wind);
42  const std::vector <float> &vObsErr =
43  profileDataHandler.get<float>(ufo::VariableNames::obserr_northward_wind);
44  const std::vector <float> &vBkg =
45  profileDataHandler.get<float>(ufo::VariableNames::hofx_northward_wind);
46  const std::vector <float> &vBkgErr =
48  std::vector <float> &vPGE =
49  profileDataHandler.get<float>(ufo::VariableNames::pge_northward_wind);
50  std::vector <float> &vPGEBd =
51  profileDataHandler.get<float>(ufo::VariableNames::pgebd_northward_wind);
52  std::vector <int> &vFlags =
53  profileDataHandler.get<int>(ufo::VariableNames::qcflags_northward_wind);
54  const std::vector <int> &timeFlags =
55  profileDataHandler.get<int>(ufo::VariableNames::qcflags_time);
56 
57  if (!oops::allVectorsSameNonZeroSize(uObs, uObsErr, uBkg, uBkgErr,
58  uPGE, uFlags,
59  vObs, vObsErr, vBkg, vBkgErr,
60  vPGE, vFlags, timeFlags)) {
61  oops::Log::warning() << "At least one vector is the wrong size. "
62  << "Check will not be performed." << std::endl;
63  oops::Log::warning() << "Vector sizes: "
64  << oops::listOfVectorSizes(uObs, uObsErr, uBkg, uBkgErr,
65  uPGE, uFlags,
66  vObs, vObsErr, vBkg, vBkgErr,
67  vPGE, vFlags, timeFlags)
68  << std::endl;
69  return;
70  }
71 
72  // Probability density of 'bad' observations.
73  std::vector <float> PdBad(numProfileLevels, options_.BkCheck_PdBad_uv.value());
74 
75  // Modify observation PGE if certain flags have been set.
76  for (int jlev = 0; jlev < numProfileLevels; ++jlev) {
78  uPGE[jlev] = 0.5 + 0.5 * uPGE[jlev];
79  if (timeFlags[jlev])
81  }
82 
83  // Calculate probability of gross error.
85  uObs,
86  uObsErr,
87  uBkg,
88  uBkgErr,
89  PdBad,
90  ModelLevels,
91  uFlags,
92  uPGE,
93  uPGEBd,
94  -1,
95  &vObs,
96  &vBkg);
97 
98  // Update v PGE and flags.
99  vPGE = uPGE;
100  vFlags = uFlags;
101  vPGEBd = uPGEBd;
102  }
103 } // namespace ufo
Options controlling the operation of the ConventionalProfileProcessing filter.
oops::Parameter< float > BkCheck_PdBad_uv
Prior probability of 'bad' observations for u and v.
ProbabilityOfGrossErrorParameters PGEParameters
Parameters related to PGE calculations.
oops::Parameter< bool > modellevels
Have the observation and model values been averaged onto model levels?
void runCheck(ProfileDataHandler &profileDataHandler) override
Run check.
ProfileCheckBackgroundWindSpeed(const ConventionalProfileProcessingParameters &options)
Profile QC checker base class.
const ConventionalProfileProcessingParameters & options_
Configurable parameters.
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.
@ PermRejectFlag
Blacklisted data.
Definition: RunCRTM.h:27
static ProfileCheckMaker< ProfileCheckBackgroundWindSpeed > makerProfileCheckBackgroundWindSpeed_("BackgroundWindSpeed")
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 constexpr const char *const bkgerr_eastward_wind
Definition: VariableNames.h:51
static constexpr const char *const qcflags_eastward_wind
static constexpr const char *const bkgerr_northward_wind
Definition: VariableNames.h:53
static constexpr const char *const obserr_eastward_wind
Definition: VariableNames.h:30
static constexpr const char *const hofx_northward_wind
Definition: VariableNames.h:42
static constexpr const char *const qcflags_northward_wind
static constexpr const char *const pge_northward_wind
Definition: VariableNames.h:66
static constexpr const char *const pgebd_northward_wind
Definition: VariableNames.h:78
static constexpr const char *const obs_northward_wind
Definition: VariableNames.h:22
static constexpr const char *const obs_eastward_wind
Definition: VariableNames.h:21
static constexpr const char *const qcflags_time
static constexpr const char *const hofx_eastward_wind
Definition: VariableNames.h:41
static constexpr const char *const pgebd_eastward_wind
Definition: VariableNames.h:76
static constexpr const char *const obserr_northward_wind
Definition: VariableNames.h:31
static constexpr const char *const pge_eastward_wind
Definition: VariableNames.h:65