8 #ifndef TEST_INTERFACE_OBSOPERATOR_H_
9 #define TEST_INTERFACE_OBSOPERATOR_H_
15 #define ECKIT_TESTING_SELF_REGISTER_CASES 0
17 #include <boost/noncopyable.hpp>
19 #include "eckit/config/LocalConfiguration.h"
20 #include "eckit/testing/Test.h"
37 typedef ObsTestsFixture<OBS> Test_;
40 std::vector<eckit::LocalConfiguration> conf;
43 for (std::size_t jj = 0; jj < Test_::obspace().size(); ++jj) {
44 eckit::LocalConfiguration obsopconf(conf[jj],
"obs operator");
45 std::unique_ptr<ObsOperator_> hop(
new ObsOperator_(Test_::obspace()[jj], obsopconf));
63 std::vector<eckit::LocalConfiguration> conf;
66 for (std::size_t jj = 0; jj < Test_::obspace().size(); ++jj) {
69 eckit::LocalConfiguration obsopconf(conf[jj],
"obs operator");
70 ObsOperator_ hop(Test_::obspace()[jj], obsopconf);
73 const ObsAuxCtrl_ ybias(Test_::obspace()[jj], conf[jj]);
76 eckit::LocalConfiguration gconf(conf[jj],
"geovals");
78 hopvars += ybias.requiredVars();
79 const GeoVaLs_ gval(gconf, Test_::obspace()[jj], hopvars);
82 ObsVector_ hofx(Test_::obspace()[jj]);
86 diagvars += ybias.requiredHdiagnostics();
87 ObsDiags_ diags(Test_::obspace()[jj],
88 hop.locations(Test_::obspace()[jj].windowStart(),
89 Test_::obspace()[jj].windowEnd()),
93 hop.simulateObs(gval, hofx, ybias, diags);
97 if (conf[jj].
has(
"obs bias")) {
98 const ObsVector_ bias(Test_::obspace()[jj],
"ObsBias",
false);
102 const double tol = conf[jj].getDouble(
"tolerance");
103 if (conf[jj].
has(
"vector ref")) {
106 ObsVector_ obsref(Test_::obspace()[jj], conf[jj].getString(
"vector ref"));
108 const double zz = obsref.rms();
109 oops::Log::info() <<
"Vector difference between reference and computed: " << obsref;
110 EXPECT(zz < 100*tol);
112 }
else if (conf[jj].
has(
"norm ref")) {
115 ObsVector_ obsref(Test_::obspace()[jj], conf[jj].getString(
"norm ref"));
118 const double zz = obsref.rms();
119 oops::Log::info() <<
"Normalised vector difference between reference and computed: "
121 EXPECT(zz < 100*tol);
125 const double zz = hofx.rms();
126 const double xx = conf[jj].getDouble(
"rms ref");
128 oops::Log::debug() <<
"zz: " << std::fixed << std::setprecision(8) << zz << std::endl;
129 oops::Log::debug() <<
"xx: " << std::fixed << std::setprecision(8) << xx << std::endl;
131 EXPECT(oops::is_close(xx, zz, tol));
138 template <
typename OBS>
145 std::string
testid()
const override {
return "test::ObsOperator<" + OBS::name() +
">";}
148 std::vector<eckit::testing::Test>& ts = eckit::testing::specification();
150 ts.emplace_back(
CASE(
"interface/ObsOperator/testConstructor")
151 { testConstructor<OBS>(); });
152 ts.emplace_back(
CASE(
"interface/ObsOperator/testSimulateObs")
153 { testSimulateObs<OBS>(); });
165 #endif // TEST_INTERFACE_OBSOPERATOR_H_