ECC-1620: New format for special units, e.g., 8x15m

This commit is contained in:
Eugen Betke 2023-11-29 09:37:38 +00:00
parent c515507a26
commit 3bcb5a8cc9
2 changed files with 14 additions and 7 deletions

View File

@ -183,9 +183,16 @@ std::string Step::value<std::string>(const std::string& format) const {
if (unit_ != Unit::Value::HOUR)
u = unit_.value<std::string>();
if (unit_ == Unit::Value::MINUTES15 || unit_ == Unit::Value::MINUTES30)
err = snprintf(output, MAX_SIZE, (format + "(%s)").c_str(), value<double>(), u.c_str());
else
if (unit_ == Unit::Value::MINUTES15 ||
unit_ == Unit::Value::MINUTES30 ||
unit_ == Unit::Value::HOURS3 ||
unit_ == Unit::Value::HOURS6 ||
unit_ == Unit::Value::HOURS12 ||
unit_ == Unit::Value::YEARS10 ||
unit_ == Unit::Value::YEARS30
)
err = snprintf(output, MAX_SIZE, (format + "x%s").c_str(), value<double>(), u.c_str());
else
err = snprintf(output, MAX_SIZE, (format + "%s").c_str(), value<double>(), u.c_str());
if (err < 0 || err >= MAX_SIZE) {

View File

@ -63,11 +63,11 @@ grib_check_key_equals $temp " -w count=1 -s stepUnits=D -p step:i,stepUnits:s" "
grib_check_key_equals $temp " -w count=1 -s stepUnits=s -p step,stepUnits:s" "345600s s"
grib_check_key_equals $temp " -w count=1 -s stepUnits=m -p step,stepUnits:s" "5760m m"
grib_check_key_equals $temp " -w count=1 -s stepUnits=15m -p step,stepUnits:s" "384(15m) 15m"
grib_check_key_equals $temp " -w count=1 -s stepUnits=30m -p step,stepUnits:s" "192(30m) 30m"
grib_check_key_equals $temp " -w count=1 -s stepUnits=15m -p step,stepUnits:s" "384x15m 15m"
grib_check_key_equals $temp " -w count=1 -s stepUnits=30m -p step,stepUnits:s" "192x30m 30m"
grib_check_key_equals $temp " -w count=1 -s stepUnits=h -p step,stepUnits:s" "96 h"
grib_check_key_equals $temp " -w count=1 -s stepUnits=6h -p step,stepUnits:s" "166h 6h" # FIXME(maee) (16(6h) 6h) is correct
grib_check_key_equals $temp " -w count=1 -s stepUnits=12h -p step,stepUnits:s" "812h 12h" # FIXME(maee) (8(12h) 12h) is correct
grib_check_key_equals $temp " -w count=1 -s stepUnits=6h -p step,stepUnits:s" "16x6h 6h"
grib_check_key_equals $temp " -w count=1 -s stepUnits=12h -p step,stepUnits:s" "8x12h 12h"
grib_check_key_equals $temp " -w count=1 -s stepUnits=D -p step,stepUnits:s" "4D D"
${tools_dir}/grib_set -s stepUnits=s,startStep=0,endStep=345600 $fn $temp