ECC-1620: Recompute optimal step units for each message

This commit is contained in:
Eugen Betke 2023-09-04 13:01:19 +00:00
parent b2c8b6876d
commit a08c2cec4a
8 changed files with 257 additions and 290 deletions

View File

@ -14,8 +14,9 @@ codetable[1] indicatorOfUnitOfTimeRange ('4.4.table',masterDir,localDir) : dump
#alias forecastTimeUnit = indicatorOfUnitOfTimeRange;
#template_nofail default_step_units "grib2/localConcepts/[centre:s]/default_step_units.def";
#codetable[1] stepUnits 'stepUnits.table' = defaultStepUnits : transient,dump,no_copy;
transient useOptimalStepUnits = 0;
meta stepUnits optimal_step_units(forecastTime,indicatorOfUnitOfTimeRange,lengthOfTimeRange,indicatorOfUnitForTimeRange) : dump;
codetable[1] stepUnits 'stepUnits.table' = 255 : transient,dump,no_copy;
#transient useOptimalStepUnits = 0;
meta optimalStepUnits optimal_step_units(forecastTime,indicatorOfUnitOfTimeRange,lengthOfTimeRange,indicatorOfUnitForTimeRange) : dump;
# Forecast time in units defined by previous octet (GRIB-29: supports negative forecast time)
signed[4] forecastTime : dump;

View File

@ -281,8 +281,9 @@ static int unpack_one_time_range_long_(grib_accessor* a, long* val, size_t* len)
if ((err = grib_get_long_internal(h, self->start_step_value, &start_step_value)))
return err;
if ((err = grib_get_long_internal(h, self->step_units, &step_units)))
return err;
//if ((err = grib_get_long_internal(h, self->step_units, &step_units)))
//return err;
step_units = get_step_units(h);
if ((err = grib_get_long_internal(h, self->time_range_unit, &time_range_unit)))
return err;
if ((err = grib_get_long_internal(h, self->time_range_value, &time_range_value)))
@ -328,8 +329,9 @@ static int unpack_multiple_time_ranges_long_(grib_accessor* a, long* val, size_t
if ((err = grib_get_long_internal(h, self->start_step_value, &start_step_value)))
return err;
if ((err = grib_get_long_internal(h, self->step_units, &step_units)))
return err;
//if ((err = grib_get_long_internal(h, self->step_units, &step_units)))
//return err;
step_units = get_step_units(h);
if ((err = grib_get_long_internal(h, self->numberOfTimeRange, &numberOfTimeRange)))
return err;
if (numberOfTimeRange > MAX_NUM_TIME_RANGES) {
@ -441,8 +443,9 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len)
if ((err = grib_get_long_internal(h, self->time_range_unit, &time_range_unit)))
return err;
if ((err = grib_get_long_internal(h, self->step_units, &step_units)))
return err;
//if ((err = grib_get_long_internal(h, self->step_units, &step_units)))
//return err;
step_units = get_step_units(h);
if ((err = grib_get_long_internal(h, self->year, &year)))
return err;
if ((err = grib_get_long_internal(h, self->month, &month)))
@ -562,19 +565,20 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len)
return ret;
long step_units;
if ((ret = grib_get_long_internal(h, self->step_units, &step_units)) != GRIB_SUCCESS)
return ret;
//if ((ret = grib_get_long_internal(h, self->step_units, &step_units)) != GRIB_SUCCESS)
//return ret;
step_units = get_step_units(h);
Step step(step_value, step_units);
step.set_unit(step_units);
step.hide_hour_unit();
if (is_future_output_enabled(h)) {
//if (is_future_output_enabled(h)) {
snprintf(val, *len, "%s", step.to_string().c_str());
}
else {
snprintf(val, *len, "%ld", step.value<long>());
}
//}
//else {
// snprintf(val, *len, "%ld", step.value<long>());
//}
return GRIB_SUCCESS;
}

View File

@ -146,25 +146,26 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len)
if ((ret = grib_get_long_internal(h, self->start_step, &end_start_value)) != GRIB_SUCCESS)
return ret;
if ((ret = grib_get_long_internal(h, "stepUnits", &step_units)) != GRIB_SUCCESS)
return ret;
//if ((ret = grib_get_long_internal(h, "stepUnits", &step_units)) != GRIB_SUCCESS)
// return ret;
step_units = get_step_units(h);
Step start_step{end_start_value, step_units};
start_step.hide_hour_unit();
if (self->end_step == NULL) {
if (is_future_output_enabled(h)) {
//if (is_future_output_enabled(h)) {
snprintf(buf, sizeof(buf), "%s", start_step.to_string().c_str());
}
else {
snprintf(buf, sizeof(buf), "%ld", end_start_value);
}
//}
//else {
// snprintf(buf, sizeof(buf), "%ld", end_start_value);
//}
}
else {
if ((ret = grib_get_long_internal(h, self->end_step, &end_step_value)) != GRIB_SUCCESS)
return ret;
if (is_future_output_enabled(h)) {
//if (is_future_output_enabled(h)) {
Step end_step{end_step_value, step_units};
end_step.hide_hour_unit();
if (end_start_value == end_step_value) {
@ -173,15 +174,15 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len)
else {
snprintf(buf, sizeof(buf), "%s-%s", start_step.to_string().c_str(), end_step.to_string().c_str());
}
}
else {
if (end_start_value == end_step_value) {
snprintf(buf, sizeof(buf), "%ld", end_step_value);
}
else {
snprintf(buf, sizeof(buf), "%ld-%ld", end_start_value, end_step_value);
}
}
//}
//else {
// if (end_start_value == end_step_value) {
// snprintf(buf, sizeof(buf), "%ld", end_step_value);
// }
// else {
// snprintf(buf, sizeof(buf), "%ld-%ld", end_start_value, end_step_value);
// }
//}
}
@ -259,13 +260,13 @@ static int pack_string_new(grib_accessor* a, const char* val, size_t* len)
static int pack_string(grib_accessor* a, const char* val, size_t* len)
{
grib_handle* h = grib_handle_of_accessor(a);
if (is_future_output_enabled(h)) {
//grib_handle* h = grib_handle_of_accessor(a);
//if (is_future_output_enabled(h)) {
return pack_string_new(a, val, len);
}
else {
return pack_string_old(a, val, len);
}
//}
//else {
// return pack_string_old(a, val, len);
//}
}
static int value_count(grib_accessor* a, long* count)
@ -300,8 +301,9 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
if ((ret = grib_get_long_internal(h, self->start_step, &end_start_value)) != GRIB_SUCCESS)
return ret;
if ((ret = grib_get_long_internal(h, "stepUnits", &step_units)) != GRIB_SUCCESS)
return ret;
//if ((ret = grib_get_long_internal(h, "stepUnits", &step_units)) != GRIB_SUCCESS)
// return ret;
step_units = get_step_units(h);
Step start_step{end_start_value, step_units};
start_step.hide_hour_unit();

