8 #ifndef TEST_INTERFACE_GETVALUES_H_
9 #define TEST_INTERFACE_GETVALUES_H_
20 #define ECKIT_TESTING_SELF_REGISTER_CASES 0
22 #include <boost/noncopyable.hpp>
23 #include <boost/ptr_container/ptr_vector.hpp>
25 #include "eckit/config/LocalConfiguration.h"
26 #include "eckit/testing/Test.h"
36 #include "oops/util/DateTime.h"
37 #include "oops/util/dot_product.h"
38 #include "oops/util/Duration.h"
45 template <
typename MODEL,
typename OBS>
class GetValuesFixture :
private boost::noncopyable {
67 return theGetValuesFixture;
95 ~GetValuesFixture<MODEL, OBS>() {}
103 std::unique_ptr<const Locations_>
locs_;
113 std::unique_ptr<const GetValues_>
GetValues(
new GetValues_(Test_::resol(), Test_::locs()));
127 const util::Duration windowlength = Test_::timeend() - Test_::timebeg();
128 const util::DateTime timemid = Test_::timebeg() + windowlength/2;
130 const eckit::LocalConfiguration confgen(Test_::testconf(),
"state generate");
131 const State_ xx(Test_::resol(), confgen);
133 EXPECT(xx.norm() > 0.0);
135 GeoVaLs_ gv1(Test_::locs(), Test_::geovalvars());
136 GeoVaLs_ gv2(Test_::locs(), Test_::geovalvars());
139 Test_::getvalues().fillGeoVaLs(xx, Test_::timebeg(), Test_::timeend(), gv1);
142 Test_::getvalues().fillGeoVaLs(xx, Test_::timebeg(), timemid, gv2);
143 Test_::getvalues().fillGeoVaLs(xx, timemid, Test_::timeend(), gv2);
145 EXPECT(gv1.rms() > 0.0);
146 EXPECT(gv2.rms() > 0.0);
147 EXPECT(gv1.rms() == gv2.rms());
191 const eckit::LocalConfiguration confgen(Test_::testconf(),
"state generate");
192 const State_ xx(Test_::resol(), confgen);
195 double interp_tol = Test_::testconf().getDouble(
"interpolation tolerance");
198 GeoVaLs_ gval(Test_::locs(), Test_::geovalvars());
200 EXPECT(xx.norm() > 0.0);
203 Test_::getvalues().fillGeoVaLs(xx, Test_::timebeg(), Test_::timeend(), gval);
205 EXPECT(gval.rms() > 0.0);
206 oops::Log::debug() <<
"RMS GeoVaLs: " << gval.rms() << std::endl;
211 AnalyticInit_ init(confgen);
212 init.fillGeoVaLs(Test_::locs(), ref);
214 EXPECT(ref.rms() > 0.0);
215 oops::Log::debug() <<
"RMS reference GeoVaLs: " << ref.rms() << std::endl;
221 oops::Log::test() <<
"Normalized rms of the difference: " << gval.normalizedrms(ref) << std::endl;
222 EXPECT(gval.normalizedrms(ref) < interp_tol);
227 template <
typename MODEL,
typename OBS>
234 std::string
testid()
const override {
return "test::GetValues<" + MODEL::name() +
235 ", " + OBS::name() +
">";}
238 std::vector<eckit::testing::Test>& ts = eckit::testing::specification();
240 ts.emplace_back(
CASE(
"interface/GeometryIterator/testGetValuesConstructor")
241 { testGetValuesConstructor<MODEL, OBS>(); });
242 ts.emplace_back(
CASE(
"interface/GeometryIterator/testGetValuesMultiWindow")
243 { testGetValuesMultiWindow<MODEL, OBS>(); });
244 ts.emplace_back(
CASE(
"interface/GeometryIterator/testGetValuesInterpolation")
245 { testGetValuesInterpolation<MODEL, OBS>(); });
255 #endif // TEST_INTERFACE_GETVALUES_H_