8 #ifndef TEST_IODA_DESCENDINGSORT_H_
9 #define TEST_IODA_DESCENDINGSORT_H_
14 #define ECKIT_TESTING_SELF_REGISTER_CASES 0
16 #include "eckit/config/LocalConfiguration.h"
17 #include "eckit/testing/Test.h"
19 #include "oops/mpi/mpi.h"
20 #include "oops/runs/Test.h"
21 #include "oops/test/TestEnvironment.h"
22 #include "oops/util/Expect.h"
24 #include "ioda/IodaTrait.h"
33 util::DateTime bgn(conf.getString(
"window begin"));
34 util::DateTime end(conf.getString(
"window end"));
35 const eckit::LocalConfiguration obsSpaceConf(conf,
"obs space");
36 ioda::ObsSpace obsdata(obsSpaceConf, oops::mpi::world(), bgn, end, oops::mpi::myself());
40 throw eckit::BadValue(
"Must set sort_order to descending", Here());
43 throw eckit::BadValue(
"Must set group_variable", Here());
47 const size_t nlocs = obsdata.
nlocs();
50 std::vector <int> expectedIndicesAll;
51 expectedIndicesAll.assign(nlocs, 0);
52 obsdata.
get_db(
"MetaData",
"expected_indices", expectedIndicesAll, { });
55 const std::vector <size_t> recnums = obsdata.
recnum();
60 for (
size_t rn = 0; rn < recnumList.size(); ++rn) {
62 std::vector <size_t> expectedRecordIndices;
63 for (
size_t rnindex = 0; rnindex < nlocs; ++rnindex)
64 if (recnums[rnindex] == rn)
65 expectedRecordIndices.emplace_back(expectedIndicesAll[rnindex]);
68 const std::vector<size_t> recordIndices = obsdata.
recidx_vector(rn);
71 const bool equal = std::equal(recordIndices.begin(),
73 expectedRecordIndices.begin());
81 std::string
testid()
const override {
return "ioda::test::DescendingSort";}
84 std::vector<eckit::testing::Test>& ts = eckit::testing::specification();
86 const eckit::LocalConfiguration conf(::test::TestEnvironment::config());
87 for (
const std::string & testCaseName : conf.keys())
89 const eckit::LocalConfiguration testCaseConf(::test::TestEnvironment::config(), testCaseName);
90 ts.emplace_back(
CASE(
"ioda/DescendingSort/" + testCaseName, testCaseConf)
Observation data class for IODA.
const std::vector< std::size_t > & recnum() const
return reference to the record number vector
std::vector< std::size_t > recidx_all_recnums() const
return all record numbers from the recidx_ data member
const std::vector< std::string > & obs_group_vars() const
return YAML configuration parameter: obsdatain.obsgrouping.group variables
const std::vector< std::size_t > & recidx_vector(const RecIdxIter &irec) const
return record number vector pointed to by the given iterator
size_t nlocs() const
return the number of locations in the obs space. Note that nlocs may be smaller than global unique nl...
void get_db(const std::string &group, const std::string &name, std::vector< int > &vdata, const std::vector< int > &chanSelect={ }) const
transfer data from the obs container to vdata
std::string obs_sort_order() const
return YAML configuration parameter: obsdatain.obsgrouping.sort order
void save()
save the obs space data into a file (if obsdataout specified)
void register_tests() const override
void clear() const override
std::string testid() const override
CASE("Derived variable and unit conversion methods")
void testDescendingSort(const eckit::LocalConfiguration &conf)