22 static ProfileCheckMaker<ProfileAverageRelativeHumidity>
35 std::vector <std::string> variableNamesInt =
41 std::vector <std::string> variableNamesFloat =
50 std::vector <std::string> variableNamesGeoVaLs =
54 variableNamesInt.insert
55 (variableNamesInt.end(),
57 std::string(ufo::VariableNames::modellevels_average_relative_humidity_qcflags)});
58 variableNamesFloat.insert
59 (variableNamesFloat.end(),
61 std::string(ufo::VariableNames::modellevels_average_relative_humidity_derived)});
62 variableNamesGeoVaLs.insert
63 (variableNamesGeoVaLs.end(),
64 {ufo::VariableNames::geovals_average_relative_humidity,
65 ufo::VariableNames::geovals_average_relative_humidity_qcflags});
68 std::vector <ProfileDataHolder> profiles =
78 const size_t halfnprofs = profileDataHandler.
getObsdb().nrecs() / 2;
79 for (
size_t jprof = 0; jprof < halfnprofs; ++jprof) {
80 oops::Log::debug() <<
" Profile " << (jprof + 1) <<
" / " << halfnprofs << std::endl;
81 auto& profileOriginal = profiles[jprof];
82 auto& profileExtended = profiles[jprof + halfnprofs];
89 for (
size_t jprof = 0; jprof < halfnprofs * 2; ++jprof) {
108 if (numProfileLevels <= 1)
111 const std::vector <float> &rhObs =
113 std::vector <float> &rhPGEBd =
115 std::vector <int> &rhFlags =
118 const std::vector <int> &InstrType =
120 std::vector <int> &NumGapsRH =
123 if (!oops::allVectorsSameNonZeroSize(rhObs, rhPGEBd, rhFlags)) {
124 oops::Log::warning() <<
"At least one vector is the wrong size. "
125 <<
"Relative humidity averaging will not be performed." << std::endl;
126 oops::Log::warning() <<
"Vector sizes: "
127 << oops::listOfVectorSizes(rhObs,
137 std::vector <float> &geovals_relative_humidity =
139 if (geovals_relative_humidity.empty())
140 throw eckit::BadValue(
"GeoVaLs vector is empty.", Here());
143 const std::vector <float> &LogPA =
145 const std::vector <float> &LogPB =
147 const std::vector <float> &RepLogP =
149 const std::vector <float> &BigGap =
151 if (LogPA.empty() || LogPB.empty() ||
152 !oops::allVectorsSameNonZeroSize(RepLogP, BigGap)) {
153 std::stringstream errorMessage;
154 errorMessage <<
"At least one model-level vector is the wrong size. "
155 <<
"Ensure that the AveragePressure routine has been run before this one."
157 errorMessage <<
"Vector sizes: "
158 << oops::listOfVectorSizes(LogPA, LogPB,
161 throw eckit::BadValue(errorMessage.str(), Here());
166 for (
size_t jlev = 0; jlev < numProfileLevels; ++jlev)
175 const std::vector <float> &LogPmodel = RHinterp ? LogPB : LogPA;
179 std::vector <float> rhModObs;
180 std::vector <int> rhFlagsModObs;
198 if (NumGaps > 0) NumGapsRH[0]++;
201 for (
size_t mlev = 0; mlev < geovals_relative_humidity.size(); ++mlev)
207 const std::vector <float> &tModObs =
208 profileExtended.
get<
float>
210 if (!tModObs.empty()) {
217 if (!InstrType.empty()) {
218 const int profileInstr = InstrType[0];
220 if (InstrTThresholds.find(profileInstr) != InstrTThresholds.end())
221 SondeRHminT = InstrTThresholds.at(profileInstr);
225 bool RejectRH =
false;
226 for (
int mlev = 0; mlev < tModObs.size(); ++mlev) {
238 profileExtended.
set<
float>
242 profileExtended.
set<
int>
252 std::move(
profile.getGeoVaLVector
257 const std::vector <float>& average_relative_humidity_qcflags_float =
260 std::vector <int> average_relative_humidity_qcflags_int
261 (average_relative_humidity_qcflags_float.begin(),
262 average_relative_humidity_qcflags_float.end());
263 std::replace(average_relative_humidity_qcflags_int.begin(),
264 average_relative_humidity_qcflags_int.end(),
269 std::move(average_relative_humidity_qcflags_int));
Options controlling the operation of the ConventionalProfileProcessing filter.
oops::Parameter< std::map< int, float > > AvgRH_InstrTThresholds
oops::Parameter< float > AvgRH_PGEskip
oops::Parameter< bool > compareWithOPS
Compare with OPS values?
oops::Parameter< bool > AvgRH_Interp
Perform interpolation or averaging of relative humidity observations?
oops::Parameter< float > AvgRH_AvgTThreshold
oops::Parameter< float > AvgRH_SondeDZFraction
void runCheck(ProfileDataHandler &profileDataHandler) override
ProfileAverageRelativeHumidity(const ConventionalProfileProcessingParameters &options)
void runCheckOnProfiles(ProfileDataHolder &profileOriginal, ProfileDataHolder &profileExtended)
void fillValidationData(ProfileDataHolder &profileDataHolder)
Fill variables in validator (for comparison with OPS output).
Profile QC checker base class.
const float missingValueFloat
Missing value (float)
const ConventionalProfileProcessingParameters & options_
Configurable parameters.
Retrieve and store data for individual profiles. To do this, first the vector of values in the entire...
void updateAllProfiles(std::vector< ProfileDataHolder > &profiles)
Read values from a collection of profiles and update information related to each one.
std::vector< ProfileDataHolder > produceProfileVector(const std::vector< std::string > &variableNamesInt, const std::vector< std::string > &variableNamesFloat, const std::vector< std::string > &variableNamesString, const std::vector< std::string > &variableNamesGeoVaLs, const std::vector< std::string > &variableNamesObsDiags)
Produce a vector of all profiles, loading the requested variables into each one.
ioda::ObsSpace & getObsdb()
Return obsdb.
Profile data holder class.
int getNumProfileLevels() const
Get number of profile levels for this profile.
std::vector< T > & get(const std::string &fullname)
Retrieve a vector if it is present. If not, throw an exception.
void set(const std::string &fullname, std::vector< T > &&vec_in)
Set values in a vector.
std::vector< float > & getGeoVaLVector(const std::string &fullname)
Retrieve a GeoVaL vector if it is present. If not, throw an exception.
void checkObsSpaceSection(ufo::ObsSpaceSection section)
Check this profile is in the expected ObsSpace section (original or extended).
@ FinalRejectFlag
Final QC flag.
@ PermRejectFlag
Blacklisted data.
void calculateVerticalAverage(const std::vector< int > &flagsIn, const std::vector< float > &valuesIn, const std::vector< float > &coordIn, const std::vector< float > &bigGap, const std::vector< float > &coordOut, float DZFrac, ProfileAveraging::Method method, std::vector< int > &flagsOut, std::vector< float > &valuesOut, int &numGaps, std::vector< float > *coordMax, std::vector< float > *coordMin)
Profile vertical averaging onto model levels.
static ProfileCheckMaker< ProfileAverageRelativeHumidity > makerProfileAverageRelativeHumidity_("AverageRelativeHumidity")
static constexpr double t0c
static constexpr const char *const geovals_relative_humidity
static constexpr const char *const extended_obs_space
static constexpr const char *const obs_relative_humidity
static constexpr const char *const bigPgaps_derived
static constexpr const char *const modellevels_logP_derived
static constexpr const char *const qcflags_relative_humidity
static constexpr const char *const geovals_average_relative_humidity
static constexpr const char *const modellevels_average_relative_humidity_derived
static constexpr const char *const LogP_derived
static constexpr const char *const InstrType
static constexpr const char *const modellevels_logP_rho_derived
static constexpr const char *const modellevels_average_relative_humidity_qcflags
static constexpr const char *const modellevels_average_air_temperature_derived
static constexpr const char *const counter_NumGapsRH
static constexpr const char *const pgebd_relative_humidity
static constexpr const char *const geovals_average_relative_humidity_qcflags