10 #include "eckit/config/Configuration.h"
12 #include "ioda/ObsDataVector.h"
13 #include "ioda/ObsSpace.h"
15 #include "oops/util/Logger.h"
16 #include "oops/util/PropertiesOfNVectors.h"
18 #include "ufo/GeoVaLs.h"
24 constexpr util::NamedEnumerator<ThresholdType>
32 :
FilterBase(obsdb, parameters, flags, obserr), parameters_(parameters)
34 oops::Log::trace() <<
"ModelObThreshold contructor starting" << std::endl;
43 oops::Log::trace() <<
"ModelObThreshold destructed" << std::endl;
91 std::vector<std::vector<bool>> & flagged)
const {
92 oops::Log::trace() <<
"ModelObThreshold priorFilter" << std::endl;
93 print(oops::Log::trace());
108 std::ostringstream errString;
110 if (coord_vals.size() <= 1 || coord_vals.size() != thresholds.size()) {
111 errString <<
"At least one of coord_vals, thresholds is wrong size - either unequal or < 2"
112 << oops::listOfVectorSizes(coord_vals, thresholds) << std::endl;
113 throw eckit::BadValue(errString.str());
118 std::vector<float> obs_height;
129 for (
size_t iloc=0; iloc <
nlocs; ++iloc) {
131 float bg_threshold = interp_thresholds(obs_height[iloc]);
134 std::vector <double> model_profile_column;
135 std::vector <double> model_vcoord_column;
136 model_profile_column.assign(gvals->
nlevs(model_profile_name), 0.0);
137 model_vcoord_column.assign(gvals->
nlevs(model_vcoord_name), 0.0);
139 gvals->
getAtLocation(model_profile_column, model_profile_name, iloc);
140 gvals->
getAtLocation(model_vcoord_column, model_vcoord_name, iloc);
144 float bg_model = interp_model(obs_height[iloc]);
150 for (
size_t jv = 0; jv < filtervars.
nvars(); ++jv) {
151 flagged[jv][iloc] =
true;
155 for (
size_t jv = 0; jv < filtervars.
nvars(); ++jv) {
157 if (bg_model < (bg_threshold)) {
158 flagged[jv][iloc] =
true;
162 if (bg_model > (bg_threshold)) {
163 flagged[jv][iloc] =
true;
175 os <<
"ModelObThreshold: config = " <<
parameters_ << std::endl;
Base class for UFO QC filters.
GeoVaLs: geophysical values at locations.
size_t nlevs(const std::string &var) const
Return number of levels for a specified variable.
void getAtLocation(std::vector< double > &, const std::string &, const int) const
Get GeoVaLs at a specified location.
void print(std::ostream &) const override
ModelObThreshold(ioda::ObsSpace &, const Parameters_ &, std::shared_ptr< ioda::ObsDataVector< int > >, std::shared_ptr< ioda::ObsDataVector< float > >)
void applyFilter(const std::vector< bool > &, const Variables &, std::vector< std::vector< bool >> &) const override
Filter to apply a threshold to a model profile interpolated to the observation height.
Parameters controlling the operation of the ModelObThreshold filter.
oops::RequiredParameter< Variable > obs_height
Name of the observation height variable to interpolate to.
oops::RequiredParameter< std::vector< double > > thresholds
Vector of threshold values.
oops::RequiredParameter< ThresholdType > threshold_type
Threshold type: min or max.
oops::RequiredParameter< Variable > model_vcoord
Name of the model vertical coordinate variable (GeoVal)
oops::RequiredParameter< std::vector< double > > coord_vals
Vector of vertical coordinates corresponding to vector of thresholds.
oops::RequiredParameter< Variable > model_profile
Name of the model profile variable (GeoVaLs)
const GeoVaLs * getGeoVaLs() const
Returns reference to GeoVaLs required by 1DVar.
void get(const Variable &varname, std::vector< float > &values) const
Fills a std::vector with values of the specified variable.
Represents a piecewise linear interpolation of a set of data points.
const std::string & variable() const
size_t nvars() const
Return the number of constituent "primitive" (single-channel) variables.
integer function nlocs(this)
Return the number of observational locations in this Locations object.
static constexpr char enumTypeName[]
static constexpr util::NamedEnumerator< ThresholdType > namedValues[]