8 #include "oops/util/FloatCompare.h"
9 #include "oops/util/missingValues.h"
18 const eckit::Configuration & config)
22 if (
odb_.obs_group_vars().empty())
23 throw eckit::UserError(
"Group variables configuration is empty", Here());
26 if (
odb_.obs_sort_var() !=
"air_pressure")
27 throw eckit::UserError(
"Sort variable must be air_pressure", Here());
28 if (
odb_.obs_sort_order() !=
"descending")
29 throw eckit::UserError(
"Profiles must be sorted in descending order", Here());
34 if (!
odb_.has(
"MetaData",
"extended_obs_space"))
35 throw eckit::UserError(
"The extended obs space has not been produced", Here());
39 if (!
odb_.has(
"MetaData",
"air_pressure"))
40 throw eckit::UserError(
"air_pressure@MetaData not present", Here());
43 options_.validateAndDeserialize(config);
77 (
const std::vector<std::size_t> & locsOriginal,
78 const std::vector<std::size_t> & locsExtended)
const
80 const std::vector<std::size_t> slant_path_location =
90 std::vector<float> slant_pressure;
94 std::vector <float> pressure_gv(nlevs_p);
95 for (std::size_t mlev = 0; mlev < nlevs_p; ++mlev) {
97 slant_pressure.push_back(pressure_gv[mlev]);
104 return slant_path_location;
108 if (!(
odb_.has(
"MetOfficeHofX",
"slant_path_location") &&
109 odb_.has(
"MetOfficeHofX",
"slant_pressure")))
110 throw eckit::UserError(
"At least one reference variable is not present", Here());
119 (
const std::vector<std::size_t> & locsExtended,
120 const std::vector<std::size_t> & slant_path_location,
121 const std::vector<float> & slant_pressure)
const {
122 std::vector<int> slant_path_location_ref_profile;
123 std::vector<float> slant_pressure_ref_profile;
124 for (
const std::size_t loc : locsExtended) {
128 std::stringstream errmsg;
129 for (std::size_t mlev = 0; mlev < locsExtended.size(); ++mlev) {
130 if (slant_path_location[mlev] != slant_path_location_ref_profile[mlev]) {
131 errmsg <<
"Mismatch for slant_path_location, level = " << mlev
132 <<
" (this code, OPS): "
133 << slant_path_location[mlev] <<
", "
134 << slant_path_location_ref_profile[mlev];
135 throw eckit::BadValue(errmsg.str(), Here());
137 if (!oops::is_close_relative(slant_pressure[mlev],
138 slant_pressure_ref_profile[mlev],
140 errmsg <<
"Mismatch for slant_pressure, level = " << mlev
141 <<
" (this code, OPS): "
142 << slant_pressure[mlev] <<
", "
143 << slant_pressure_ref_profile[mlev];
144 throw eckit::BadValue(errmsg.str(), Here());
150 os <<
"ObsProfileAverage operator" << std::endl;
151 os <<
"config = " <<
options_ << std::endl;
GeoVaLs: geophysical values at locations.
std::string modelVerticalCoord_
Name of model vertical coordinate.
void compareAuxiliaryReferenceVariables(const std::vector< std::size_t > &locsExtended, const std::vector< std::size_t > &slant_path_location, const std::vector< float > &slant_pressure) const
Compare auxiliary reference variables with those obtained in OPS.
std::vector< std::size_t > getSlantPathLocations(const std::vector< std::size_t > &locsOriginal, const std::vector< std::size_t > &locsExtended) const
oops::Variables requiredVars_
Required variables.
ObsProfileAverageData(const ioda::ObsSpace &odb, const eckit::Configuration &config)
std::vector< int > operatorVarIndices_
Indices of operator variables.
std::unique_ptr< GeoVaLs > cachedGeoVaLs_
Cached GeoVaLs.
ObsProfileAverageParameters options_
Options for this observation operator.
const oops::Variables & requiredVars() const
Return required variables for the operator.
void cacheGeoVaLs(const GeoVaLs &gv) const
Cache the initial values of the GeoVaLs.
const oops::Variables & simulatedVars() const
Return simulated variables for the operator.
void setUpAuxiliaryReferenceVariables()
const std::vector< int > & operatorVarIndices() const
Return operator variable indices for the operator.
void print(std::ostream &os) const
Print operator configuration options.
std::vector< float > slant_pressure_ref_
Reference values of slant path pressures.
std::vector< int > slant_path_location_ref_
Reference values of slant path locations.
oops::Variables operatorVars_
Operator variables.
const ioda::ObsSpace & odb_
ObsSpace.
oops::Parameter< bool > compareWithOPS
Perform comparisons of auxiliary variables with OPS?
oops::RequiredParameter< std::string > modelVerticalCoordinate
Name of model vertical coordinate.
oops::Parameter< int > numIntersectionIterations
void getOperatorVariables(const eckit::Configuration &conf, const oops::Variables &simulatedVariables, oops::Variables &operatorVariables, std::vector< int > &operatorVariableIndices)
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)