8 #ifndef TEST_IODA_LOCALOBSSPACE_H_
9 #define TEST_IODA_LOCALOBSSPACE_H_
15 #define ECKIT_TESTING_SELF_REGISTER_CASES 0
17 #include <boost/shared_ptr.hpp>
19 #include "eckit/config/LocalConfiguration.h"
20 #include "eckit/testing/Test.h"
22 #include "oops/mpi/mpi.h"
23 #include "oops/runs/Test.h"
24 #include "oops/test/TestEnvironment.h"
26 #include "ioda/IodaTrait.h"
38 std::vector<eckit::LocalConfiguration> conf;
39 ::test::TestEnvironment::config().get(
"observations", conf);
42 for (std::size_t jj = 0; jj < Test_::size(); ++jj) {
43 double lonpt = conf[jj].getDouble(
"obs space.localization.lon ref point");
44 double latpt = conf[jj].getDouble(
"obs space.localization.lat ref point");
45 eckit::geometry::Point2 refPoint(lonpt, latpt);
48 eckit::LocalConfiguration locconf(conf[jj],
"obs space.localization");
49 std::string searchMethods[2] = {
"brute_force",
"kd_tree"};
51 for (
const std::string &searchMethod : searchMethods) {
52 locconf.set(
"search method", searchMethod);
53 oops::Log::debug() <<
"Using " << searchMethod <<
" for search method" << std::endl;
54 ioda::ObsSpace obsspace_local(Test_::obspace(jj), refPoint, locconf);
56 std::size_t Nlocs = obsspace_local.
nlocs();
57 oops::Log::debug() <<
"Nlocs_local = " << Nlocs << std::endl;
58 obsspace_local.
comm().allReduceInPlace(Nlocs, eckit::mpi::sum());
60 std::size_t ExpectedNlocs =
61 conf[jj].getUnsigned(
"obs space.test data.expected local nlocs");
62 oops::Log::debug() <<
"Expected Nlocs_local = " << ExpectedNlocs << std::endl;
63 EXPECT(Nlocs == ExpectedNlocs);
65 std::vector<double> obsdist = obsspace_local.
obsdist();
66 double distance = conf[jj].getDouble(
"obs space.localization.lengthscale");
67 oops::Log::debug() <<
"loc_ dist" << distance << std::endl;
68 if (!obsdist.empty()) {
69 oops::Log::debug() <<
"loc_obs_dist(min,max) = " <<
70 *std::min_element(obsdist.begin(), obsdist.end()) <<
" "<<
71 *std::max_element(obsdist.begin(), obsdist.end()) << std::endl;
72 EXPECT(*std::max_element(obsdist.begin(), obsdist.end()) <= distance);
73 EXPECT(*std::min_element(obsdist.begin(), obsdist.end()) > 0.0);
86 std::string
testid()
const override {
return "test::LocalObsSpace<ioda::IodaTrait>";}
89 std::vector<eckit::testing::Test>& ts = eckit::testing::specification();
91 ts.emplace_back(CASE(
"ioda/LocalObsSpace/testConstructor_local")
103 #endif // TEST_IODA_LOCALOBSSPACE_H_