8 #ifndef TEST_IO_OBSIOCONSTRUCTOR_H_
9 #define TEST_IO_OBSIOCONSTRUCTOR_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/ObsIo.h"
35 #include "ioda/io/ObsIoFactory.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() <<
"ObsIo obs space config: " << i <<
": " << obsConfig << std::endl;
64 oops::Log::trace() <<
"ObsIo test data config: " << i <<
": " << testConfig << std::endl;
67 topParams.validateAndDeserialize(obsConfig);
69 oops::mpi::world(), oops::mpi::myself());
72 std::shared_ptr<ObsIo> obsIo;
76 ioda::Dimensions_t expectedMaxVarSize = testConfig.getInt(
"max var size", 0);
77 ioda::Dimensions_t maxVarSize = obsIo->maxVarSize();
78 EXPECT_EQUAL(maxVarSize, expectedMaxVarSize);
80 ioda::Dimensions_t expectedNumLocs = testConfig.getInt(
"nlocs", 0);
81 ioda::Dimensions_t
numLocs = obsIo->numLocs();
82 EXPECT_EQUAL(
numLocs, expectedNumLocs);
84 ioda::Dimensions_t expectedNumVars = testConfig.getInt(
"nvars", 0);
85 ioda::Dimensions_t numVars = obsIo->numVars();
86 EXPECT_EQUAL(numVars, expectedNumVars);
88 ioda::Dimensions_t expectedNumDimVars = testConfig.getInt(
"ndvars", 0);
89 ioda::Dimensions_t numDimVars = obsIo->numDimVars();
90 EXPECT_EQUAL(numDimVars, expectedNumDimVars);
98 std::vector<eckit::LocalConfiguration> writeDimConfigs =
99 testConfig.getSubConfigurations(
"write dimensions");
100 ioda::Dimensions_t expectedNumLocs = 0;
101 for (std::size_t j = 0; j < writeDimConfigs.size(); ++j) {
102 std::string dimName = writeDimConfigs[i].getString(
"name");
103 Dimensions_t dimSize = writeDimConfigs[i].getInt(
"size");
104 if (dimName ==
"nlocs") {
105 expectedNumLocs = dimSize;
109 ioda::Dimensions_t
numLocs = obsIo->numLocs();
110 EXPECT_EQUAL(
numLocs, expectedNumLocs);
122 std::string
testid()
const override {
return "test::ObsIoConstructor";}
125 std::vector<eckit::testing::Test>& ts = eckit::testing::specification();
127 ts.emplace_back(
CASE(
"ioda/ObsIoConstructor/testConstructor")
Interfaces for ioda::ObsGroup and related classes.
Interfaces for ioda::Variable and related classes.
static std::shared_ptr< ObsIo > create(ObsIoModes mode, const ObsSpaceParameters ¶meters)
Create and return a new instance of an ObsIo subclass.
ObsTopLevelParameters top_level_
sub groups of parameters
oops::OptionalParameter< ObsFileOutParameters > obsOutFile
output specification by writing to a file
virtual ~ObsIoConstructor()
void clear() const override
std::string testid() const override
void register_tests() 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