8 #ifndef TEST_IO_OBSFRAMECONSTRUCTOR_H_
9 #define TEST_IO_OBSFRAMECONSTRUCTOR_H_
20 #define ECKIT_TESTING_SELF_REGISTER_CASES 0
22 #include "eckit/config/LocalConfiguration.h"
23 #include "eckit/testing/Test.h"
25 #include "oops/mpi/mpi.h"
26 #include "oops/runs/Test.h"
27 #include "oops/test/TestEnvironment.h"
28 #include "oops/util/DateTime.h"
29 #include "oops/util/FloatCompare.h"
30 #include "oops/util/Logger.h"
32 #include "ioda/core/IodaUtils.h"
33 #include "ioda/distribution/DistributionFactory.h"
34 #include "ioda/io/ObsFrameRead.h"
35 #include "ioda/io/ObsFrameWrite.h"
37 #include "ioda/ObsSpaceParameters.h"
53 const eckit::LocalConfiguration conf(::test::TestEnvironment::config());
54 std::vector<eckit::LocalConfiguration> confOspaces = conf.getSubConfigurations(
"observations");
55 util::DateTime bgn(::test::TestEnvironment::config().getString(
"window begin"));
56 util::DateTime end(::test::TestEnvironment::config().getString(
"window end"));
58 for (std::size_t i = 0; i < confOspaces.size(); ++i) {
59 eckit::LocalConfiguration obsConfig;
60 eckit::LocalConfiguration testConfig;
61 confOspaces[i].get(
"obs space", obsConfig);
62 confOspaces[i].get(
"test data", testConfig);
63 oops::Log::trace() <<
"ObsFrame obs space config: " << i <<
": " << obsConfig << std::endl;
64 oops::Log::trace() <<
"ObsFrame test data config: " << i <<
": " << testConfig << std::endl;
67 topParams.validateAndDeserialize(obsConfig);
69 oops::mpi::world(), oops::mpi::myself());
72 std::shared_ptr<ObsFrame> obsFrame = std::make_shared<ObsFrameRead>(obsParams);
75 ioda::Dimensions_t expectedMaxVarSize = testConfig.getInt(
"max var size", 0);
76 ioda::Dimensions_t maxVarSize = obsFrame->ioMaxVarSize();
77 EXPECT_EQUAL(maxVarSize, expectedMaxVarSize);
79 ioda::Dimensions_t expectedNumLocs = testConfig.getInt(
"nlocs", 0);
80 ioda::Dimensions_t
numLocs = obsFrame->ioNumLocs();
81 EXPECT_EQUAL(
numLocs, expectedNumLocs);
83 ioda::Dimensions_t expectedNumVars = testConfig.getInt(
"nvars", 0);
84 ioda::Dimensions_t numVars = obsFrame->ioNumVars();
85 EXPECT_EQUAL(numVars, expectedNumVars);
87 ioda::Dimensions_t expectedNumDimVars = testConfig.getInt(
"ndvars", 0);
88 ioda::Dimensions_t numDimVars = obsFrame->ioNumDimVars();
89 EXPECT_EQUAL(numDimVars, expectedNumDimVars);
94 obsFrame = std::make_shared<ObsFrameWrite>(obsParams);
97 std::vector<eckit::LocalConfiguration> writeDimConfigs =
98 testConfig.getSubConfigurations(
"write dimensions");
99 ioda::Dimensions_t expectedNumLocs = 0;
100 for (std::size_t j = 0; j < writeDimConfigs.size(); ++j) {
101 std::string dimName = writeDimConfigs[i].getString(
"name");
102 Dimensions_t dimSize = writeDimConfigs[i].getInt(
"size");
103 if (dimName ==
"nlocs") {
104 expectedNumLocs = dimSize;
108 ioda::Dimensions_t
numLocs = obsFrame->ioNumLocs();
109 EXPECT_EQUAL(
numLocs, expectedNumLocs);
121 std::string
testid()
const override {
return "test::ObsFrameConstructor";}
124 std::vector<eckit::testing::Test>& ts = eckit::testing::specification();
126 ts.emplace_back(
CASE(
"ioda/ObsFrameConstructor/testConstructor")
Interfaces for ioda::ObsGroup and related classes.
Interfaces for ioda::Variable and related classes.
ObsTopLevelParameters top_level_
sub groups of parameters
oops::OptionalParameter< ObsFileOutParameters > obsOutFile
output specification by writing to a file
virtual ~ObsFrameConstructor()
std::string testid() const override
void register_tests() const override
void clear() const override
CASE("Derived variable, unit conversion, and exception checking methods")
void setOfileParamsFromTestConfig(const eckit::LocalConfiguration &obsConfig, ioda::ObsSpaceParameters &obsParams)
set params for output file construction from test YAML configuration