ECC-616: BUFR operator 203YYY: implement encoding (Part 2)

This commit is contained in:
Shahram Najm 2018-04-10 15:54:32 +01:00
parent e23533ca78
commit 4043657257
12 changed files with 87 additions and 15 deletions

View File

@ -13,7 +13,6 @@ STRING(REGEX REPLACE "\n" ";" bufr_refs_to_download "${bufr_refs_to_download}")
# Exceptional case: download bufr files which have to be treated specially
LIST(APPEND bufr_refs_to_download "vos308014_v3_26.bufr") # See test ecc-197
LIST(APPEND bufr_refs_to_download "israel_observations_2017041010.bufr") # See test ecc-313
ecbuild_get_test_multidata(
TARGET eccodes_download_bufrs

View File

@ -143,3 +143,4 @@ srals3_eumetsat.bufr
eumetsat_iasi_co.bufr
eum_iasi_twt.bufr
delayed_repl_01.bufr
israel_observations_2017041010.bufr

View File

@ -2613,10 +2613,10 @@ static int process_elements(grib_accessor* a,int flag,long onlySubset,long start
case 3:
/* Change reference values */
//if (flag != PROCESS_DECODE) {
// grib_context_log(c,GRIB_LOG_ERROR,"process_elements: operator %d supported for decoding only",descriptors[i]->X);
// return GRIB_INTERNAL_ERROR;
//}
if (self->compressedData == 1 && flag != PROCESS_DECODE) {
grib_context_log(c,GRIB_LOG_ERROR,"process_elements: operator %d not supported for encoding compressed data",descriptors[i]->X);
return GRIB_INTERNAL_ERROR;
}
if (descriptors[i]->Y == 255) {
grib_context_log(c, GRIB_LOG_DEBUG,"Operator 203YYY: Y=255, definition of new reference values is concluded");
self->change_ref_value_operand = 255;

View File

@ -618,7 +618,8 @@ static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accesso
_dump_long_array(h,self->dumper.out,"delayedDescriptorReplicationFactor","inputDelayedDescriptorReplicationFactor");
_dump_long_array(h,self->dumper.out,"shortDelayedDescriptorReplicationFactor","inputShortDelayedDescriptorReplicationFactor");
_dump_long_array(h,self->dumper.out,"extendedDelayedDescriptorReplicationFactor","inputExtendedDelayedDescriptorReplicationFactor");
_dump_long_array(h,self->dumper.out,"overriddenReferenceValues","overriddenReferenceValues");
/* Do not show the overriddenReferenceValues array. That's more for ENCODING */
/*_dump_long_array(h,self->dumper.out,"overriddenReferenceValues","overriddenReferenceValues");*/
grib_dump_accessors_block(d,block);
depth-=2;
} else if (!grib_inline_strcmp(a->name,"groupNumber")) {

View File

@ -529,7 +529,8 @@ static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accesso
_dump_long_array(h,self->dumper.out,"delayedDescriptorReplicationFactor","inputDelayedDescriptorReplicationFactor");
_dump_long_array(h,self->dumper.out,"shortDelayedDescriptorReplicationFactor","inputShortDelayedDescriptorReplicationFactor");
_dump_long_array(h,self->dumper.out,"extendedDelayedDescriptorReplicationFactor","inputExtendedDelayedDescriptorReplicationFactor");
_dump_long_array(h,self->dumper.out,"overriddenReferenceValues","overriddenReferenceValues");
/* Do not show the overriddenReferenceValues array. That's more for ENCODING */
/*_dump_long_array(h,self->dumper.out,"overriddenReferenceValues","overriddenReferenceValues");*/
grib_dump_accessors_block(d,block);
depth-=2;
} else if (!grib_inline_strcmp(a->name,"groupNumber")) {

View File

@ -555,7 +555,8 @@ static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accesso
_dump_long_array(h,self->dumper.out,"delayedDescriptorReplicationFactor","inputDelayedDescriptorReplicationFactor");
_dump_long_array(h,self->dumper.out,"shortDelayedDescriptorReplicationFactor","inputShortDelayedDescriptorReplicationFactor");
_dump_long_array(h,self->dumper.out,"extendedDelayedDescriptorReplicationFactor","inputExtendedDelayedDescriptorReplicationFactor");
_dump_long_array(h,self->dumper.out,"overriddenReferenceValues","overriddenReferenceValues");
/* Do not show the overriddenReferenceValues array. That's more for ENCODING */
/* _dump_long_array(h,self->dumper.out,"overriddenReferenceValues","overriddenReferenceValues"); */
grib_dump_accessors_block(d,block);
depth-=2;
} else if (!grib_inline_strcmp(a->name,"groupNumber")) {

View File

@ -567,7 +567,8 @@ static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accesso
_dump_long_array(h,self->dumper.out,"delayedDescriptorReplicationFactor","inputDelayedDescriptorReplicationFactor");
_dump_long_array(h,self->dumper.out,"shortDelayedDescriptorReplicationFactor","inputShortDelayedDescriptorReplicationFactor");
_dump_long_array(h,self->dumper.out,"extendedDelayedDescriptorReplicationFactor","inputExtendedDelayedDescriptorReplicationFactor");
_dump_long_array(h,self->dumper.out,"overriddenReferenceValues","overriddenReferenceValues");
/* Do not show the overriddenReferenceValues array. That's more for ENCODING */
/* _dump_long_array(h,self->dumper.out,"overriddenReferenceValues","overriddenReferenceValues"); */
grib_dump_accessors_block(d,block);
depth-=2;
} else if (!grib_inline_strcmp(a->name,"groupNumber")) {

View File

@ -690,7 +690,8 @@ static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accesso
_dump_long_array(h,self->dumper.out,"delayedDescriptorReplicationFactor","inputDelayedDescriptorReplicationFactor");
_dump_long_array(h,self->dumper.out,"shortDelayedDescriptorReplicationFactor","inputShortDelayedDescriptorReplicationFactor");
_dump_long_array(h,self->dumper.out,"extendedDelayedDescriptorReplicationFactor","inputExtendedDelayedDescriptorReplicationFactor");
_dump_long_array(h,self->dumper.out,"overriddenReferenceValues","overriddenReferenceValues");
/* Do not show the overriddenReferenceValues array. That's more for ENCODING */
/*_dump_long_array(h,self->dumper.out,"overriddenReferenceValues","overriddenReferenceValues");*/
grib_dump_accessors_block(d,block);
depth-=2;
} else if (!grib_inline_strcmp(a->name,"groupNumber")) {

View File

@ -80,6 +80,7 @@ list( APPEND tests_data_reqd
bufr_ecc-286
bufr_ecc-288
bufr_ecc-313
bufr_ecc-616
bufr_ecc-379
bufr_ecc-393
bufr_ecc-433

View File

@ -37,7 +37,14 @@ fRules=${label}.filter
#-----------------------------------------------------------
files=`cat ${data_dir}/bufr/bufr_data_files.txt`
exclude="ias1_240.bufr syno_multi.bufr tropical_cyclone.bufr"
# Exclude BUFR files for various reasosn:
# ias1_240.bufr: Too large. The filter rules file generated is too big for the parser!
# tropical_cyclone.bufr: multi-message
# syno_multi.bufr: multi-message
# israel_observations_2017041010.bufr: Suffers from a bug. In filter cannot do:
# set #1#3HourPressureChange=-1.6;
# The hash cannot be followed by a number!
exclude="ias1_240.bufr syno_multi.bufr tropical_cyclone.bufr israel_observations_2017041010.bufr"
for f in $files
do

View File

@ -13,8 +13,6 @@
# ---------------------------------------------------------
# This is the test for the JIRA issue ECC-313.
# It tests decoding a BUFR file which uses the operator 203YYY.
# Currently we cannot ENCODE with this operator. This test is
# for DECODING only
# ---------------------------------------------------------
label="bufr_ecc-313-test"
tempRules=temp.${label}.filter
@ -36,6 +34,7 @@ cat > $tempRules <<EOF
print "h1=[heightOfStationGroundAboveMeanSeaLevel]";
print "h2=[heightOfBarometerAboveMeanSeaLevel]";
print "rv=[overriddenReferenceValues]";
print "rf1=[#1#heightOfStationGroundAboveMeanSeaLevel->reference]";
EOF
${tools_dir}/codes_bufr_filter $tempRules $input > $tempOut
@ -64,9 +63,10 @@ h2=11 -1e+100 -1e+100 -1e+100 -1e+100 -1e+100 -1e+100 -1e+100
-1e+100 -1e+100 -1e+100 -1e+100 -1e+100 938 -1e+100 -1e+100
-1e+100 -1e+100
rv=-5000 -5000
rf1=-5000
EOF
echo "Expected output:"
cat $tempRef
diff $tempRef $tempOut
rm -f $tempRules $tempRef $tempOut

59
tests/bufr_ecc-616.sh Executable file
View File

@ -0,0 +1,59 @@
#!/bin/sh
# Copyright 2005-2018 ECMWF.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
#
# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
#
. ./include.sh
# ---------------------------------------------------------
# This is the test for the JIRA issue ECC-616.
# It tests encoding a BUFR file which uses the operator 203YYY.
# ---------------------------------------------------------
label="bufr_ecc-616-test"
tempRules=temp.${label}.filter
tempOut=temp.${label}.txt
tempRef=temp.${label}.ref
tempBufr=temp.${label}.bufr
input=${data_dir}/bufr/israel_observations_2017041010.bufr
cat > $tempRules <<EOF
set unpack=1;
set extractSubset=23;
set doExtractSubsets=1;
write;
assert(numberOfSubsets==1);
EOF
${tools_dir}/codes_bufr_filter -o $tempBufr $tempRules $input
# The unexpandedDescriptors are:
# 203014 7030 7031 203255 307080
# 7030 = heightOfStationGroundAboveMeanSeaLevel
# 7031 = heightOfBarometerAboveMeanSeaLevel
cat > $tempRules <<EOF
set unpack=1;
print " numSubs=[numberOfSubsets]";
print " refVals={[overriddenReferenceValues',']}";
print " height=[heightOfStationGroundAboveMeanSeaLevel]";
print " height->ref=[heightOfStationGroundAboveMeanSeaLevel->reference]";
EOF
${tools_dir}/codes_bufr_filter $tempRules $tempBufr > $tempOut
cat > $tempRef << EOF
numSubs=1
refVals={-5000,-5000}
height=-415
height->ref=-5000
EOF
echo "Expected output:"
cat $tempRef
diff $tempRef $tempOut
rm -f $tempRules $tempRef $tempOut $tempBufr