UFO
ProfileCheckTime.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<ProfileCheckTime>
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() << " Time check" << std::endl;
26 
27  const size_t numLevelsToCheck = profileIndices_.getNumLevelsToCheck();
28  const bool ModelLevels = options_.modellevels.value();
29  const std::vector <int> &ObsType =
31  const std::vector <float> &level_time =
33  const std::vector <float> &pressures =
35  std::vector <int> &uFlags =
37  std::vector <int> &vFlags =
39  std::vector <int> &timeFlags =
41 
42  if (!oops::allVectorsSameNonZeroSize(ObsType, pressures)) {
43  oops::Log::warning() << "At least one vector is the wrong size. "
44  << "Time checks will not be performed." << std::endl;
45  oops::Log::warning() << "Vector sizes: "
46  << oops::listOfVectorSizes(ObsType, pressures)
47  << std::endl;
48  return;
49  }
50 
51  // Flag any observations that appear outside of the current time window.
52  // The variable level_time is equal to the number of seconds relative to
53  // the middle of the time window. level_time is compared to half of the
54  // assimilation window length.
55  const float halfWindowLength = 0.5 * (profileDataHandler_.getObsdb().windowEnd() -
56  profileDataHandler_.getObsdb().windowStart()).toSeconds();
57  timeFlags.assign(numLevelsToCheck, false);
58  if (!level_time.empty() && !ModelLevels) {
59  for (size_t jlev = 0; jlev < numLevelsToCheck; ++jlev) {
60  const float leveltime = level_time[jlev];
61  if (leveltime == missingValueFloat) continue;
62  timeFlags[jlev] = (leveltime < (-halfWindowLength - 0.5) ||
63  leveltime > (halfWindowLength - 0.5));
64  }
65  }
66 
67  // Reject sonde wind values for short period after launch.
68  const float SondeLaunchWindRej = options_.TimeCheck_SondeLaunchWindRej.value();
69  // Firstly determine surface pressure.
70  float PSurf = 0.0;
71  if (!uFlags.empty() && SondeLaunchWindRej > 0.0 &&
72  !ModelLevels &&
74  PSurf = pressures[0];
75  for (size_t jlev = 0;
76  jlev < std::min(static_cast<int>(numLevelsToCheck), 10);
77  ++jlev) {
79  PSurf = pressures[jlev];
80  break;
81  }
82  }
83  }
84 
85  // If surface pressure is nonzero, perform the wind rejection.
86  if (PSurf > 0.0) {
87  int NWindRej = 0; // Number of wind levels rejected
88  const float PLimit = PSurf - SondeLaunchWindRej * 100.0; // Convert from hPa to Pa
89  for (size_t jlev = 0; jlev < numLevelsToCheck; ++jlev) {
90  if (pressures[jlev] > 0.0 && pressures[jlev] < PLimit) break;
91  if (!uFlags.empty()) uFlags[jlev] |= ufo::MetOfficeQCFlags::Elem::PermRejectFlag;
92  if (!vFlags.empty()) vFlags[jlev] |= ufo::MetOfficeQCFlags::Elem::PermRejectFlag;
93  NWindRej++;
94  }
95  oops::Log::debug() << "Wind rejection: "
96  << "Psurf = " << PSurf * 0.01 << " hPa, "
97  << "NWindRej = " << NWindRej << std::endl;
98  }
99  }
100 } // namespace ufo
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::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::ProfileDataHandler::getObsdb
ioda::ObsSpace & getObsdb()
Return obsdb.
Definition: ProfileDataHandler.h:136
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::VariableNames::qcflags_northward_wind
static constexpr const char *const qcflags_northward_wind
Definition: VariableNames.h:96
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::ProfileConsistencyCheckParameters::TimeCheck_SondeLaunchWindRej
oops::Parameter< float > TimeCheck_SondeLaunchWindRej
Threshold relative to surface pressure for rejecting levels (hPa)
Definition: ProfileConsistencyCheckParameters.h:258
ufo::ProfileCheckTime::ProfileCheckTime
ProfileCheckTime(const ProfileConsistencyCheckParameters &options, const ProfileIndices &profileIndices, ProfileDataHandler &profileDataHandler, ProfileCheckValidator &profileCheckValidator)
Definition: ProfileCheckTime.cc:16
ufo::makerProfileCheckTime_
static ProfileCheckMaker< ProfileCheckTime > makerProfileCheckTime_("Time")
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::ProfileCheckTime::runCheck
void runCheck() override
Run check.
Definition: ProfileCheckTime.cc:23
ufo::ProfileCheckBase::options_
const ProfileConsistencyCheckParameters & options_
Configurable parameters.
Definition: ProfileCheckBase.h:71
ufo::VariableNames::obs_level_time
static constexpr const char *const obs_level_time
Definition: VariableNames.h:81
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::MetOfficeObsIDs::WindProf
@ WindProf
wind profiler
Definition: MetOfficeObservationIDs.h:275
ufo::VariableNames::qcflags_time
static constexpr const char *const qcflags_time
Definition: VariableNames.h:97
ufo::ProfileConsistencyCheckParameters
Options controlling the operation of the ProfileConsistencyChecks filter.
Definition: ProfileConsistencyCheckParameters.h:33
ProfileCheckTime.h
ufo::VariableNames::ObsType
static constexpr const char *const ObsType
Definition: VariableNames.h:83
ufo::ProfileDataHandler::get
std::vector< T > & get(const std::string &fullname)
Definition: ProfileDataHandler.h:53
ufo::MetOfficeQCFlags::SurfaceLevelFlag
@ SurfaceLevelFlag
Surface Level.
Definition: MetOfficeQCFlags.h:89