11 #ifndef TEST_BASE_OBSERRORCOVARIANCE_H_
12 #define TEST_BASE_OBSERRORCOVARIANCE_H_
18 #define ECKIT_TESTING_SELF_REGISTER_CASES 0
20 #include "eckit/testing/Test.h"
37 oops::instantiateObsErrorFactory<OBS>();
39 std::vector<eckit::LocalConfiguration> conf;
42 for (std::size_t jj = 0; jj < Test_::obspace().size(); ++jj) {
43 const eckit::LocalConfiguration rconf(conf[jj],
"obs error");
45 rparams.validateAndDeserialize(rconf);
46 std::unique_ptr<Covar_> R = std::make_unique<Covar_>(rparams.obsErrorParameters,
47 Test_::obspace()[jj]);
49 oops::Log::test() <<
"Testing ObsError: " << *R << std::endl;
63 oops::instantiateObsErrorFactory<OBS>();
65 std::vector<eckit::LocalConfiguration> conf;
68 for (std::size_t jj = 0; jj < Test_::obspace().size(); ++jj) {
69 ObsVector_ obserr(Test_::obspace()[jj],
"ObsError");
71 const eckit::LocalConfiguration rconf(conf[jj],
"obs error");
73 rparams.validateAndDeserialize(rconf);
74 Covar_ R(rparams.obsErrorParameters, Test_::obspace()[jj]);
77 EXPECT(oops::is_close(R.getRMSE(), obserr.rms(), 1.e-10));
80 ObsVector_ dy(Test_::obspace()[jj]);
84 oops::Log::test() <<
"Random vector dy: " << dy << std::endl;
87 oops::Log::test() <<
"R*dy: " << dy1 << std::endl;
88 R.inverseMultiply(dy1);
90 oops::Log::test() <<
"R^{-1}*R*dy: " << dy1 << std::endl;
91 EXPECT(oops::is_close(dy1.rms(), dy.rms(), 1.e-10));
93 R.inverseMultiply(dy2);
94 oops::Log::test() <<
"R^{-1}*dy: " << dy2 << std::endl;
97 oops::Log::test() <<
"R*R^{-1}*dy: " << dy2 << std::endl;
98 EXPECT(oops::is_close(dy2.rms(), dy.rms(), 1.e-10));
111 oops::instantiateObsErrorFactory<OBS>();
113 std::vector<eckit::LocalConfiguration> conf;
116 for (std::size_t jj = 0; jj < Test_::obspace().size(); ++jj) {
117 ObsVector_ obserr(Test_::obspace()[jj],
"ObsError");
119 const eckit::LocalConfiguration rconf(conf[jj],
"obs error");
121 rparams.validateAndDeserialize(rconf);
122 Covar_ R(rparams.obsErrorParameters, Test_::obspace()[jj]);
124 ObsVector_ dy(R.obserrors());
125 oops::Log::test() <<
"ObsError: " << dy << std::endl;
126 EXPECT(oops::is_close(dy.rms(), obserr.rms(), 1.e-10));
128 ObsVector_ dy1(R.inverseVariance());
129 oops::Log::test() <<
"inverseVariance: " << dy1 << std::endl;
132 EXPECT(oops::is_close(dy.rms(), dy1.rms(), 1.e-10));
136 oops::Log::test() <<
"R filled with ones: " << R.obserrors() << std::endl;
137 EXPECT(oops::is_close(R.obserrors().rms(), R.inverseVariance().rms(), 1.e-10));
138 EXPECT(oops::is_close(R.obserrors().rms(), dy.rms(), 1.e-10));
141 ObsVector_ testOnes(Test_::obspace()[jj],
"Ones");
142 EXPECT(oops::is_close(dy.rms(), testOnes.rms(), 1.e-10));
148 template <
typename OBS>
155 std::string
testid()
const override {
return "test::ObsErrorCovariance<" + OBS::name() +
">";}
158 std::vector<eckit::testing::Test>& ts = eckit::testing::specification();
160 ts.emplace_back(
CASE(
"interface/ObsErrorCovariance/testConstructor")
161 { testConstructor<OBS>(); });
162 ts.emplace_back(
CASE(
"interface/ObsErrorCovariance/testMultiplies")
163 { testMultiplies<OBS>(); });
164 ts.emplace_back(
CASE(
"interface/ObsErrorCovariance/testAccessors")
165 { testAccessors<OBS>(); });
Observation error covariance matrix of observations from a single ObsSpace.
Contains a polymorphic parameter holding an instance of a subclass of ObsErrorParametersBase.
ObsVector class used in oops; subclass of interface class interface::ObsVector.
void register_tests() const override
ObsTestsFixture< OBS > Test_
void clear() const override
std::string testid() const override
virtual ~ObsErrorCovariance()
static const eckit::Configuration & config()
void testMultiplies()
Tests that and .
CASE("test_linearmodelparameterswrapper_valid_name")
void testConstructor()
Tests creation and destruction of ObsErrorCovariances.