Skip to content

Commit

Permalink
Fixed missing optional, added levtype/category for ocean and fixed typo
Browse files Browse the repository at this point in the history
  • Loading branch information
stefaniereuter committed Nov 29, 2024
1 parent 2c8d22a commit 4a7bc2a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
10 changes: 6 additions & 4 deletions src/multio/action/statistics/cfg/StatisticsConfiguration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string>(glossary().levtype); levType) {
levType_ = *levType;
} else if ( auto category = md.getOpt<std::string>(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()};
Expand Down Expand Up @@ -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<std::int64_t> timeVal;
if (opt.useDateTime() && (timeVal = md.get<std::int64_t>(glossary().time))) {
if (opt.useDateTime() && (timeVal = md.getOpt<std::int64_t>(glossary().time))) {
time_ = *timeVal;
}
else if (!opt.useDateTime() && (timeVal = md.get<std::int64_t>(glossary().startTime))) {
else if (!opt.useDateTime() && (timeVal = md.getOpt<std::int64_t>(glossary().startTime))) {
time_ = *timeVal;
}
else {
Expand All @@ -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<std::int64_t> dateVal;
if (opt.useDateTime() && (dateVal = md.get<std::int64_t>(glossary().date))) {
if (opt.useDateTime() && (dateVal = md.getOpt<std::int64_t>(glossary().date))) {
date_ = *dateVal;
}
else if (!opt.useDateTime() && (dateVal = md.get<std::int64_t>(glossary().startDate))) {
else if (!opt.useDateTime() && (dateVal = md.getOpt<std::int64_t>(glossary().startDate))) {
date_ = *dateVal;
}
else {
Expand Down
4 changes: 2 additions & 2 deletions src/multio/action/statistics/cfg/StatisticsOptions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_{"."},
Expand Down Expand Up @@ -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;
};

Expand Down
2 changes: 1 addition & 1 deletion src/multio/action/statistics/cfg/StatisticsOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/multio/message/MetadataException.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {};

//-----------------------------------------------------------------------------

Expand Down

0 comments on commit 4a7bc2a

Please sign in to comment.