ECC-1519: grib_ls: Using the 'statistics' namespace does not respect the specified format

This commit is contained in:
Shahram Najm 2023-02-01 15:52:36 +00:00
parent 87e403b4da
commit ac30393626
2 changed files with 5 additions and 2 deletions

View File

@ -45,7 +45,7 @@ input=${data_dir}/lfpw.grib1
temp1=temp1.statistics.grib
temp2=temp2.statistics.grib
stats=`${tools_dir}/grib_get -w count=50 -F%.2f -n statistics $input`
[ "$stats" = "10098 0 1064.19 3066.07 2.57004 4.60965 0" ]
[ "$stats" = "10098.00 0.00 1064.19 3066.07 2.57 4.61 0.00" ]
# Scaling values in presence of real 9999 values
${tools_dir}/grib_set -s scaleValuesBy=0.5 $input $temp1

View File

@ -756,6 +756,10 @@ static void grib_tools_set_print_keys(grib_runtime_options* options, grib_handle
if (strlen(name) > options->default_print_width)
options->default_print_width = (int)strlen(name);
options->print_keys[options->print_keys_count].type = GRIB_TYPE_STRING;
// For the statistics namespace, do not force the type to be string.
// Setting it to undefined will use the keys' native type i.e. GRIB_TYPE_DOUBLE
if (strcmp(ns,"statistics")==0)
options->print_keys[options->print_keys_count].type = GRIB_TYPE_UNDEFINED;
options->print_keys_count++;
}
@ -990,7 +994,6 @@ static void get_value_for_key(grib_handle* h, const char* key_name, int key_type
double dvalue = 0;
long lvalue = 0;
size_t len = MAX_STRING_LEN;
if (grib_is_missing(h, key_name, &ret) && ret == GRIB_SUCCESS) {
snprintf(value_str, 32, "MISSING");
return;