From bf6f75ea324efd2ab0efb6563def96d60281eb93 Mon Sep 17 00:00:00 2001 From: Stefanie Reuter Date: Fri, 29 Nov 2024 13:34:53 +0000 Subject: [PATCH] Fix ocean output for climate runs - Fix missing optional - Add levtype/category for ocean - Fix typo --- .../action/statistics/cfg/StatisticsConfiguration.cc | 10 ++++++---- src/multio/action/statistics/cfg/StatisticsOptions.cc | 4 ++-- src/multio/action/statistics/cfg/StatisticsOptions.h | 2 +- src/multio/message/MetadataException.cc | 6 +++--- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/multio/action/statistics/cfg/StatisticsConfiguration.cc b/src/multio/action/statistics/cfg/StatisticsConfiguration.cc index 53e62182f..f20253e0b 100644 --- a/src/multio/action/statistics/cfg/StatisticsConfiguration.cc +++ b/src/multio/action/statistics/cfg/StatisticsConfiguration.cc @@ -94,6 +94,8 @@ void StatisticsConfiguration::readGridType(const message::Metadata& md, const St void StatisticsConfiguration::readLevType(const message::Metadata& md, const StatisticsOptions& opt) { if (auto levType = md.getOpt(glossary().levtype); levType) { levType_ = *levType; + } else if ( auto category = md.getOpt(glossary().category); category) { + levType_ = *category;//TODO this needs proper handling once category is changed to levtype } else { throw eckit::SeriousBug{"LevType metadata not present", Here()}; @@ -130,10 +132,10 @@ void StatisticsConfiguration::readLevel(const message::Metadata& md, const Stati void StatisticsConfiguration::readStartTime(const message::Metadata& md, const StatisticsOptions& opt) { std::optional timeVal; - if (opt.useDateTime() && (timeVal = md.get(glossary().time))) { + if (opt.useDateTime() && (timeVal = md.getOpt(glossary().time))) { time_ = *timeVal; } - else if (!opt.useDateTime() && (timeVal = md.get(glossary().startTime))) { + else if (!opt.useDateTime() && (timeVal = md.getOpt(glossary().startTime))) { time_ = *timeVal; } else { @@ -144,10 +146,10 @@ void StatisticsConfiguration::readStartTime(const message::Metadata& md, const S void StatisticsConfiguration::readStartDate(const message::Metadata& md, const StatisticsOptions& opt) { std::optional dateVal; - if (opt.useDateTime() && (dateVal = md.get(glossary().date))) { + if (opt.useDateTime() && (dateVal = md.getOpt(glossary().date))) { date_ = *dateVal; } - else if (!opt.useDateTime() && (dateVal = md.get(glossary().startDate))) { + else if (!opt.useDateTime() && (dateVal = md.getOpt(glossary().startDate))) { date_ = *dateVal; } else { diff --git a/src/multio/action/statistics/cfg/StatisticsOptions.cc b/src/multio/action/statistics/cfg/StatisticsOptions.cc index 22d81a6f9..07c7460c5 100644 --- a/src/multio/action/statistics/cfg/StatisticsOptions.cc +++ b/src/multio/action/statistics/cfg/StatisticsOptions.cc @@ -11,7 +11,7 @@ StatisticsOptions::StatisticsOptions( const config::ComponentConfiguration& comp readRestart_{false}, writeRestart_{false}, debugRestart_{false}, - useDateTime_{true}, + useDateTime_{false}, clientSideStatistics_{false}, restartTime_{"latest"},//00000000-000000 restartPath_{"."}, @@ -58,7 +58,7 @@ StatisticsOptions::StatisticsOptions( const config::ComponentConfiguration& comp void StatisticsOptions::parseUseDateTime(const eckit::LocalConfiguration& cfg) { // Distance in steps between two messages - useDateTime_ = cfg.getLong("use-date-time", true ); + useDateTime_ = cfg.getLong("use-current-time", false ); return; }; diff --git a/src/multio/action/statistics/cfg/StatisticsOptions.h b/src/multio/action/statistics/cfg/StatisticsOptions.h index 9c0d13932..5d26f7b18 100644 --- a/src/multio/action/statistics/cfg/StatisticsOptions.h +++ b/src/multio/action/statistics/cfg/StatisticsOptions.h @@ -63,7 +63,7 @@ class StatisticsOptions{ const std::string& logPrefix() const; const std::string& windowType() const; - bool useDateTime() const { return true; }; + bool useDateTime() const { return useDateTime_; }; // Handle missing value const std::string& bitmapPresentKey() const; diff --git a/src/multio/message/MetadataException.cc b/src/multio/message/MetadataException.cc index f1843993b..365fe2804 100644 --- a/src/multio/message/MetadataException.cc +++ b/src/multio/message/MetadataException.cc @@ -15,16 +15,16 @@ MetadataMissingKeyException::MetadataMissingKeyException(const std::string& miss MetadataKeyException(missingKey, std::string("missing"), l) {}; MetadataWrongTypeException::MetadataWrongTypeException(const std::string& key, const eckit::CodeLocation& l) : - MetadataException(std::string("differet key type contained for \"") + key + std::string("\""), l) {}; + MetadataException(std::string("different key type contained for \"") + key + std::string("\""), l) {}; MetadataWrongTypeException::MetadataWrongTypeException(std::size_t requestedIndex, std::size_t containedIndex, const eckit::CodeLocation& l) : - MetadataException(std::string("differet key type contained. Requested index: ") + std::to_string(requestedIndex) + MetadataException(std::string("different key type contained. Requested index: ") + std::to_string(requestedIndex) + std::string(" contained index: ") + std::to_string(containedIndex), l) {}; MetadataWrongTypeException::MetadataWrongTypeException(const eckit::CodeLocation& l) : - MetadataException(std::string("differet key type contained"), l) {}; + MetadataException(std::string("different key type contained"), l) {}; //-----------------------------------------------------------------------------