11 #ifndef TEST_INTERFACE_OBSAUXINCREMENT_H_
12 #define TEST_INTERFACE_OBSAUXINCREMENT_H_
20 #define ECKIT_TESTING_SELF_REGISTER_CASES 0
22 #include <boost/noncopyable.hpp>
24 #include "eckit/config/LocalConfiguration.h"
25 #include "eckit/testing/Test.h"
30 #include "oops/util/DateTime.h"
31 #include "oops/util/dot_product.h"
49 return theObsAuxIncrementFixture;
54 eckit::LocalConfiguration biasconf =
57 biasparams.validateAndDeserialize(biasconf);
63 ~ObsAuxIncrementFixture<OBS>() {}
65 std::vector<std::shared_ptr<Covariance_> >
covar_;
74 for (std::size_t jj = 0; jj < Test_::obspace().size(); ++jj) {
75 eckit::LocalConfiguration biasconf = Test_::config(jj).getSubConfiguration(
"obs bias");
76 typename AuxIncr_::Parameters_ biasparams;
77 biasparams.validateAndDeserialize(biasconf);
78 AuxIncr_ dx(Test_::obspace()[jj], biasparams);
79 oops::Log::test() <<
"Printing zero ObsAuxIncrement: " << dx << std::endl;
80 EXPECT(dx.norm() == 0.0);
90 for (std::size_t jj = 0; jj < Test_::obspace().size(); ++jj) {
91 if (Test_::config(jj).has(
"obs bias")) {
92 eckit::LocalConfiguration biasconf = Test_::config(jj).getSubConfiguration(
"obs bias");
93 typename AuxIncr_::Parameters_ biasparams;
94 biasparams.validateAndDeserialize(biasconf);
95 AuxIncr_ dx1(Test_::obspace()[jj], biasparams);
97 oops::Log::test() <<
"Printing random ObsAuxIncrement: " << dx1 << std::endl;
99 AuxIncr_ dxempty(dx1,
false);
100 EXPECT_EQUAL(dxempty.norm(), 0.0);
103 EXPECT(dx2.norm() > 0.0);
104 EXPECT(dx2.norm() == dx1.norm());
108 EXPECT(dx2.norm() == 0.0);
120 for (std::size_t jj = 0; jj < Test_::obspace().size(); ++jj) {
121 if (Test_::config(jj).has(
"obs bias")) {
122 eckit::LocalConfiguration biasconf = Test_::config(jj).getSubConfiguration(
"obs bias");
123 typename AuxIncr_::Parameters_ biasparams;
124 biasparams.validateAndDeserialize(biasconf);
125 AuxIncr_ dx1(Test_::obspace()[jj], biasparams);
126 AuxTest_::covariance(jj).randomize(dx1);
127 AuxIncr_ dx2(Test_::obspace()[jj], biasparams);
131 double dot1 = dx1.norm();
134 double dot2 = dx2.norm();
138 double dot3 = dx2.norm();
141 EXPECT(dot3 <= dot1 + dot2);
153 for (std::size_t jj = 0; jj < Test_::obspace().size(); ++jj) {
154 eckit::LocalConfiguration biasconf = Test_::config(jj).getSubConfiguration(
"obs bias");
155 typename AuxIncr_::Parameters_ biasparams;
156 biasparams.validateAndDeserialize(biasconf);
157 AuxIncr_ dx1(Test_::obspace()[jj], biasparams);
158 AuxTest_::covariance(jj).randomize(dx1);
166 EXPECT(dx2.norm() < 1e-8);
177 for (std::size_t jj = 0; jj < Test_::obspace().size(); ++jj) {
178 eckit::LocalConfiguration biasconf = Test_::config(jj).getSubConfiguration(
"obs bias");
179 typename AuxIncr_::Parameters_ biasparams;
180 biasparams.validateAndDeserialize(biasconf);
181 AuxIncr_ dx1(Test_::obspace()[jj], biasparams);
182 AuxTest_::covariance(jj).randomize(dx1);
183 AuxIncr_ dx2(Test_::obspace()[jj], biasparams);
184 AuxTest_::covariance(jj).randomize(dx2);
187 double zz1 = dot_product(dx1, dx2);
188 double zz2 = dot_product(dx2, dx1);
201 for (std::size_t jj = 0; jj < Test_::obspace().size(); ++jj) {
202 eckit::LocalConfiguration biasconf = Test_::config(jj).getSubConfiguration(
"obs bias");
203 typename AuxIncr_::Parameters_ biasparams;
204 biasparams.validateAndDeserialize(biasconf);
205 AuxIncr_ dx(Test_::obspace()[jj], biasparams);
206 AuxTest_::covariance(jj).randomize(dx);
207 EXPECT(dx.norm() > 0.0);
211 EXPECT(dx.norm() == 0.0);
222 for (std::size_t jj = 0; jj < Test_::obspace().size(); ++jj) {
223 eckit::LocalConfiguration biasconf = Test_::config(jj).getSubConfiguration(
"obs bias");
224 typename AuxIncr_::Parameters_ biasparams;
225 biasparams.validateAndDeserialize(biasconf);
226 AuxIncr_ dx1(Test_::obspace()[jj], biasparams);
227 AuxTest_::covariance(jj).randomize(dx1);
237 EXPECT(dx2.norm() < 1e-8);
243 template <
typename OBS>
252 std::string
testid()
const override {
return "test::ObsAuxIncrement<" + OBS::name() +
">";}
255 std::vector<eckit::testing::Test>& ts = eckit::testing::specification();
257 ts.emplace_back(
CASE(
"interface/ObsAuxIncrement/testObsAuxIncrementConstructor")
258 { testObsAuxIncrementConstructor<OBS>(); });
259 ts.emplace_back(
CASE(
"interface/ObsAuxIncrement/testObsAuxIncrementCopyConstructor")
260 { testObsAuxIncrementCopyConstructor<OBS>(); });
261 ts.emplace_back(
CASE(
"interface/ObsAuxIncrement/testObsAuxIncrementTriangle")
262 { testObsAuxIncrementTriangle<OBS>(); });
263 ts.emplace_back(
CASE(
"interface/ObsAuxIncrement/testObsAuxIncrementOpPlusEq")
264 { testObsAuxIncrementOpPlusEq<OBS>(); });
265 ts.emplace_back(
CASE(
"interface/ObsAuxIncrement/testObsAuxIncrementDotProduct")
266 { testObsAuxIncrementDotProduct<OBS>(); });
267 ts.emplace_back(
CASE(
"interface/ObsAuxIncrement/testObsAuxIncrementAxpy")
268 { testObsAuxIncrementAxpy<OBS>(); });
Auxiliary error covariance related to observations, templated on <OBS>
ObsAuxCovariance_::Parameters_ Parameters_
void randomize(ObsAuxIncrement_ &) const
randomize the values in the ObsAuxIncrement
Auxiliary increment related to observations, templated on <OBS>
std::size_t size() const
Access.
oops::ObsAuxCovariance< OBS > Covariance_
ObsTestsFixture< OBS > Test_
static ObsAuxIncrementFixture< OBS > & getInstance()
static const Covariance_ & covariance(const size_t ii)
std::vector< std::shared_ptr< Covariance_ > > covar_
ObsTestsFixture< OBS > Test_
void clear() const override
virtual ~ObsAuxIncrement()
std::string testid() const override
void register_tests() const override
static ObsSpaces_ & obspace()
accessor to a all obs spaces
static eckit::LocalConfiguration & config(size_t jj)
accessor to a jj-th obs type config
void testObsAuxIncrementCopyConstructor()
Tests copy-constructor (with option of allocating, but not copying the data)
void testObsAuxIncrementConstructor()
test constructor and print method
void testObsAuxIncrementOpPlusEq()
void testObsAuxIncrementTriangle()
void testObsAuxIncrementAxpy()
void testObsAuxIncrementDotProduct()
void testObsAuxIncrementZero()
CASE("test_linearmodelparameterswrapper_valid_name")