8 #ifndef TEST_IODA_OBSVECTORPACKEIGEN_H_
9 #define TEST_IODA_OBSVECTORPACKEIGEN_H_
11 #include <Eigen/Dense>
16 #define ECKIT_TESTING_SELF_REGISTER_CASES 0
18 #include "eckit/config/LocalConfiguration.h"
19 #include "eckit/testing/Test.h"
21 #include "oops/mpi/mpi.h"
22 #include "oops/runs/Test.h"
23 #include "oops/test/TestEnvironment.h"
24 #include "oops/util/Logger.h"
46 std::vector<eckit::LocalConfiguration> conf;
47 ::test::TestEnvironment::config().get(
"observations", conf);
48 util::DateTime bgn((::test::TestEnvironment::config().getString(
"window begin")));
49 util::DateTime end((::test::TestEnvironment::config().getString(
"window end")));
51 for (std::size_t jj = 0; jj < conf.size(); ++jj) {
52 eckit::LocalConfiguration obsconf(conf[jj],
"obs space");
54 obsparams.validateAndDeserialize(obsconf);
55 ioda::ObsSpace obsdb(obsparams, oops::mpi::world(), bgn, end, oops::mpi::myself());
57 const size_t rank = obsdb.distribution()->rank();
61 const std::string maskname = conf[jj].getString(
"mask variable");
64 maskvector.
mask(mask);
66 const std::vector<size_t> ref_sizes =
67 conf[jj].getUnsignedVector(
"reference local masked nobs");
68 EXPECT_EQUAL(size, ref_sizes[rank]);
71 Eigen::VectorXd packed = obsvec.
packEigen(maskvector);
72 const std::vector<double> ref_norms =
73 conf[jj].getDoubleVector(
"reference local masked norm");
74 EXPECT(oops::is_close(packed.norm(), ref_norms[rank], 1.e-5));
81 EXPECT_NOT_EQUAL(vec1.
rms(), vec2.
rms());
82 vec2.
mask(maskvector);
83 EXPECT_EQUAL(vec1.
rms(), vec2.
rms());
95 std::string
testid()
const override {
return "test::ObsVector<ioda::IodaTrait>";}
98 std::vector<eckit::testing::Test>& ts = eckit::testing::specification();
100 ts.emplace_back(
CASE(
"ioda/ObsVectorPackEigen/testPackEigen")
ObsDataVector<DATATYPE> handles vectors of data of type DATATYPE in observation space.
ObsVector class to handle vectors in observation space for IODA.
void mask(const ObsDataVector< int > &mask)
Set this ObsVector values to missing where mask is non-zero.
Eigen::VectorXd packEigen(const ObsVector &mask) const
size_t packEigenSize(const ObsVector &mask) const
void clear() const override
std::string testid() const override
void register_tests() const override
ObsVectorPackEigen()=default
virtual ~ObsVectorPackEigen()=default
CASE("Derived variable, unit conversion, and exception checking methods")
void testPackEigen()
tests ObsVector::packEigen, packEigenSize methods and mask methods