8 #include "oops/util/missingValues.h"
10 #include "ufo/GeoVaLs.h"
11 #include "ufo/ObsDiagnostics.h"
22 const std::vector <bool> &apply,
24 std::vector<std::vector<bool>> &flagged)
25 : obsdb_(data.obsspace()),
26 geovals_(data.getGeoVaLs()),
27 obsdiags_(data.getObsDiags()),
29 filtervars_(filtervars),
73 if (entriesPerProfile == 0) {
88 std::string fullname = it_profile.first;
90 std::string groupname;
93 if (groupname ==
"QCFlags" ||
94 groupname ==
"ModelLevelsFlags" ||
95 groupname ==
"ModelLevelsQCFlags" ||
96 groupname ==
"ModelRhoLevelsFlags" ||
97 groupname ==
"Counters") {
98 const std::vector <int>& profileData = get<int>(fullname);
106 }
else if (groupname ==
"Corrections" ||
107 groupname ==
"DerivedValue" ||
108 groupname ==
"GrossErrorProbability" ||
109 groupname ==
"GrossErrorProbabilityBuddyCheck" ||
110 groupname ==
"ModelLevelsDerivedValue" ||
111 groupname ==
"ModelRhoLevelsDerivedValue" ||
113 const std::vector <float>& profileData = get<float>(fullname);
131 <<
" errors detected, whole profile rejected" << std::endl;
132 for (
size_t jlev = 0; jlev < ReportFlags.size(); ++jlev) {
143 std::string fullname = it_profile.first;
145 std::string groupname;
148 if (groupname ==
"QCFlags") {
152 const std::vector <int> &Flags = get<int>(fullname);
153 if (Flags.empty())
continue;
159 for (
size_t idx = 0; idx < idxvar; ++idx) {
167 bool isObservationReport = varname ==
"observation_report";
174 if (isObservationReport &&
176 oops::Log::debug() <<
" Reject all variables, index " << profileIndex << std::endl;
178 flagged_[jvar][profileIndex] =
true;
187 <<
", index " << profileIndex << std::endl;
188 flagged_[idxvar][profileIndex] =
true;
197 (
const std::string & variableName)
const
201 auto it_altCoord = alternativeVerticalCoordinate.find(variableName);
202 if (it_altCoord != alternativeVerticalCoordinate.end()) {
204 return it_altCoord->second;
213 auto it_GeoVaLData =
GeoVaLData_.find(variableName);
216 return it_GeoVaLData->second;
218 std::vector <float> vec_GeoVaL_column;
225 const std::vector<std::size_t> slant_path_location =
229 this->getAssociatedVerticalCoordinate(variableName));
231 vec_GeoVaL_column.assign(
geovals_->
nlevs(variableName), 0.0);
237 if (slant_path_location.size() == vec_GeoVaL_column.size()) {
238 std::vector<float> vec_GeoVaL_loc(
geovals_->
nlevs(variableName));
241 for (std::size_t mlev = 0; mlev < slant_path_location.size(); ++mlev) {
242 const std::size_t jloc = slant_path_location[mlev];
244 vec_GeoVaL_column[mlev] = vec_GeoVaL_loc[mlev];
253 GeoVaLData_.emplace(variableName, std::move(vec_GeoVaL_column));
263 return it_obsDiagData->second;
266 std::string groupname;
268 std::vector <float> vec_ObsDiag;
274 if (vec_all.empty() &&
278 vec_all.assign(
obsdb_.nlocs(), util::missingValue(1.0f));
283 if (!vec_all.empty()) {
286 vec_ObsDiag.emplace_back(vec_all[profileIndex]);
295 (
const std::vector <std::string> &variableNamesInt,
296 const std::vector <std::string> &variableNamesFloat,
297 const std::vector <std::string> &variableNamesString,
298 const std::vector <std::string> &variableNamesGeoVaLs,
299 const std::vector <std::string> &variableNamesObsDiags)
302 std::vector <ProfileDataHolder> profiles;
304 for (
size_t jprof = 0; jprof <
obsdb_.nrecs(); ++jprof) {
310 variableNamesGeoVaLs,
311 variableNamesObsDiags);
312 profiles.emplace_back(
profile);
320 for (
size_t jprof = 0; jprof <
obsdb_.nrecs(); ++jprof) {
322 auto&
profile = profiles[jprof];
Options controlling the operation of the EntireSampleDataHandler and ProfileDataHandler classes.
oops::Parameter< int > nErrorsFail
Number of errors, accumulated over checks, that cause the observation to have failed.
size_t getEntriesPerProfile(const std::string &groupname) const
Determine number of entries per profile for a variable group.
oops::Parameter< std::string > defaultVerticalCoordinate
oops::Parameter< std::map< std::string, std::string > > alternativeVerticalCoordinate
Retrieve and store data for entire sample. This class uses lazy loading; vectors of variables are ret...
size_t nlevs(const std::string &var) const
Return number of levels for a specified variable.
bool has(const std::string &var) const
void getAtLocation(std::vector< double > &, const std::string &, const int) const
Get GeoVaLs at a specified location.
void get(std::vector< float > &, const std::string &) const
bool has(const std::string &var) const
ObsFilterData provides access to all data related to an ObsFilter.
ProfileDataHandler(const ObsFilterData &data, const DataHandlerParameters &options, const std::vector< bool > &apply, const Variables &filtervars, std::vector< std::vector< bool >> &flagged)
const DataHandlerParameters & options_
Configurable parameters.
void updateAllProfiles(std::vector< ProfileDataHolder > &profiles)
Read values from a collection of profiles and update information related to each one.
std::unique_ptr< EntireSampleDataHandler > entireSampleDataHandler_
Class that handles the entire data sample.
std::vector< float > & getGeoVaLVector(const std::string &variableName)
Get GeoVaLs for a particular profile.
const Variables & filtervars_
Filter variables.
const ObsDiagnostics *const obsdiags_
ObsDiags loaded by the filter.
std::unordered_map< std::string, std::vector< float > > obsDiagData_
Container of ObsDiags in the current profile.
void updateEntireSampleData()
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.
void initialiseNextProfile()
std::unique_ptr< ProfileIndices > profileIndices_
Class that handles profile indices.
std::vector< float > & getObsDiag(const std::string &variableName)
Get ObsDiags for a particular profile.
std::unordered_map< std::string, std::vector< float > > GeoVaLData_
Container of GeoVaLs in the current profile.
void updateProfileInformation()
ioda::ObsSpace & obsdb_
Observation database.
void resetProfileIndices()
void updateValueIfPresent(const std::vector< T > &vecIn, const size_t &idxIn, std::vector< T > &vecOut, const size_t &idxOut)
Transfer values from one vector to another (as long as neither is empty).
void setFinalReportFlags()
Set final report flags based on the NumAnyErrors counter.
void writeQuantitiesToObsdb()
std::vector< std::vector< bool > > & flagged_
Flagged values.
void getProfileIndicesInEntireSample(const std::string &groupname)
Get indices in entire sample corresponding to current profile.
void resetProfileInformation()
std::string getAssociatedVerticalCoordinate(const std::string &variableName) const
std::vector< size_t > profileIndicesInEntireSample_
Indices in the entire data sample that correspond to the current profile.
const GeoVaLs *const geovals_
GeoVaLs loaded by the filter.
std::unordered_map< std::string, boost::variant< std::vector< int >, std::vector< float >, std::vector< std::string > > > profileData_
Container of each variable in the current profile.
Profile data holder class.
Determine indices of observations making up individual profiles. The indices are computed with respec...
size_t size() const
Return the number of constituent Variable objects (some of which may contain multiple channels).
@ FinalRejectReport
One of flags 1-6 set.
@ FinalRejectFlag
Final QC flag.
void splitVarGroup(const std::string &vargrp, std::string &var, std::string &grp)
std::vector< std::size_t > getSlantPathLocations(const ioda::ObsSpace &odb, const GeoVaLs &gv, const std::vector< std::size_t > &locs, const std::string &modelVerticalCoord, const int itermax)
static constexpr const char *const qcflags_observation_report
static constexpr const char *const counter_NumAnyErrors
static constexpr const char *const obs_air_pressure