Skip to content

Commit 0bc6378

Browse files
committed
eckit::geo::Grid
1 parent bff2280 commit 0bc6378

File tree

8 files changed

+26
-41
lines changed

8 files changed

+26
-41
lines changed

src/eckit/geo/grid/ORCA.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ const ORCA::ORCARecord& orca_record(const Spec& spec) {
7575

7676

7777
ORCA::ORCA(const Spec& spec) :
78-
Regular(spec),
78+
Grid(spec),
7979
name_(spec.get_string("name")),
8080
arrangement_(arrangement_from_string(spec.get_string("orca_arrangement"))),
8181
record_(orca_record(spec)),
@@ -285,8 +285,11 @@ std::string ORCA::arrangement_to_string(Arrangement a) {
285285

286286

287287
void ORCA::fill_spec(spec::Custom& custom) const {
288-
custom.set("grid", name_ + "_" + arrangement_to_string(arrangement_));
289-
if (auto _uid = uid(); !GridSpecByUID::instance().exists(_uid)) {
288+
auto grid = name_ + "_" + arrangement_to_string(arrangement_);
289+
custom.set("grid", grid);
290+
291+
if (auto _uid = uid(); !GridSpecByName::instance().exists(grid) ||
292+
GridSpecByName::instance().match(grid).spec(grid)->get_string("orca_uid") != _uid) {
290293
custom.set("uid", _uid);
291294
}
292295
}

src/eckit/geo/grid/ORCA.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
#include <array>
1616
#include <cstddef>
1717
#include <cstdint>
18+
#include <memory>
1819

1920
#include "eckit/geo/Arrangement.h"
21+
#include "eckit/geo/Grid.h"
2022
#include "eckit/geo/container/PointsContainer.h"
21-
#include "eckit/geo/grid/Regular.h"
2223

2324

2425
namespace eckit {
@@ -29,7 +30,7 @@ class PathName;
2930
namespace eckit::geo::grid {
3031

3132

32-
class ORCA final : public Regular {
33+
class ORCA final : public Grid {
3334
public:
3435

3536
// -- Types
@@ -66,8 +67,8 @@ class ORCA final : public Regular {
6667

6768
// -- Methods
6869

69-
size_t nx() const override { return record_.nj(); }
70-
size_t ny() const override { return record_.ni(); }
70+
size_t nx() const { return record_.nj(); }
71+
size_t ny() const { return record_.ni(); }
7172

7273
std::string name() const { return name_; }
7374
std::string arrangement() const;
@@ -80,7 +81,11 @@ class ORCA final : public Regular {
8081
iterator cend() const override;
8182

8283
uid_type calculate_uid() const override;
84+
8385
const std::string& type() const override;
86+
std::vector<size_t> shape() const override { return {record_.ni(), record_.nj()}; }
87+
88+
size_t size() const override { return record_.ni() * record_.nj(); };
8489

8590
bool includesNorthPole() const override { return true; }
8691
bool includesSouthPole() const override { return true; } // FIXME: not sure this is semanticaly correct

src/eckit/geo/grid/ReducedGaussian.cc

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,6 @@ ReducedGaussian::ReducedGaussian(size_t N, const BoundingBox& bbox) :
7171
ReducedGaussian(N, util::reduced_octahedral_pl(N), bbox) {}
7272

7373

74-
// ReducedGaussian::ReducedGaussian(size_t N, const pl_type& pl, const BoundingBox& bbox) :
75-
// N_(check_N(N)), pl_(pl), j_(0), Nj_(pl.size()), x_(Nj_), y_(make_y_range(N, bbox)) {
76-
// ASSERT(N_ * 2 == pl_.size());
77-
// ASSERT(0 < N_ && Nj_ <= 2 * N_);
78-
// ASSERT(y_);
79-
// }
80-
81-
8274
Grid::iterator ReducedGaussian::cbegin() const {
8375
return iterator{new geo::iterator::Reduced(*this, 0)};
8476
}

src/eckit/geo/grid/unstructured/FESOM.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,11 @@ std::string FESOM::arrangement_to_string(Arrangement a) {
207207

208208

209209
void FESOM::fill_spec(spec::Custom& custom) const {
210-
custom.set("grid", name_ + "_" + arrangement_to_string(arrangement_));
211-
if (auto _uid = uid(); !GridSpecByUID::instance().exists(_uid)) {
210+
auto grid = name_ + "_" + arrangement_to_string(arrangement_);
211+
custom.set("grid", grid);
212+
213+
if (auto _uid = uid(); !GridSpecByName::instance().exists(grid) ||
214+
GridSpecByName::instance().match(grid).spec(grid)->get_string("fesom_uid") != _uid) {
212215
custom.set("uid", _uid);
213216
}
214217
}

src/eckit/geo/iterator/Unstructured.cc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,12 @@ struct UnstructuredInstance : Instance, Unstructured {
3737

3838

3939
Unstructured::Unstructured(const Grid& grid, size_t index, std::shared_ptr<container::PointsContainer> container) :
40-
projection_(grid.projection()), container_(container), index_(index), size_(container_->size()), uid_(grid.uid()) {
40+
container_(container), index_(index), size_(container_->size()), uid_(grid.uid()) {
4141
ASSERT(container_->size() == grid.size());
4242
}
4343

4444

45-
Unstructured::Unstructured(const Grid& grid) :
46-
projection_(grid.projection()), index_(grid.size()), size_(grid.size()), uid_(grid.uid()) {}
45+
Unstructured::Unstructured(const Grid& grid) : index_(grid.size()), size_(grid.size()), uid_(grid.uid()) {}
4746

4847

4948
bool Unstructured::operator==(const geo::Iterator& other) const {
@@ -80,7 +79,7 @@ Unstructured::operator bool() const {
8079

8180
Point Unstructured::operator*() const {
8281
ASSERT(container_);
83-
return projection_.fwd(container_->get(index_));
82+
return container_->get(index_);
8483
}
8584

8685

src/eckit/geo/iterator/Unstructured.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,9 @@
1717
#include "eckit/geo/Iterator.h"
1818

1919

20-
namespace eckit::geo {
21-
class Projection;
22-
namespace container {
20+
namespace eckit::geo::container {
2321
class PointsContainer;
2422
}
25-
} // namespace eckit::geo
2623

2724

2825
namespace eckit::geo::iterator {
@@ -40,8 +37,6 @@ class Unstructured : public Iterator {
4037

4138
// -- Members
4239

43-
const Projection& projection_;
44-
4540
std::shared_ptr<container::PointsContainer> container_;
4641
size_t index_;
4742
const size_t size_;

src/eckit/runtime/Tool.cc

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,7 @@ Tool::~Tool() {}
2323
int Tool::start() {
2424
int status = 0;
2525

26-
try {
27-
run();
28-
}
29-
catch (Exception& e) {
30-
status = 1;
31-
Log::error() << "** " << e.what() << " Caught in " << Here() << std::endl;
32-
Log::error() << "** Exception terminates " << name() << std::endl;
33-
}
34-
catch (std::exception& e) {
35-
status = 1;
36-
Log::error() << "** " << e.what() << " Caught in " << Here() << std::endl;
37-
Log::error() << "** Exception terminates " << name() << std::endl;
38-
}
26+
run();
3927

4028
return status;
4129
}

tests/geo/grid_healpix.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ CASE("gridspec") {
3939
std::unique_ptr<const Grid> grid2(GridFactory::build(spec2));
4040

4141
EXPECT_EQUAL(grid2->size(), 48);
42-
EXPECT_EQUAL(grid2->spec_str(), R"({"grid":"H2","order":"nested"})");
42+
EXPECT_EQUAL(grid2->spec_str(), R"({"grid":"H2n"})");
4343

4444
spec::Custom spec3({{"grid", "h2"}, {"order", "ring"}});
4545
std::unique_ptr<const Grid> grid3(GridFactory::build(spec3));

0 commit comments

Comments
 (0)