diff --git a/VERSION b/VERSION index 720c738..3d0e623 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.11.1 +1.11.4 diff --git a/share/metkit/language.yaml b/share/metkit/language.yaml index 79b8165..1a3f8b9 100644 --- a/share/metkit/language.yaml +++ b/share/metkit/language.yaml @@ -7,11 +7,13 @@ _field: &_field flatten: false type: enum values: + - [ai, operational aifs] - [at, austria] - [be, belgium] - [c3, c3s] - [ce, cems] - [ch, switzerland] + - [ci, cerise] - [co, cosmo] - [cr, cams research] - [cs, ecsn] @@ -552,6 +554,8 @@ _field: &_field default: 0 type: range never: + - dataset: + - climate-dt - stream: - msmm - mmsa @@ -603,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] diff --git a/src/metkit/mars/StepRange.cc b/src/metkit/mars/StepRange.cc index 1763f54..6feed4b 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 72b5671..5026f85 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 ac22bce..5e4ce59 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 fdff3ed..16c0962 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,