You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

DESCRIPTION

Compare BUFR messages contained in two files. If some differences are found it fails returning an error code. Floating point values are compared exactly by default, different tolerance can be defined see -P -A -R. Default behaviour: absolute error=0, bit-by-bit compare, same order in files.

USAGE

bufr_compare [options] file file

OPTIONS


-r

Compare files in which the messages are not in the same order. This option is time expensive.


-b key,key,...

All the keys in this list are skipped in the comparison. Bit-by-bit compare on.


-d

Write different messages on files


-c key[:l/d/s/n],key[:l/d/s/n],...

Only the listed keys or namespaces (:n) are compared. The optional letter after the colon is used to force the type in the comparison: l->integer, d->float, s->string, n->namespace. See -a option. Incompatible with -H option.


-S start

First field to be processed.


-E end

Last field to be processed.


-a

-c option modifier. The keys listed with the option -c will be added to the list of keys compared without -c.


-H

Compare only message headers. Bit-by-bit compare on. Incompatible with -c option.


-R key1=relative_error1,key2=relative_error2,...

Compare floating point values using the relative error as tolerance. key1=relative_error will compare key1 using relative_error1. all=relative_error will compare all the floating point keys using relative_error. Default all=0.


-A absolute error

Compare floating point values using the absolute error as tolerance. Default is absolute error=0


-P

Compare data values using the packing error as tolerance.


-t factor

Compare data values using factor multiplied by the tolerance specified in options -P -R -A.


-w key[:{s/d/l}]{=/!=}value,key[:{s/d/l}]{=/!=}value,...

Where clause. Messages are processed only if they match all the key/value constraints. A valid constraint is of type key=value or key!=value. For each key a string (key:s) or a double (key:d) or a long (key:l) type can be specified. Default type is string.


-f

Force. Force the execution not to fail on error.


-V

Version.


-7

Does not fail when the message has wrong length


-v

Verbose.

bufr_compare examples

  1. The default behaviour for bufr_compare without any option is to perform a bit by bit comparison of the two messages. If the messages are found to be bitwise different then grib_compare switches to a "key based" mode to find out which coded keys are different. To see how grib_compare works we first set the bufrHeaderCentre=222 in the file syno_1.bufr

     
    > bufr_set -s bufrHeaderCentre=222 data/bufr/syno_1.bufr out.bufr
    
    Then we can compare the two fields with bufr_compare.
     
    > bufr_compare data/bufr/syno_1.bufr out.bufr
    == 1 == DIFFERENCE == long [bufrHeaderCentre]: [98] != [222]
    == 1 == DIFFERENCE == [rdbType] not found in 2nd field
    == 1 == DIFFERENCE == [rdbSubtype] not found in 2nd field
    == 1 == DIFFERENCE == [typicalDate] not found in 2nd field
    == 1 == DIFFERENCE == [typicalTime] not found in 2nd field
    == 1 == DIFFERENCE == [rdbtimeDay] not found in 2nd field
    == 1 == DIFFERENCE == [rdbtimeHour] not found in 2nd field
    == 1 == DIFFERENCE == [rdbtimeMinute] not found in 2nd field
    == 1 == DIFFERENCE == [rdbtimeSecond] not found in 2nd field
    == 1 == DIFFERENCE == [rectimeDay] not found in 2nd field
    == 1 == DIFFERENCE == [rectimeHour] not found in 2nd field
    == 1 == DIFFERENCE == [rectimeMinute] not found in 2nd field
    == 1 == DIFFERENCE == [rectimeSecond] not found in 2nd field
    == 1 == DIFFERENCE == [correction1] not found in 2nd field
    == 1 == DIFFERENCE == [correction1Part] not found in 2nd field
    == 1 == DIFFERENCE == [correction2] not found in 2nd field
    == 1 == DIFFERENCE == [correction2Part] not found in 2nd field
    == 1 == DIFFERENCE == [correction3] not found in 2nd field
    == 1 == DIFFERENCE == [correction3Part] not found in 2nd field
    == 1 == DIFFERENCE == [correction4] not found in 2nd field
    == 1 == DIFFERENCE == [correction4Part] not found in 2nd field
    == 1 == DIFFERENCE == [qualityControl] not found in 2nd field
    == 1 == DIFFERENCE == [localLatitude] not found in 2nd field
    == 1 == DIFFERENCE == [localLongitude] not found in 2nd field
    
    In the output we can see that the only "coded" key with different values in the two messages is indicatorOfParameter which is the relevant key for the parameter information. The comparison can be forced to be successful listing the keys with different values in the -b option.
     
    > grib_compare -b indicatorOfParameter regular_latlon_surface.grib1 2d.grib1
    


  • No labels