mirror of https://github.com/ecmwf/eccodes.git
Resolve key name conflict between BUFR headers and data ECC-69
This commit is contained in:
parent
e30c1949ec
commit
8c57fff608
|
@ -7,7 +7,7 @@
|
|||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
#
|
||||
|
||||
codetable[2] originatingCentrer 'grib1/0.table' : dump;
|
||||
codetable[2] bufrHeaderOriginatingCentre 'grib1/0.table' : dump;
|
||||
unsigned[1] updateSequenceNumber;
|
||||
|
||||
flags[1] section1Flags 'bufr/section1_flags.table' = 128 : hidden ; # = section 2 present
|
||||
|
|
|
@ -13,7 +13,7 @@ section_length[3] section1Length ;
|
|||
|
||||
unsigned[1] masterTableNumber;
|
||||
|
||||
codetable[2] centre 'grib1/0.table' : dump;
|
||||
codetable[2] bufrHeaderCentre 'grib1/0.table' : dump;
|
||||
|
||||
unsigned[1] updateSequenceNumber;
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@ section_length[3] section1Length ;
|
|||
|
||||
unsigned[1] masterTableNumber;
|
||||
|
||||
codetable[1] subCentre 'grib1/0.table' : dump;
|
||||
unsigned[1] centre : dump;
|
||||
codetable[1] bufrHeaderSubCentre 'grib1/0.table' : dump;
|
||||
unsigned[1] bufrHeaderCentre : dump;
|
||||
|
||||
unsigned[1] updateSequenceNumber;
|
||||
|
||||
|
|
|
@ -13,9 +13,9 @@ section_length[3] section1Length ;
|
|||
|
||||
unsigned[1] masterTableNumber;
|
||||
|
||||
codetable[2] centre 'grib1/0.table' : dump;
|
||||
unsigned[2] subCentre : dump;
|
||||
alias ls.centre=centre;
|
||||
codetable[2] bufrHeaderCentre 'grib1/0.table' : dump;
|
||||
unsigned[2] bufrHeaderSubCentre : dump;
|
||||
alias ls.centre=bufrHeaderCentre;
|
||||
|
||||
unsigned[1] updateSequenceNumber;
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
section_length[3] section2Length ;
|
||||
unsigned[1] reserved = 0;
|
||||
if(centre == 98) {
|
||||
if(bufrHeaderCentre == 98) {
|
||||
if (section2Length==52) {
|
||||
template rdb_key "bufr/rdb_key.def";
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
constant defaultSequence=0;
|
||||
constant tablesMasterDir="bufr/tables/[masterTableNumber]/wmo/[masterTablesVersionNumber]" : hidden;
|
||||
constant tablesLocalDir="bufr/tables/[masterTableNumber]/local/[localTablesVersionNumber]/[centre:l]/[subCentre]" : hidden;
|
||||
constant tablesLocalDir="bufr/tables/[masterTableNumber]/local/[localTablesVersionNumber]/[bufrHeaderCentre:l]/[bufrHeaderSubCentre]" : hidden;
|
||||
constant rootTablesDir="bufr/tables" : hidden;
|
||||
|
||||
transient tableNumber=0;
|
||||
|
@ -25,7 +25,7 @@ unsigned[1] reserved = 0;
|
|||
unsigned[2] numberOfSubsets : dump;
|
||||
alias ls.numberOfSubsets=numberOfSubsets;
|
||||
|
||||
if (section2Present && centre==98 && section2Length==52) {
|
||||
if (section2Present && bufrHeaderCentre==98 && section2Length==52) {
|
||||
|
||||
concept isSatelliteType(zero) {
|
||||
1 = {rdbType = 2; }
|
||||
|
|
|
@ -75,9 +75,9 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
/* This is the place where you may wish to modify the clone
|
||||
E.g. we change the centre */
|
||||
E.g. we change the bufrHeaderCentre */
|
||||
|
||||
CODES_CHECK(codes_set_long(clone_handle, "centre", 222),0);
|
||||
CODES_CHECK(codes_set_long(clone_handle, "bufrHeaderCentre", 222),0);
|
||||
|
||||
/* get the coded message in a buffer */
|
||||
CODES_CHECK(codes_get_message(clone_handle,&buffer,&size),0);
|
||||
|
|
|
@ -64,11 +64,11 @@ int main(int argc,char* argv[])
|
|||
CODES_CHECK(codes_get_long(h,"typicalDate",&longVal),0);
|
||||
printf(" typicalDate: %ld\n",longVal);
|
||||
|
||||
CODES_CHECK(codes_get_long(h,"centre",&longVal),0);
|
||||
printf(" centre: %ld\n",longVal);
|
||||
CODES_CHECK(codes_get_long(h,"bufrHeaderCentre",&longVal),0);
|
||||
printf(" bufrHeaderCentre: %ld\n",longVal);
|
||||
|
||||
CODES_CHECK(codes_get_long(h,"subCentre",&longVal),0);
|
||||
printf(" subCentre: %ld\n",longVal);
|
||||
CODES_CHECK(codes_get_long(h,"bufrHeaderSubCentre",&longVal),0);
|
||||
printf(" bufrHeaderSubCentre: %ld\n",longVal);
|
||||
|
||||
CODES_CHECK(codes_get_long(h,"masterTablesVersionNumber",&longVal),0);
|
||||
printf(" masterTablesVersionNumber: %ld\n",longVal);
|
||||
|
|
|
@ -28,7 +28,7 @@ fRef=${f}.header.ref
|
|||
REDIRECT=/dev/null
|
||||
|
||||
#Write the values into a file and compare with reference
|
||||
${examples_dir}/bufr_print_header $f 2> $REDIRECT > $fTmp
|
||||
${examples_dir}/bufr_print_header $f 2> $REDIRECT > $fTmp
|
||||
|
||||
#We compare output to the reference by ignoring the whitespaces
|
||||
diff -w $fRef $fTmp >$REDIRECT 2> $REDIRECT
|
||||
|
|
|
@ -69,20 +69,17 @@ int main(int argc,char* argv[])
|
|||
/*CODES_CHECK(codes_set_long(h,"unpack",1),0);*/
|
||||
|
||||
/* This is the place where you may wish to modify the message*/
|
||||
/*E.g. we change the centre and 2m temperature */
|
||||
/*E.g. we change the centre */
|
||||
|
||||
/* set centre */
|
||||
/* set bufrHeaderCentre */
|
||||
longVal=222;
|
||||
CODES_CHECK(codes_set_long(h, "centre", longVal),0);
|
||||
printf(" set centre to: %ld\n",longVal);
|
||||
CODES_CHECK(codes_set_long(h, "bufrHeaderCentre", longVal),0);
|
||||
printf(" set bufrHeaderCentre to: %ld\n",longVal);
|
||||
|
||||
/* check centre */
|
||||
CODES_CHECK(codes_get_long(h,"centre",&longVal),0);
|
||||
printf(" centre's new value is: %ld\n",longVal);
|
||||
/* check bufrHeaderCentre */
|
||||
CODES_CHECK(codes_get_long(h,"bufrHeaderCentre",&longVal),0);
|
||||
printf(" bufrHeaderCentre's new value is: %ld\n",longVal);
|
||||
|
||||
/*doubleVal=240.+i*2.;
|
||||
CODES_CHECK(codes_set_double(h,"airTemperatureAt2M",doubleVal),0);
|
||||
printf(" set airTemperatureAt2M to: %f\n",doubleVal);*/
|
||||
|
||||
/* get the modified message in a buffer */
|
||||
CODES_CHECK(codes_get_message(h,&buffer,&size),0);
|
||||
|
|
|
@ -43,8 +43,8 @@ program bufr_clone
|
|||
call codes_clone(ibufr_in, ibufr_out)
|
||||
|
||||
! This is the place where you may wish to modify the clone
|
||||
! E.g. we change the centre
|
||||
call codes_set(ibufr_out,'centre',222)
|
||||
! E.g. we change the bufrHeaderCentre
|
||||
call codes_set(ibufr_out,'bufrHeaderCentre',222)
|
||||
|
||||
! write cloned messages to a file
|
||||
call codes_write(ibufr_out,outfile)
|
||||
|
|
|
@ -45,11 +45,11 @@ integer(kind=4) :: numberofsubsets
|
|||
call codes_get(ibufr,'typicalDate',typicalDate);
|
||||
write(*,*) ' typicalDate:',typicalDate
|
||||
|
||||
call codes_get(ibufr,'centre',centre);
|
||||
write(*,*) ' centre:',centre
|
||||
call codes_get(ibufr,'bufrHeaderCentre',centre);
|
||||
write(*,*) ' bufrHeaderCentre:',centre
|
||||
|
||||
call codes_get(ibufr,'subCentre',subcentre)
|
||||
write(*,*) ' subCentre:',subcentre
|
||||
call codes_get(ibufr,'bufrHeaderSubCentre',subcentre)
|
||||
write(*,*) ' bufrHeaderSubCentre:',subcentre
|
||||
|
||||
call codes_get(ibufr,'masterTablesVersionNumber',masterversion)
|
||||
write(*,*) ' masterTablesVersionNumber:',masterversion
|
||||
|
|
|
@ -36,17 +36,17 @@ program bufr_set_keys
|
|||
write(*,*) 'message: ',count
|
||||
|
||||
! This is the place where you may wish to modify the message
|
||||
! E.g. we change the centre and 2m temperature
|
||||
! E.g. we change the centre
|
||||
|
||||
! set centre
|
||||
centre=222
|
||||
call codes_set(ibufr,'centre',222)
|
||||
write(*,*) ' set centre to:',centre
|
||||
call codes_set(ibufr,'bufrHeaderCentre',222)
|
||||
write(*,*) ' set bufrHeaderCentre to:',centre
|
||||
|
||||
! check centre's new value
|
||||
centreNew=0
|
||||
call codes_get(ibufr,'centre',centreNew)
|
||||
write(*,*) ' centre''s new value:',centreNew
|
||||
call codes_get(ibufr,'bufrHeaderCentre',centreNew)
|
||||
write(*,*) ' bufrHeaderCentre''s new value:',centreNew
|
||||
|
||||
! write modified message to a file
|
||||
call codes_write(ibufr,outfile)
|
||||
|
|
|
@ -44,7 +44,7 @@ def example():
|
|||
clone_id = codes_clone(gid)
|
||||
|
||||
# this is the place where you may wish to modify the clone
|
||||
codes_set(clone_id,'centre',centre)
|
||||
codes_set(clone_id,'bufrHeaderCentre',centre)
|
||||
|
||||
# write the cloned message to a file
|
||||
codes_write(clone_id,fout)
|
||||
|
|
|
@ -32,8 +32,8 @@ def example():
|
|||
'dataCategory',
|
||||
'dataSubCategory',
|
||||
'typicalDate',
|
||||
'centre',
|
||||
'subCentre',
|
||||
'bufrHeaderCentre',
|
||||
'bufrHeaderSubCentre',
|
||||
'masterTablesVersionNumber',
|
||||
'localTablesVersionNumber',
|
||||
'numberOfSubsets',
|
||||
|
|
|
@ -46,18 +46,18 @@ def example():
|
|||
#codes_set(gid,'unpack',1);
|
||||
|
||||
# This is the place where you may wish to modify the message
|
||||
# E.g. we change the centre and 2m temperature
|
||||
# E.g. we change the centre
|
||||
|
||||
# set centre
|
||||
val=222
|
||||
print ' set centre to: %d' % val
|
||||
print ' set bufrHeaderCentre to: %d' % val
|
||||
|
||||
key='centre'
|
||||
key='bufrHeaderCentre'
|
||||
if not codes_is_defined(gid,key):
|
||||
raise Exception("Key: " + key + " was not defined")
|
||||
codes_set(gid,key,val)
|
||||
|
||||
#check centre's value
|
||||
#check bufrHeaderCentre's value
|
||||
print ' %s''s new value is: %d' % (key,codes_get(gid,key))
|
||||
|
||||
# write modified message to output
|
||||
|
|
|
@ -41,7 +41,7 @@ fRules=${label}.filter
|
|||
echo "Test: dump header" >> $fLog
|
||||
|
||||
cat > $fRules <<EOF
|
||||
print "[centre] [subCentre] [masterTablesVersionNumber] [localTablesVersionNumber] [numberOfSubsets]";
|
||||
print "[bufrHeaderCentre] [bufrHeaderSubCentre] [masterTablesVersionNumber] [localTablesVersionNumber] [numberOfSubsets]";
|
||||
EOF
|
||||
|
||||
for f in `ls *.bufr` ; do
|
||||
|
@ -205,7 +205,7 @@ EOF
|
|||
f="b005_89.bufr"
|
||||
echo "Test: access marker operators" >> $fLog
|
||||
echo "file: $f" >> $fLog
|
||||
${tools_dir}/bufr_filter $fRules $f 2>> $fLog 1>> $fLog
|
||||
${tools_dir}/bufr_filter $fRules $f #2>> $fLog 1>> $fLog
|
||||
|
||||
${tools_dir}/bufr_filter $fRules $f 2>> ${f}.log 1>> ${f}.log
|
||||
cat > ${f}.ref <<EOF
|
||||
|
@ -682,7 +682,7 @@ ${tools_dir}/bufr_filter -f $fRules $f 2>>$fLog 1>>$fLog
|
|||
|
||||
#Here 1024 is out of range for centre (it is 8-bit only)
|
||||
cat > $fRules <<EOF
|
||||
set centre=1024;
|
||||
set bufrHeaderCentre=1024;
|
||||
EOF
|
||||
|
||||
# Invoke without -f i.e. should fail if error encountered
|
||||
|
@ -718,7 +718,7 @@ f="syno_1.bufr"
|
|||
echo "Test: nformat specifier for integer keys" >> $fLog
|
||||
echo "file: $f" >> $fLog
|
||||
result=`${tools_dir}/bufr_filter $fRules $f`
|
||||
#[ "$result" = "centre=098, height= 3" ]
|
||||
[ "$result" = "centre=098, height= 3" ]
|
||||
|
||||
|
||||
#----------------------------------------------------
|
||||
|
|
|
@ -42,7 +42,7 @@ REDIRECT=/dev/null
|
|||
|
||||
echo "Test: -p switch" >> $fLog
|
||||
echo "file: $f" >> $fLog
|
||||
${tools_dir}/bufr_get -p totalLength,centre,subCentre,masterTableNumber,masterTablesVersionNumber,localTablesVersionNumber,numberOfSubsets,numberOfObservations $f > $fTmp
|
||||
${tools_dir}/bufr_get -p totalLength,bufrHeaderCentre,bufrHeaderSubCentre,masterTableNumber,masterTablesVersionNumber,localTablesVersionNumber,numberOfSubsets,numberOfObservations $f > $fTmp
|
||||
|
||||
#Write the values into a file and compare with ref
|
||||
cat $fTmp | awk '{split($0,a," "); for (i=1; i<=8; i++) print a[i]}' > $res_get
|
||||
|
|
|
@ -43,7 +43,7 @@ ref_ls=$f".ls.ref"
|
|||
res_ls=$f".ls.test"
|
||||
REDIRECT=/dev/null
|
||||
|
||||
${tools_dir}/bufr_ls -p totalLength,centre,subCentre,masterTableNumber,masterTablesVersionNumber,localTablesVersionNumber,numberOfSubsets,numberOfObservations $f 2> $REDIRECT > $fTmp
|
||||
${tools_dir}/bufr_ls -p totalLength,bufrHeaderCentre,bufrHeaderSubCentre,masterTableNumber,masterTablesVersionNumber,localTablesVersionNumber,numberOfSubsets,numberOfObservations $f 2> $REDIRECT > $fTmp
|
||||
|
||||
#Write the values into a file and compare with ref
|
||||
awk NR==3 $fTmp | awk '{split($0,a," "); for (i=1; i<=8; i++) print a[i]}' > $res_ls
|
||||
|
|
|
@ -35,9 +35,9 @@ rm -f $fBufrTmp | true
|
|||
f="syno_1.bufr"
|
||||
echo "Test: setting header for single message file" >> $fLog
|
||||
echo "file: $f" >> $fLog
|
||||
${tools_dir}/bufr_set -v -p centre,centre:l -s centre=222 $f $fBufrTmp >> $fLog
|
||||
${tools_dir}/bufr_set -v -p bufrHeaderCentre,bufrHeaderCentre:l -s bufrHeaderCentre=222 $f $fBufrTmp >> $fLog
|
||||
|
||||
centre=`${tools_dir}/bufr_get -p centre $fBufrTmp`
|
||||
centre=`${tools_dir}/bufr_get -p bufrHeaderCentre $fBufrTmp`
|
||||
[ $centre = "222" ]
|
||||
|
||||
#----------------------------------------------------
|
||||
|
@ -49,10 +49,10 @@ rm -f $fBufrTmp | true
|
|||
f="syno_multi.bufr"
|
||||
echo "Test: setting header for multi-message file" >> $fLog
|
||||
echo "file: $f" >> $fLog
|
||||
${tools_dir}/bufr_set -v -p centre,centre:l -s centre=222 $f $fBufrTmp >> $fLog
|
||||
${tools_dir}/bufr_set -v -p bufrHeaderCentre,bufrHeaderCentre:l -s bufrHeaderCentre=222 $f $fBufrTmp >> $fLog
|
||||
|
||||
for i in 1 2 3 ;do
|
||||
centre=`${tools_dir}/bufr_get -w count=$i -p centre $fBufrTmp`
|
||||
centre=`${tools_dir}/bufr_get -w count=$i -p bufrHeaderCentre $fBufrTmp`
|
||||
[ $centre = "222" ]
|
||||
done
|
||||
|
||||
|
@ -127,7 +127,7 @@ set +e
|
|||
f="syno_1.bufr"
|
||||
echo "Test: nonexistent keys" >> $fLog
|
||||
echo "file: $f" >> $fLog
|
||||
${tools_dir}/bufr_set -s centre=1024 $f $fBufrTmp 2>> $fLog 1>> $fLog
|
||||
${tools_dir}/bufr_set -s bufrHeaderCentre=1024 $f $fBufrTmp 2>> $fLog 1>> $fLog
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "bufr_set should have failed if key not found" >&2
|
||||
exit 1
|
||||
|
@ -135,7 +135,7 @@ fi
|
|||
set -e
|
||||
|
||||
# Now repeat with -f option (do not exit on error)
|
||||
${tools_dir}/bufr_set -f -s centre=1024 -f $f $fBufrTmp 2>>$fLog 1>>$fLog
|
||||
${tools_dir}/bufr_set -f -s bufrHeaderCentre=1024 -f $f $fBufrTmp 2>>$fLog 1>>$fLog
|
||||
|
||||
#-----------------------------------------------------------
|
||||
# Test: key values out of range
|
||||
|
|
Loading…
Reference in New Issue