View File

@ -21,9 +21,9 @@
START_CLASS_DEF
CLASS = accessor
SUPER = grib_accessor_class_gen
IMPLEMENTS = pack_long;unpack_long;dump
IMPLEMENTS = pack_string;unpack_string;dump
IMPLEMENTS = get_native_type;string_length
IMPLEMENTS = unpack_long;dump
IMPLEMENTS = unpack_string;dump
IMPLEMENTS = string_length
IMPLEMENTS = init
MEMBERS = const char* forecast_time_value
MEMBERS = const char* forecast_time_unit
@ -84,13 +84,13 @@ static grib_accessor_class _grib_accessor_class_optimal_step_units = {
0, /* get sub_section */
0, /* pack_missing */
0, /* is_missing */
&pack_long, /* pack_long */
0, /* pack_long */
&unpack_long, /* unpack_long */
0, /* pack_double */
0, /* pack_float */
0, /* unpack_double */
0, /* unpack_float */
&pack_string, /* pack_string */
0, /* pack_string */
&unpack_string, /* unpack_string */
0, /* pack_string_array */
0, /* unpack_string_array */
@ -150,19 +150,19 @@ static size_t string_length(grib_accessor* a)
static long staticStepUnits = UnitType{Unit::MISSING}.to_long();
static int pack_long(grib_accessor* a, const long* val, size_t* len)
{
staticStepUnits = *val;
//static int pack_long(grib_accessor* a, const long* val, size_t* len)
//{
// staticStepUnits = *val;
return GRIB_SUCCESS;
}
// return GRIB_SUCCESS;
//}
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{
if (staticStepUnits != 255) {
*val = staticStepUnits;
return GRIB_SUCCESS;
}
//if (staticStepUnits != 255) {
// *val = staticStepUnits;
// return GRIB_SUCCESS;
//}
grib_accessor_optimal_step_units* self = (grib_accessor_optimal_step_units*)a;
grib_handle* h = grib_handle_of_accessor(a);
@ -183,11 +183,11 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
}
static int pack_string(grib_accessor* a, const char* val, size_t* len)
{
staticStepUnits = UnitType{val}.to_long();
return GRIB_SUCCESS;
}
//static int pack_string(grib_accessor* a, const char* val, size_t* len)
//{
// staticStepUnits = UnitType{val}.to_long();
// return GRIB_SUCCESS;
//}
static int unpack_string(grib_accessor* a, char* val, size_t* len)
{

View File

@ -184,8 +184,9 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
if ((err = grib_get_long_internal(h, self->forecast_time_unit, &forecast_time_unit)))
return err;
if ((err = grib_get_long_internal(h, self->step_units, &step_units)))
return err;
//if ((err = grib_get_long_internal(h, self->step_units, &step_units)))
// return err;
step_units = get_step_units(h);
if ((err = grib_get_long_internal(h, self->forecast_time_value, &forecast_time_value)))
return err;
@ -229,8 +230,9 @@ int pack_long_old_(grib_accessor* a, const long* val, size_t* len) {
if ((err = grib_get_long_internal(h, self->forecast_time_unit, &forecast_time_unit)))
return err;
if ((err = grib_get_long_internal(h, self->step_units, &step_units)))
return err;
//if ((err = grib_get_long_internal(h, self->step_units, &step_units)))
// return err;
step_units = get_step_units(h);
unpack_long(a, &oldStep, len);
@ -286,8 +288,9 @@ int pack_long_new_(grib_accessor* a, const long* val, size_t* len) {
return err;
if ((err = unpack_long(a, &start_step_value_old, len)) != GRIB_SUCCESS)
return err;
if ((err = grib_get_long_internal(h, self->step_units, &step_units)) != GRIB_SUCCESS)
return err;
//if ((err = grib_get_long_internal(h, self->step_units, &step_units)) != GRIB_SUCCESS)
//return err;
step_units = get_step_units(h);
Step start_step_old(start_step_value_old, step_units);
Step forecast_time(*val, step_units);
Step time_range_new{};
@ -315,12 +318,12 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len)
{
grib_handle* h = grib_handle_of_accessor(a);
int ret;
if (is_future_output_enabled(h)) {
//if (is_future_output_enabled(h)) {
ret = pack_long_new_(a, val, len);
}
else {
ret = pack_long_old_(a, val, len);
}
//}
//else {
// ret = pack_long_old_(a, val, len);
//}
return ret;
}
@ -334,8 +337,9 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len)
Step step = step_from_string(val);
long step_units;
if ((ret = grib_get_long_internal(h, self->step_units, &step_units)) != GRIB_SUCCESS)
return ret;
//if ((ret = grib_get_long_internal(h, self->step_units, &step_units)) != GRIB_SUCCESS)
// return ret;
step_units = get_step_units(h);
long value = step.value<long>();
@ -358,19 +362,20 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len)
return ret;
long step_units;
if ((ret = grib_get_long_internal(h, self->step_units, &step_units)) != GRIB_SUCCESS)
return ret;
//if ((ret = grib_get_long_internal(h, self->step_units, &step_units)) != GRIB_SUCCESS)
// return ret;
step_units = get_step_units(h);
Step step{value, step_units};
step.hide_hour_unit();
//snprintf(val, *len, "%ld", value);
if (is_future_output_enabled(h)) {
//if (is_future_output_enabled(h)) {
snprintf(val, *len, "%s", step.to_string().c_str());
}
else {
snprintf(val, *len, "%ld", step.value<long>());
}
//}
//else {
// snprintf(val, *len, "%ld", step.value<long>());
//}
return GRIB_SUCCESS;
}

