From bfc91fc7f1baf6f8f77f98d74e47da14179c080b Mon Sep 17 00:00:00 2001 From: Sebastien Villaume Date: Wed, 17 Jan 2024 11:49:45 +0000 Subject: [PATCH 1/5] METK-119 adding new class cerise into language.yaml --- share/metkit/language.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/share/metkit/language.yaml b/share/metkit/language.yaml index be63e201..381b5874 100644 --- a/share/metkit/language.yaml +++ b/share/metkit/language.yaml @@ -12,6 +12,7 @@ _field: &_field - [c3, c3s] - [ce, cems] - [ch, switzerland] + - [ci, cerise] - [co, cosmo] - [cr, cams research] - [cs, ecsn] From d0264e9d4ff9941e16f02a0550ed297456b4e13e Mon Sep 17 00:00:00 2001 From: Emanuele Danovaro Date: Wed, 17 Jan 2024 14:22:27 +0000 Subject: [PATCH 2/5] MARS-931 fix steprange for already archived data --- VERSION | 2 +- src/metkit/mars/StepRange.cc | 32 +++++++++++++++----------------- src/metkit/mars/StepRange.h | 16 ++++++++-------- tests/test_expand.cc | 4 ++++ tests/test_steprange_axis.cc | 30 ++++++++++++++++++++++++++++++ 5 files changed, 58 insertions(+), 26 deletions(-) diff --git a/VERSION b/VERSION index 720c7384..0a5af26d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.11.1 +1.11.3 diff --git a/src/metkit/mars/StepRange.cc b/src/metkit/mars/StepRange.cc index 1763f547..6feed4b3 100644 --- a/src/metkit/mars/StepRange.cc +++ b/src/metkit/mars/StepRange.cc @@ -49,7 +49,6 @@ std::string canonical(const eckit::Time& time) { long m = time.minutes(); long s = time.seconds(); - // std::cout << h << "h" << m << "m" << s << "s\n"; std::string out = ""; if (h!=0 || (m==0 && s==0)) { out += std::to_string(h); @@ -96,17 +95,20 @@ StepRange::operator std::string() const void StepRange::print(std::ostream& s) const { if(from_ == to_) { - s << canonical(from_); + s << canonical(eckit::Time(from_*3600, true)); } else { - TimeUnit unit = std::min(maxUnit(from_), maxUnit(to_)); - s << canonical(from_,unit) << '-' << canonical(to_,unit); + eckit::Time f{static_cast(from_*3600.), true}; + eckit::Time t{static_cast(to_*3600.), true}; + + TimeUnit unit = std::min(maxUnit(f), maxUnit(t)); + s << canonical(f, unit) << '-' << canonical(t, unit); } } StepRange::StepRange(const std::string& s): - from_(0), - to_(0) + from_(0.), + to_(0.) { Tokenizer parse("-"); std::vector result; @@ -116,12 +118,12 @@ StepRange::StepRange(const std::string& s): switch(result.size()) { case 1: - to_ = from_ = eckit::Time(result[0], true); + to_ = from_ = eckit::Time(result[0], true)/3600.; break; case 2: - from_ = eckit::Time(result[0], true); - to_ = eckit::Time(result[1], true); + from_ = eckit::Time(result[0], true)/3600.; + to_ = eckit::Time(result[1], true)/3600.; break; default: @@ -134,18 +136,14 @@ StepRange::StepRange(const std::string& s): void StepRange::dump(DumpLoad& a) const { - a.dump(from_.seconds()/3600.); - a.dump(to_.seconds()/3600.); + a.dump(from_); + a.dump(to_); } void StepRange::load(DumpLoad& a) { - double from, to; - a.load(from); - a.load(to); - - from_ = eckit::Time(from*3600., true); - to_ = eckit::Time(to*3600., true); + a.load(from_); + a.load(to_); } //---------------------------------------------------------------------------------------------------------------------- diff --git a/src/metkit/mars/StepRange.h b/src/metkit/mars/StepRange.h index 72b56714..5026f85f 100644 --- a/src/metkit/mars/StepRange.h +++ b/src/metkit/mars/StepRange.h @@ -34,15 +34,15 @@ class StepRange { StepRange(const std::string&); - StepRange(eckit::Time from = eckit::Time(0), eckit::Time to = eckit::Time(0)): - from_(from),to_(to) { + explicit StepRange(eckit::Time from = eckit::Time(0), eckit::Time to = eckit::Time(0)) : + from_(from/3600.), to_(to/3600.) { - if (from_ != eckit::Time(0) && to_ == eckit::Time(0)) { + if (from != eckit::Time(0) && to == eckit::Time(0)) { to_ = from_; } } - StepRange(double from, double to = 0): + explicit StepRange(double from, double to = 0): StepRange(eckit::Time(from*3600, true), eckit::Time(to*3600, true)) {} @@ -74,8 +74,8 @@ class StepRange { // -- Methods - double from() const { return from_/3600.; } - double to() const { return to_/3600.; } + double from() const { return from_; } + double to() const { return to_; } void dump(eckit::DumpLoad&) const; void load(eckit::DumpLoad&); @@ -115,8 +115,8 @@ class StepRange { // -- Members - eckit::Time from_; - eckit::Time to_; + double from_; + double to_; // -- Methods // None diff --git a/tests/test_expand.cc b/tests/test_expand.cc index ac22bced..5e4ce59e 100644 --- a/tests/test_expand.cc +++ b/tests/test_expand.cc @@ -290,6 +290,10 @@ CASE( "test_metkit_expand_13_step" ) { step({"0:45"}, {"45m"}); step({"0:50"}, {"50m"}); step({"0:55"}, {"55m"}); + step({"0-24"}, {"0-24"}); + step({"0-24s"}, {"0s-24s"}); + step({"0-120s"}, {"0m-2m"}); + step({"0s-120m"}, {"0-2"}); step({"1-2"}, {"1-2"}); step({"30m-1"}, {"30m-60m"}); diff --git a/tests/test_steprange_axis.cc b/tests/test_steprange_axis.cc index fdff3ed4..16c09628 100644 --- a/tests/test_steprange_axis.cc +++ b/tests/test_steprange_axis.cc @@ -34,6 +34,36 @@ namespace test { //----------------------------------------------------------------------------- +CASE("steprange") { + + { + StepRange sr{0,24}; + EXPECT(sr.from()==0); + std::cout << sr.to() << std::endl; + EXPECT(sr.to()==24); + } + { + StepRange sr{"0-24"}; + EXPECT(sr.from()==0); + EXPECT(sr.to()==24); + } + { + StepRange sr{0,.5}; + EXPECT(sr.from()==0); + EXPECT(sr.to()==0.5); + } + { + StepRange sr{"0-30m"}; + EXPECT(sr.from()==0); + EXPECT(sr.to()==0.5); + } + { + StepRange sr{"0-24s"}; + EXPECT(sr.from()==0); + EXPECT(sr.to()==(24./3600.)); + } +} + static void test_steprange_axis( const std::vector& user, From 51e03c20af6ee948c0063162597c02e53acf6324 Mon Sep 17 00:00:00 2001 From: Emanuele Danovaro Date: Mon, 29 Jan 2024 12:47:48 +0000 Subject: [PATCH 3/5] added class=ai --- share/metkit/language.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/share/metkit/language.yaml b/share/metkit/language.yaml index 136db490..859a4a2c 100644 --- a/share/metkit/language.yaml +++ b/share/metkit/language.yaml @@ -7,6 +7,7 @@ _field: &_field flatten: false type: enum values: + - [ai, operational aifs] - [at, austria] - [be, belgium] - [c3, c3s] From 6f8d3426bd6073fce1651277c963dbdc9de359c8 Mon Sep 17 00:00:00 2001 From: Emanuele Danovaro Date: Mon, 29 Jan 2024 12:50:31 +0000 Subject: [PATCH 4/5] version bump --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 0a5af26d..3d0e6231 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.11.3 +1.11.4 From b76820a9f97024965a17b1982738cf468f82d439 Mon Sep 17 00:00:00 2001 From: Emanuele Danovaro Date: Wed, 31 Jan 2024 11:53:34 +0000 Subject: [PATCH 5/5] fix step injection during climate-dt request expansion --- share/metkit/language.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/share/metkit/language.yaml b/share/metkit/language.yaml index 859a4a2c..1a3f8b9c 100644 --- a/share/metkit/language.yaml +++ b/share/metkit/language.yaml @@ -554,6 +554,8 @@ _field: &_field default: 0 type: range never: + - dataset: + - climate-dt - stream: - msmm - mmsa @@ -605,6 +607,9 @@ _field: &_field default: g flatten: false type: enum + never: + - dataset: + - climate-dt values: - [a, north west europe] - [b, north east europe, baltic and black sea]