8 #ifndef TEST_GENERIC_VERTICALLOCEV_H_
9 #define TEST_GENERIC_VERTICALLOCEV_H_
11 #include <Eigen/Dense>
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"
33 #include "oops/util/DateTime.h"
34 #include "oops/util/dot_product.h"
50 const Geometry_ & geometry = Test_::resol();
54 State_ x(Test_::resol(), Test_::ctlvars(), Test_::time());
56 VerticalLocEV_ vertloc(vertlocconf, x);
57 oops::Log::test() <<
"Number of eigenvalues used in VerticalLoc: " << vertloc.neig() << std::endl;
61 int neig = vertloc.neig();
62 oops::Log::debug() <<
"Expected number of eigen modes: " << nEigExpected << std::endl;
63 oops::Log::debug() <<
"Actual number of eigen modes: " << neig << std::endl;
64 EXPECT(nEigExpected == neig);
67 EXPECT(vertloc.testTruncateEvecs(geometry));
77 std::vector<util::DateTime> times;
78 times.push_back(Test_::time());
79 Increment4D_ dx1(Test_::resol(), Test_::ctlvars(), times);
80 Increment4D_ dx2(Test_::resol(), Test_::ctlvars(), times);
81 IncrementEnsemble_ incEns(Test_::resol(), Test_::ctlvars(), times, neig);
83 for (
int i = 1; i < neig; ++i) {incEns[i][0].zero();}
84 for (
int i = 1; i < neig; ++i) {
85 double n = incEns[0][0].dot_product_with(incEns[i][0]);
86 EXPECT(n < 100*DBL_EPSILON);
92 double normRandom = dx2.dot_product_with(dx2);
93 dx2.schur_product_with(dx1);
94 EXPECT(std::abs(dx2.dot_product_with(dx2)-normRandom) < normRandom*DBL_EPSILON);
95 oops::Log::debug() <<
"Increment ones()" << dx1 << std::endl;
98 vertloc.modulateIncrement(dx1, incEns);
101 double n0 = incEns[0][0].dot_product_with(incEns[0][0]);
102 oops::Log::debug() <<
"dot product 0: " << n0 << std::endl;
105 double tol = 2*n0*DBL_EPSILON;
106 oops::Log::debug() <<
"tolerance :" << tol << std::endl;
109 for (
int i = 1; i < neig; ++i) {
110 double n = incEns[0][0].dot_product_with(incEns[i][0]);
111 oops::Log::debug() <<
"dot product " << i <<
": " << n << std::endl;
117 IncrementEnsemble_ incEns2(Test_::resol(), Test_::ctlvars(), times, 1);
120 Eigen::MatrixXd modInc = vertloc.modulateIncrement(incEns2, geometry.begin(), 0);
121 Eigen::MatrixXd modIncInner = modInc.transpose()*modInc;
122 oops::Log::debug() <<
"modInc'*modInc" << modIncInner << std::endl;
124 for (
int i = 1; i < neig; ++i) {
125 EXPECT(modIncInner(0, i) < modIncInner(0, 0)*DBL_EPSILON);
131 template <
typename MODEL>
138 std::string
testid()
const override {
return "test::VerticalLocEV<" + MODEL::name() +
">";}
141 std::vector<eckit::testing::Test>& ts = eckit::testing::specification();
143 ts.emplace_back(
CASE(
"generic/VerticalLocEV/testVerticalLocEV")
144 { testVerticalLocEV<MODEL>(); });
Geometry class used in oops; subclass of interface class interface::Geometry.
4D model state Increment (vector of 3D Increments)
Ensemble of 4D increments.
State class used in oops; subclass of interface class interface::State.
static const eckit::Configuration & config()
virtual ~VerticalLocEV()=default
std::string testid() const override
void register_tests() const override
void clear() const override
CASE("test_linearmodelparameterswrapper_valid_name")