18 #include "eckit/config/Configuration.h"
20 #include "ioda/ObsDataVector.h"
21 #include "ioda/ObsSpace.h"
23 #include "oops/interface/ObsFilter.h"
24 #include "oops/util/abor1_cpp.h"
25 #include "oops/util/IntSetParser.h"
26 #include "oops/util/Logger.h"
39 abs_threshold_(config_.getString(
"absolute threshold",
"")),
40 threshold_(config_.getString(
"threshold",
"")),
41 function_abs_threshold_()
43 oops::Log::trace() <<
"BackgroundCheck constructor" << std::endl;
45 if (
config_.has(
"function absolute threshold")) {
46 std::vector<eckit::LocalConfiguration> threshconfs;
47 config_.get(
"function absolute threshold", threshconfs);
58 oops::Log::trace() <<
"BackgroundCheck destructed" << std::endl;
65 std::vector<std::vector<bool>> & flagged)
const {
66 oops::Log::trace() <<
"BackgroundCheck postFilter" << std::endl;
67 const oops::Variables observed =
obsdb_.obsvariables();
79 std::vector<eckit::LocalConfiguration> threshconfs;
80 config_.get(
"function absolute threshold", threshconfs);
83 data_.
get(rtvar, function_abs_threshold);
86 for (
size_t jv = 0; jv < filtervars.
nvars(); ++jv) {
89 std::vector<float> hofx;
91 for (
size_t jobs = 0; jobs <
obsdb_.nlocs(); ++jobs) {
93 ASSERT((*
obserr_)[iv][jobs] != util::missingValue((*
obserr_)[iv][jobs]));
94 ASSERT(obs[jv][jobs] != util::missingValue(obs[jv][jobs]));
95 ASSERT(hofx[jobs] != util::missingValue(hofx[jobs]));
98 float zz = function_abs_threshold[jv][jobs];
101 float yy = obs[jv][jobs] - bias[jv][jobs];
104 if (
std::abs(
static_cast<float>(hofx[jobs]) - yy) > zz) flagged[jv][jobs] =
true;
111 for (
size_t jv = 0; jv < filtervars.
nvars(); ++jv) {
114 std::vector<float> hofx;
118 std::vector<float> abs_thr(
obsdb_.nlocs(), std::numeric_limits<float>::max());
119 std::vector<float> thr(
obsdb_.nlocs(), std::numeric_limits<float>::max());
123 for (
size_t jobs = 0; jobs <
obsdb_.nlocs(); ++jobs) {
125 size_t iobs = observed.size() * jobs + iv;
126 ASSERT((*
obserr_)[iv][jobs] != util::missingValue((*
obserr_)[iv][jobs]));
127 ASSERT(obs[jv][jobs] != util::missingValue(obs[jv][jobs]));
128 ASSERT(hofx[jobs] != util::missingValue(hofx[jobs]));
131 float zz = (thr[jobs] == std::numeric_limits<float>::max()) ? abs_thr[jobs] :
132 std::min(abs_thr[jobs], thr[jobs] * (*
obserr_)[iv][jobs]);
133 ASSERT(zz < std::numeric_limits<float>::max() && zz > 0.0);
136 float yy = obs[jv][jobs] - bias[jv][jobs];
139 if (
std::abs(
static_cast<float>(hofx[jobs]) - yy) > zz) flagged[jv][jobs] =
true;
149 os <<
"BackgroundCheck::print not yet implemented ";