View File

@ -43,3 +43,18 @@ bool is_future_output_enabled(grib_handle* h)
return ret;
return strcmp(step_output_format, "future") == 0;
}
long get_step_units(grib_handle* h)
{
int ret = 0;
long step_units = 0;
if ((ret = grib_get_long_internal(h, "stepUnits", &step_units)) != GRIB_SUCCESS)
throw std::runtime_error("Failed to get stepUnits");
if (step_units == 255) {
if((ret = grib_get_long_internal(h, "optimalStepUnits", &step_units)) != GRIB_SUCCESS)
throw std::runtime_error("Failed to get optimalStepUnits");
}
return step_units;
}

View File

@ -7,6 +7,7 @@
std::optional<Step> get_step(grib_handle* h, const std::string& value_key, const std::string& unit_key);
bool is_future_output_enabled(grib_handle* h);
int set_step(grib_handle* h, const std::string& value_key, const std::string& unit_key, const Step& step);
long get_step_units(grib_handle* h);
//template <typename T>
//int set_step(grib_handle* h, const std::string& value_key, const std::string& unit_key, const Step& step)

View File

@ -52,18 +52,18 @@ temp2=temp_2.$label
##high_level_keys="startStep:s,endStep:s"
#high_level_keys="startStep:i,endStep:i"
#${tools_dir}/grib_set -s forecastTime=24,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=1,indicatorOfUnitForTimeRange=D $fn $temp
#grib_check_key_equals $temp "-y -p $low_level_keys" "24 h 1 D"
#grib_check_key_equals $temp "-y -p $high_level_keys" "24 48"
#${tools_dir}/grib_set -y -s startStep:i=24 $temp $temp2
#grib_check_key_equals $temp2 "-y -p $low_level_keys" "24 h 0 h"
#grib_check_key_equals $temp2 "-y -p $high_level_keys" "24 24"
#grib_check_key_equals $temp "-p $low_level_keys" "24 h 1 D"
#grib_check_key_equals $temp "-p $high_level_keys" "24 48"
#${tools_dir}/grib_set -s startStep:i=24 $temp $temp2
#grib_check_key_equals $temp2 "-p $low_level_keys" "24 h 0 h"
#grib_check_key_equals $temp2 "-p $high_level_keys" "24 24"
#${tools_dir}/grib_set -s forecastTime=24,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=24,indicatorOfUnitForTimeRange=h $fn $temp
#grib_check_key_equals $temp "-y -p $low_level_keys" "24 h 24 h"
#grib_check_key_equals $temp "-y -p $high_level_keys" "24 48"
#${tools_dir}/grib_set -y -s startStep:i=24 $temp $temp2
#grib_check_key_equals $temp2 "-y -p $low_level_keys" "24 h 24 h"
#grib_check_key_equals $temp2 "-y -p $high_level_keys" "24 48"
#grib_check_key_equals $temp "-p $low_level_keys" "24 h 24 h"
#grib_check_key_equals $temp "-p $high_level_keys" "24 48"
#${tools_dir}/grib_set -s startStep:i=24 $temp $temp2
#grib_check_key_equals $temp2 "-p $low_level_keys" "24 h 24 h"
#grib_check_key_equals $temp2 "-p $high_level_keys" "24 48"
#exit
@ -74,73 +74,73 @@ ${tools_dir}/grib_set -s forecastTime=24,indicatorOfUnitOfTimeRange=h,lengthOfTi
grib_check_key_equals $temp "-p $low_level_keys" "24 h 1 D"
# Use range unit: hour
${tools_dir}/grib_set -y -s endStep:d=30 $temp $temp2 # TODO(EB) remove in the future behavior
#${tools_dir}/grib_set -y -s endStep:i=30 $temp $temp2 # TODO(EB) keep for backwards compatibility
#${tools_dir}/grib_set -y -s endStep:s=30 $temp $temp2
#${tools_dir}/grib_set -y -s endStep:s=30h $temp $temp2
#${tools_dir}/grib_set -y -s endStep=30h $temp $temp2 # TODO(EB) add to tests
grib_check_key_equals $temp2 "-y -p $low_level_keys" "24 h 6 h"
#${tools_dir}/grib_set -y -s endStep:d=24.5 $temp $temp2
#grib_check_key_equals $temp2 "-y -p $low_level_keys" "24 h 30 m"
${tools_dir}/grib_set -s endStep:d=30 $temp $temp2 # TODO(EB) remove in the future behavior
#${tools_dir}/grib_set -s endStep:i=30 $temp $temp2 # TODO(EB) keep for backwards compatibility
#${tools_dir}/grib_set -s endStep:s=30 $temp $temp2
#${tools_dir}/grib_set -s endStep:s=30h $temp $temp2
#${tools_dir}/grib_set -s endStep=30h $temp $temp2 # TODO(EB) add to tests
grib_check_key_equals $temp2 "-p $low_level_keys" "24 h 6 h"
#${tools_dir}/grib_set -s endStep:d=24.5 $temp $temp2
#grib_check_key_equals $temp2 "-p $low_level_keys" "24 h 30 m"
# Use stepUnits
${tools_dir}/grib_set -y -s endStep:s=30 $temp $temp2
${tools_dir}/grib_set -y -s endStep:s=30h $temp $temp2
grib_check_key_equals $temp2 "-y -p $low_level_keys" "24 h 6 h"
#${tools_dir}/grib_set -y -s endStep:s=24.5h $temp $temp2
#grib_check_key_equals $temp2 "-y -p $low_level_keys" "24 h 30 m"
${tools_dir}/grib_set -y -s endStep:s=88200s $temp $temp2
grib_check_key_equals $temp2 "-y -p $low_level_keys" "1440 m 30 m"
#${tools_dir}/grib_set -y -s endStep:s=1446.65m $temp $temp2
#grib_check_key_equals $temp2 "-y -p $low_level_keys" "24 h 399 s"
${tools_dir}/grib_set -y -s endStep:s=24024 $temp $temp2
grib_check_key_equals $temp2 "-y -p $low_level_keys" "24 h 24000 h"
${tools_dir}/grib_set -s endStep:s=30 $temp $temp2
${tools_dir}/grib_set -s endStep:s=30h $temp $temp2
grib_check_key_equals $temp2 "-p $low_level_keys" "24 h 6 h"
#${tools_dir}/grib_set -s endStep:s=24.5h $temp $temp2
#grib_check_key_equals $temp2 "-p $low_level_keys" "24 h 30 m"
${tools_dir}/grib_set -s endStep:s=88200s $temp $temp2
grib_check_key_equals $temp2 "-p $low_level_keys" "1440 m 30 m"
#${tools_dir}/grib_set -s endStep:s=1446.65m $temp $temp2
#grib_check_key_equals $temp2 "-p $low_level_keys" "24 h 399 s"
${tools_dir}/grib_set -s endStep:s=24024 $temp $temp2
grib_check_key_equals $temp2 "-p $low_level_keys" "24 h 24000 h"
# Use range unit: hour
${tools_dir}/grib_set -y -s startStep:d=5 $temp $temp2
grib_check_key_equals $temp2 "-y -p $low_level_keys" "5 h 43 h"
#${tools_dir}/grib_set -y -s startStep:d=4.5 $temp $temp2
#grib_check_key_equals $temp2 "-y -p $low_level_keys" "270 m 1 D"
${tools_dir}/grib_set -s startStep:d=5 $temp $temp2
grib_check_key_equals $temp2 "-p $low_level_keys" "5 h 43 h"
#${tools_dir}/grib_set -s startStep:d=4.5 $temp $temp2
#grib_check_key_equals $temp2 "-p $low_level_keys" "270 m 1 D"
# Use stepUnits
${tools_dir}/grib_set -y -s startStep:s=5h $temp $temp2
grib_check_key_equals $temp2 "-y -p $low_level_keys" "5 h 43 h"
#${tools_dir}/grib_set -y -s startStep:s=4.5h $temp $temp2
#grib_check_key_equals $temp2 "-y -p $low_level_keys" "270 m 1 D"
${tools_dir}/grib_set -y -s startStep:s=240s $temp $temp2
grib_check_key_equals $temp2 "-y -p $low_level_keys" "4 m 2876 m"
#${tools_dir}/grib_set -y -s startStep:s=0.65m $temp $temp2
#grib_check_key_equals $temp2 "-y -p $low_level_keys" "39 s 1 D"
${tools_dir}/grib_set -y -s startStep:s=2 $temp $temp2
grib_check_key_equals $temp2 "-y -p $low_level_keys" "2 h 46 h"
${tools_dir}/grib_set -s startStep:s=5h $temp $temp2
grib_check_key_equals $temp2 "-p $low_level_keys" "5 h 43 h"
#${tools_dir}/grib_set -s startStep:s=4.5h $temp $temp2
#grib_check_key_equals $temp2 "-p $low_level_keys" "270 m 1 D"
${tools_dir}/grib_set -s startStep:s=240s $temp $temp2
grib_check_key_equals $temp2 "-p $low_level_keys" "4 m 2876 m"
#${tools_dir}/grib_set -s startStep:s=0.65m $temp $temp2
#grib_check_key_equals $temp2 "-p $low_level_keys" "39 s 1 D"
${tools_dir}/grib_set -s startStep:s=2 $temp $temp2
grib_check_key_equals $temp2 "-p $low_level_keys" "2 h 46 h"
${tools_dir}/grib_set -y -s stepRange:s=5h-30h $temp $temp2
grib_check_key_equals $temp2 "-y -p $low_level_keys" "5 h 25 h"
grib_check_key_equals $temp2 "-y -p stepRange:s" "5-30"
${tools_dir}/grib_set -s stepRange:s=5h-30h $temp $temp2
grib_check_key_equals $temp2 "-p $low_level_keys" "5 h 25 h"
grib_check_key_equals $temp2 "-p stepRange:s" "5-30"
${tools_dir}/grib_set -y -s stepRange:s=5-30 $temp $temp2
grib_check_key_equals $temp2 "-y -p $low_level_keys" "5 h 25 h"
grib_check_key_equals $temp2 "-y -p stepRange:s" "5-30"
${tools_dir}/grib_set -s stepRange:s=5-30 $temp $temp2
grib_check_key_equals $temp2 "-p $low_level_keys" "5 h 25 h"
grib_check_key_equals $temp2 "-p stepRange:s" "5-30"
${tools_dir}/grib_set -y -s stepRange:s=60m-120m $temp $temp2
grib_check_key_equals $temp2 "-y -p $low_level_keys" "1 h 1 h"
grib_check_key_equals $temp2 "-y -p stepRange:s" "1-2"
${tools_dir}/grib_set -s stepRange:s=60m-120m $temp $temp2
grib_check_key_equals $temp2 "-p $low_level_keys" "1 h 1 h"
grib_check_key_equals $temp2 "-p stepRange:s" "1-2"
${tools_dir}/grib_set -y -s stepRange:s=60s-120s $temp $temp2
grib_check_key_equals $temp2 "-y -p $low_level_keys" "1 m 1 m"
grib_check_key_equals $temp2 "-y -p stepRange:s" "1m-2m"
${tools_dir}/grib_set -s stepRange:s=60s-120s $temp $temp2
grib_check_key_equals $temp2 "-p $low_level_keys" "1 m 1 m"
grib_check_key_equals $temp2 "-p stepRange:s" "1m-2m"
${tools_dir}/grib_set -y -s stepRange:s=60m-121m $temp $temp2
grib_check_key_equals $temp2 "-y -p $low_level_keys" "60 m 61 m"
grib_check_key_equals $temp2 "-y -p stepRange:s" "60m-121m"
${tools_dir}/grib_set -s stepRange:s=60m-121m $temp $temp2
grib_check_key_equals $temp2 "-p $low_level_keys" "60 m 61 m"
grib_check_key_equals $temp2 "-p stepRange:s" "60m-121m"
${tools_dir}/grib_set -y -s stepRange:s=62D-122D $temp $temp2
grib_check_key_equals $temp2 "-y -p $low_level_keys" "1488 h 1440 h"
grib_check_key_equals $temp2 "-y -p stepRange:s" "1488-2928"
${tools_dir}/grib_set -s stepRange:s=62D-122D $temp $temp2
grib_check_key_equals $temp2 "-p $low_level_keys" "1488 h 1440 h"
grib_check_key_equals $temp2 "-p stepRange:s" "1488-2928"
@ -153,27 +153,27 @@ keys_d="step:d"
${tools_dir}/grib_set -s forecastTime=59,indicatorOfUnitOfTimeRange=m $fn $temp
grib_check_key_equals $temp "-y -p $keys__ -s stepUnits=s" "3540"
grib_check_key_equals $temp "-y -p $keys__ -s stepUnits=m" "59"
#grib_check_key_equals $temp "-y -p $keys__ -s stepUnits=h" "0" # TODO(EB): check behaviour (should be 0.983333)
grib_check_key_equals $temp "-y -p $keys_s -s stepUnits=s" "3540s"
grib_check_key_equals $temp "-y -p $keys_s -s stepUnits=m" "59m"
#grib_check_key_equals $temp "-y -p $keys_s -F"%.2f" -s stepUnits=h" "0.983333" # TODO(EB): check behaviour // See tools for default output format
grib_check_key_equals $temp "-y -p $keys_i -s stepUnits=s" "3540"
grib_check_key_equals $temp "-y -p $keys_i -s stepUnits=m" "59"
#grib_check_key_equals $temp "-y -p $keys_i -s stepUnits=h" "0" # TODO(EB): check behaviour
grib_check_key_equals $temp "-y -p $keys_d -s stepUnits=s" "3540"
grib_check_key_equals $temp "-y -p $keys_d -s stepUnits=m" "59"
#grib_check_key_equals $temp "-y -p $keys_d -s stepUnits=h" "0.983333" # TODO(EB): check behaviour
grib_check_key_equals $temp "-p $keys__ -s stepUnits=s" "3540"
grib_check_key_equals $temp "-p $keys__ -s stepUnits=m" "59"
#grib_check_key_equals $temp "-p $keys__ -s stepUnits=h" "0" # TODO(EB): check behaviour (should be 0.983333)
grib_check_key_equals $temp "-p $keys_s -s stepUnits=s" "3540s"
grib_check_key_equals $temp "-p $keys_s -s stepUnits=m" "59m"
#grib_check_key_equals $temp "-p $keys_s -F"%.2f" -s stepUnits=h" "0.983333" # TODO(EB): check behaviour // See tools for default output format
grib_check_key_equals $temp "-p $keys_i -s stepUnits=s" "3540"
grib_check_key_equals $temp "-p $keys_i -s stepUnits=m" "59"
#grib_check_key_equals $temp "-p $keys_i -s stepUnits=h" "0" # TODO(EB): check behaviour
grib_check_key_equals $temp "-p $keys_d -s stepUnits=s" "3540"
grib_check_key_equals $temp "-p $keys_d -s stepUnits=m" "59"
#grib_check_key_equals $temp "-p $keys_d -s stepUnits=h" "0.983333" # TODO(EB): check behaviour
${tools_dir}/grib_set -s forecastTime=0,indicatorOfUnitOfTimeRange=m $fn $temp
grib_check_key_equals $temp "-y -p $keys_i -s stepUnits=s" "0"
grib_check_key_equals $temp "-y -p $keys_i -s stepUnits=m" "0"
grib_check_key_equals $temp "-y -p $keys_i -s stepUnits=h" "0"
grib_check_key_equals $temp "-y -p $keys_d -s stepUnits=s" "0"
grib_check_key_equals $temp "-y -p $keys_d -s stepUnits=m" "0"
grib_check_key_equals $temp "-y -p $keys_d -s stepUnits=h" "0"
grib_check_key_equals $temp "-p $keys_i -s stepUnits=s" "0"
grib_check_key_equals $temp "-p $keys_i -s stepUnits=m" "0"
grib_check_key_equals $temp "-p $keys_i -s stepUnits=h" "0"
grib_check_key_equals $temp "-p $keys_d -s stepUnits=s" "0"
grib_check_key_equals $temp "-p $keys_d -s stepUnits=m" "0"
grib_check_key_equals $temp "-p $keys_d -s stepUnits=h" "0"
@ -188,82 +188,60 @@ keys_d="step:d"
${tools_dir}/grib_set -s forecastTime=0,indicatorOfUnitOfTimeRange=m $fn $temp
grib_check_key_equals $temp "-p $low_level_keys" "0 m"
grib_check_key_equals $temp "-p $keys__" "0"
grib_check_key_equals $temp "-y -p $keys__" "0"
grib_check_key_equals $temp "-p $keys_s" "0"
grib_check_key_equals $temp "-y -p $keys_s" "0"
grib_check_key_equals $temp "-p $keys_i" "0"
grib_check_key_equals $temp "-y -p $keys_i" "0"
grib_check_key_equals $temp "-p $keys_d" "0"
grib_check_key_equals $temp "-y -p $keys_d" "0"
grib_check_key_equals $temp "-y -p $keys__ -s stepUnits=s" "0"
grib_check_key_equals $temp "-y -p $keys__ -s stepUnits=m" "0"
grib_check_key_equals $temp "-y -p $keys__ -s stepUnits=h" "0"
grib_check_key_equals $temp "-y -p $keys_s -s stepUnits=s" "0s"
grib_check_key_equals $temp "-y -p $keys_s -s stepUnits=m" "0m"
grib_check_key_equals $temp "-y -p $keys_s -s stepUnits=h" "0"
grib_check_key_equals $temp "-y -p $keys_i -s stepUnits=s" "0"
grib_check_key_equals $temp "-y -p $keys_i -s stepUnits=m" "0"
grib_check_key_equals $temp "-y -p $keys_i -s stepUnits=h" "0"
grib_check_key_equals $temp "-y -p $keys_d -s stepUnits=s" "0"
grib_check_key_equals $temp "-y -p $keys_d -s stepUnits=m" "0"
grib_check_key_equals $temp "-y -p $keys_d -s stepUnits=h" "0"
grib_check_key_equals $temp "-p $keys__ -s stepUnits=s" "0"
grib_check_key_equals $temp "-p $keys__ -s stepUnits=m" "0"
grib_check_key_equals $temp "-p $keys__ -s stepUnits=h" "0"
grib_check_key_equals $temp "-p $keys_s -s stepUnits=s" "0s"
grib_check_key_equals $temp "-p $keys_s -s stepUnits=m" "0m"
grib_check_key_equals $temp "-p $keys_s -s stepUnits=h" "0"
grib_check_key_equals $temp "-p $keys_i -s stepUnits=s" "0"
grib_check_key_equals $temp "-p $keys_i -s stepUnits=m" "0"
grib_check_key_equals $temp "-p $keys_i -s stepUnits=h" "0"
grib_check_key_equals $temp "-p $keys_d -s stepUnits=s" "0"
grib_check_key_equals $temp "-p $keys_d -s stepUnits=m" "0"
grib_check_key_equals $temp "-p $keys_d -s stepUnits=h" "0"
${tools_dir}/grib_set -s forecastTime=59,indicatorOfUnitOfTimeRange=m $fn $temp
grib_check_key_equals $temp "-p $low_level_keys" "59 m"
grib_check_key_equals $temp "-p $keys__" "59"
grib_check_key_equals $temp "-y -p $keys__" "59"
grib_check_key_equals $temp "-p $keys_s" "59"
grib_check_key_equals $temp "-y -p $keys_s" "59m"
#grib_check_key_equals $temp "-p $keys_s" "59"
grib_check_key_equals $temp "-p $keys_s" "59m"
grib_check_key_equals $temp "-p $keys_i" "59"
grib_check_key_equals $temp "-y -p $keys_i" "59"
grib_check_key_equals $temp "-p $keys_d" "59"
grib_check_key_equals $temp "-y -p $keys_d" "59"
${tools_dir}/grib_set -s forecastTime=60,indicatorOfUnitOfTimeRange=m $fn $temp
grib_check_key_equals $temp "-p $low_level_keys" "60 m"
grib_check_key_equals $temp "-p $keys__" "1"
grib_check_key_equals $temp "-y -p $keys__" "1"
grib_check_key_equals $temp "-p $keys_s" "1"
grib_check_key_equals $temp "-y -p $keys_s" "1"
grib_check_key_equals $temp "-p $keys_i" "1"
grib_check_key_equals $temp "-y -p $keys_i" "1"
grib_check_key_equals $temp "-p $keys_d" "1"
grib_check_key_equals $temp "-y -p $keys_d" "1"
${tools_dir}/grib_set -s forecastTime=61,indicatorOfUnitOfTimeRange=m $fn $temp
grib_check_key_equals $temp "-p $low_level_keys" "61 m"
grib_check_key_equals $temp "-p $keys__" "61"
grib_check_key_equals $temp "-y -p $keys__" "61"
grib_check_key_equals $temp "-p $keys_s" "61"
grib_check_key_equals $temp "-y -p $keys_s" "61m"
#grib_check_key_equals $temp "-p $keys_s" "61"
grib_check_key_equals $temp "-p $keys_s" "61m"
grib_check_key_equals $temp "-p $keys_i" "61"
grib_check_key_equals $temp "-y -p $keys_i" "61"
grib_check_key_equals $temp "-p $keys_d" "61"
grib_check_key_equals $temp "-y -p $keys_d" "61"
${tools_dir}/grib_set -s forecastTime=24,indicatorOfUnitOfTimeRange=h $fn $temp
grib_check_key_equals $temp "-p $low_level_keys" "24 h"
grib_check_key_equals $temp "-p $keys__" "24"
grib_check_key_equals $temp "-y -p $keys__" "24"
grib_check_key_equals $temp "-p $keys_s" "24"
grib_check_key_equals $temp "-y -p $keys_s" "24"
grib_check_key_equals $temp "-p $keys_i" "24"
grib_check_key_equals $temp "-y -p $keys_i" "24"
grib_check_key_equals $temp "-p $keys_d" "24"
grib_check_key_equals $temp "-y -p $keys_d" "24"
${tools_dir}/grib_set -s forecastTime=1440,indicatorOfUnitOfTimeRange=m $fn $temp
grib_check_key_equals $temp "-p $low_level_keys" "1440 m"
grib_check_key_equals $temp "-p $keys__" "24"
grib_check_key_equals $temp "-y -p $keys__" "24"
grib_check_key_equals $temp "-p $keys_s" "24"
grib_check_key_equals $temp "-y -p $keys_s" "24"
grib_check_key_equals $temp "-p $keys_i" "24"
grib_check_key_equals $temp "-y -p $keys_i" "24"
grib_check_key_equals $temp "-p $keys_d" "24"
grib_check_key_equals $temp "-y -p $keys_d" "24"
@ -277,99 +255,60 @@ keys_d="stepRange:d,startStep:d,endStep:d"
${tools_dir}/grib_set -s forecastTime=0,indicatorOfUnitOfTimeRange=m,lengthOfTimeRange=2,indicatorOfUnitForTimeRange=h $fn $temp
grib_check_key_equals $temp "-p $low_level_keys" "0 m 2 h"
grib_check_key_equals $temp "-p $keys__" "0-2 0 2"
grib_check_key_equals $temp "-y -p $keys__" "0-2 0 2"
grib_check_key_equals $temp "-p $keys_s" "0-2 0 2"
grib_check_key_equals $temp "-y -p $keys_s" "0-2 0 2"
grib_check_key_equals $temp "-p $keys_i" "2 0 2"
grib_check_key_equals $temp "-y -p $keys_i" "2 0 2"
grib_check_key_equals $temp "-p $keys_d" "2 0 2"
grib_check_key_equals $temp "-y -p $keys_d" "2 0 2"
${tools_dir}/grib_set -s forecastTime=24,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=1,indicatorOfUnitForTimeRange=D $fn $temp
grib_check_key_equals $temp "-p $low_level_keys" "24 h 1 D"
grib_check_key_equals $temp "-p $keys__" "24-48 24 48"
grib_check_key_equals $temp "-y -p $keys__" "24-48 24 48"
grib_check_key_equals $temp "-p $keys_s" "24-48 24 48"
grib_check_key_equals $temp "-y -p $keys_s" "24-48 24 48"
grib_check_key_equals $temp "-p $keys_i" "48 24 48"
grib_check_key_equals $temp "-y -p $keys_i" "48 24 48"
grib_check_key_equals $temp "-p $keys_d" "48 24 48"
grib_check_key_equals $temp "-y -p $keys_d" "48 24 48"
${tools_dir}/grib_set -s forecastTime=25,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=1,indicatorOfUnitForTimeRange=D $fn $temp
grib_check_key_equals $temp "-p $low_level_keys" "25 h 1 D"
grib_check_key_equals $temp "-p $keys__" "25-49 25 49"
grib_check_key_equals $temp "-y -p $keys__" "25-49 25 49"
grib_check_key_equals $temp "-p $keys__" "25-49 25 49"
grib_check_key_equals $temp "-p $keys_s" "25-49 25 49"
grib_check_key_equals $temp "-y -p $keys_s" "25-49 25 49"
grib_check_key_equals $temp "-p $keys_i" "49 25 49"
grib_check_key_equals $temp "-y -p $keys_i" "49 25 49"
grib_check_key_equals $temp "-p $keys_d" "49 25 49"
grib_check_key_equals $temp "-y -p $keys_d" "49 25 49"
#grib_check_key_equals $temp "-y -s stepUnits=h -p $keys__" "1.0166666666666666"
#grib_check_key_equals $temp "-y -s stepUnits=h -p $keys_s" "1.0166666666666666"
#grib_check_key_equals $temp "-y -s stepUnits=h -p $keys_i" "1"
#grib_check_key_equals $temp "-y -s stepUnits=h -p $keys_d" "1.0166666666666666"
${tools_dir}/grib_set -s forecastTime=45,indicatorOfUnitOfTimeRange=m,lengthOfTimeRange=15,indicatorOfUnitForTimeRange=m $fn $temp
grib_check_key_equals $temp "-p $low_level_keys" "45 m 15 m"
grib_check_key_equals $temp "-p $keys__" "45-60 45 60"
grib_check_key_equals $temp "-y -p $keys__" "45m-60m 45 60"
grib_check_key_equals $temp "-p $keys_s" "45-60 45 60"
grib_check_key_equals $temp "-y -p $keys_s" "45m-60m 45m 60m"
grib_check_key_equals $temp "-p $keys__" "45m-60m 45 60"
#grib_check_key_equals $temp "-p $keys_s" "45-60 45 60"
grib_check_key_equals $temp "-p $keys_s" "45m-60m 45m 60m"
grib_check_key_equals $temp "-p $keys_i" "60 45 60"
grib_check_key_equals $temp "-y -p $keys_i" "60 45 60"
grib_check_key_equals $temp "-p $keys_d" "60 45 60"
grib_check_key_equals $temp "-y -p $keys_d" "60 45 60"
${tools_dir}/grib_set -s forecastTime=60,indicatorOfUnitOfTimeRange=m,lengthOfTimeRange=2,indicatorOfUnitForTimeRange=h $fn $temp
grib_check_key_equals $temp "-p $low_level_keys" "60 m 2 h"
grib_check_key_equals $temp "-p $keys__" "1-3 1 3"
grib_check_key_equals $temp "-y -p $keys__" "1-3 1 3"
grib_check_key_equals $temp "-p $keys_s" "1-3 1 3"
grib_check_key_equals $temp "-y -p $keys_s" "1-3 1 3"
grib_check_key_equals $temp "-p $keys_i" "3 1 3"
grib_check_key_equals $temp "-y -p $keys_i" "3 1 3"
grib_check_key_equals $temp "-p $keys_d" "3 1 3"
grib_check_key_equals $temp "-y -p $keys_d" "3 1 3"
${tools_dir}/grib_set -s forecastTime=18,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=6,indicatorOfUnitForTimeRange=h $fn $temp
grib_check_key_equals $temp "-p $low_level_keys" "18 h 6 h"
grib_check_key_equals $temp "-p $keys__" "18-24 18 24"
grib_check_key_equals $temp "-y -p $keys__" "18-24 18 24"
grib_check_key_equals $temp "-p $keys_s" "18-24 18 24"
grib_check_key_equals $temp "-y -p $keys_s" "18-24 18 24"
grib_check_key_equals $temp "-p $keys_i" "24 18 24"
grib_check_key_equals $temp "-y -p $keys_i" "24 18 24"
grib_check_key_equals $temp "-p $keys_d" "24 18 24"
grib_check_key_equals $temp "-y -p $keys_d" "24 18 24"
${tools_dir}/grib_set -s forecastTime=1080,indicatorOfUnitOfTimeRange=m,lengthOfTimeRange=360,indicatorOfUnitForTimeRange=m $fn $temp
grib_check_key_equals $temp "-p $low_level_keys" "1080 m 360 m"
grib_check_key_equals $temp "-p $keys__" "18-24 18 24"
grib_check_key_equals $temp "-y -p $keys__" "18-24 18 24"
grib_check_key_equals $temp "-p $keys_s" "18-24 18 24"
grib_check_key_equals $temp "-y -p $keys_s" "18-24 18 24"
grib_check_key_equals $temp "-p $keys_i" "24 18 24"
grib_check_key_equals $temp "-y -p $keys_i" "24 18 24" # TODO(EB): Check if output of stepRange:i makes sense.
grib_check_key_equals $temp "-p $keys_d" "24 18 24"
grib_check_key_equals $temp "-y -p $keys_d" "24 18 24" # TODO(EB): Check if output of stepRange:d makes sense.
${tools_dir}/grib_set -s forecastTime=1080,indicatorOfUnitOfTimeRange=m,lengthOfTimeRange=6,indicatorOfUnitForTimeRange=h $fn $temp
grib_check_key_equals $temp "-p $low_level_keys" "1080 m 6 h"
grib_check_key_equals $temp "-p $keys__" "18-24 18 24"
grib_check_key_equals $temp "-y -p $keys__" "18-24 18 24"
grib_check_key_equals $temp "-p $keys_s" "18-24 18 24"
grib_check_key_equals $temp "-y -p $keys_s" "18-24 18 24"
grib_check_key_equals $temp "-p $keys_i" "24 18 24"
grib_check_key_equals $temp "-y -p $keys_i" "24 18 24"
grib_check_key_equals $temp "-p $keys_d" "24 18 24"
grib_check_key_equals $temp "-y -p $keys_d" "24 18 24"
rm -f $temp