mirror of https://github.com/ecmwf/eccodes.git
GRIB-541 and GRIB-564
This commit is contained in:
parent
ef8c6e6e51
commit
59c22e4baa
|
@ -293,13 +293,15 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val)
|
|||
size_t size;
|
||||
double* values;
|
||||
int err=0;
|
||||
|
||||
/* GRIB-564: The index idx relates to codedValues NOT values! */
|
||||
|
||||
err=grib_get_size(a->parent->h,"values",&size);
|
||||
err=grib_get_size(a->parent->h,"codedValues",&size);
|
||||
if (err) return err;
|
||||
if (idx > size) return GRIB_INVALID_NEAREST;
|
||||
if (idx >= size) return GRIB_INVALID_NEAREST;
|
||||
|
||||
values=grib_context_malloc_clear(a->parent->h->context,size*sizeof(double));
|
||||
err=grib_get_double_array(a->parent->h,"values",values,&size);
|
||||
err=grib_get_double_array(a->parent->h,"codedValues",values,&size);
|
||||
if (err) return err;
|
||||
*val=values[idx];
|
||||
grib_context_free(a->parent->h->context,values);
|
||||
|
@ -1162,7 +1164,6 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
|
|||
count+=groupLengths[i];
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
grib_buffer_replace(a, buffer, size,1,1);
|
||||
|
|
|
@ -550,12 +550,14 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val)
|
|||
double* values;
|
||||
int err=0;
|
||||
|
||||
err=grib_get_size(a->parent->h,"values",&size);
|
||||
/* GRIB-564: The index idx relates to codedValues NOT values! */
|
||||
|
||||
err=grib_get_size(a->parent->h,"codedValues",&size);
|
||||
if (err) return err;
|
||||
if (idx > size) return GRIB_INVALID_NEAREST;
|
||||
|
||||
values=grib_context_malloc_clear(a->parent->h->context,size*sizeof(double));
|
||||
err=grib_get_double_array(a->parent->h,"values",values,&size);
|
||||
err=grib_get_double_array(a->parent->h,"codedValues",values,&size);
|
||||
if (err) return err;
|
||||
*val=values[idx];
|
||||
grib_context_free(a->parent->h->context,values);
|
||||
|
|
|
@ -47,5 +47,9 @@ res3=`${tools_dir}grib_get '-F%1.2f' -p min,max,avg $infile.2`
|
|||
[ "$res1" = "$res2" ]
|
||||
[ "$res1" = "$res3" ]
|
||||
|
||||
# GRIB-564 nearest 4 neighbours with JPEG packing
|
||||
res=`${tools_dir}grib_get -l 0,50 $infile.1`
|
||||
[ "$res" = "2.47244 2.47244 2.5115 2.51931 " ]
|
||||
|
||||
rm -f $infile.1 $infile.2 || true
|
||||
rm -f ${data_dir}/reduced_latlon_surface.grib2
|
||||
|
|
|
@ -81,5 +81,22 @@ test_data
|
|||
# See GRIB-147
|
||||
${tools_dir}grib_dump second_ord_rbr.grib1 > $REDIRECT
|
||||
|
||||
# Test nearest neighbour on second order with a bitmap
|
||||
# GRIB-541
|
||||
sec_ord_bmp=sec_ord_bmp.$$.grib1
|
||||
|
||||
# Convert to second order packing
|
||||
${tools_dir}grib_set -r -s packingType=grid_second_order gen_bitmap.grib $sec_ord_bmp
|
||||
# Check there are missing values
|
||||
nums=`${tools_dir}grib_get -p numberOfDataPoints,numberOfCodedValues,numberOfMissing $sec_ord_bmp`
|
||||
[ "$nums" = "5969 4 5965" ]
|
||||
|
||||
res=`${tools_dir}grib_get -l 33,88.5 $sec_ord_bmp`
|
||||
[ "$res" = "9999 5.51552 9999 9999 " ]
|
||||
|
||||
res=`${tools_dir}/grib_get -l 28.5,90 $sec_ord_bmp`
|
||||
[ "$res" = "3.51552 9999 5.26552 9999 " ]
|
||||
|
||||
|
||||
rm -f $sec_ord_bmp
|
||||
rm -f test.filter
|
||||
|
|
Loading…
Reference in New Issue