grib_compare

DESCRIPTION

Compares the grib messages contained in two files one by one in the same order. If some differences are found it fails returning an error code. All the keys are compared except those listed with the -b option and those that are specific of a different grib edition. Also data values are compared and are considered as different if their maximum absolute difference is greater than the absolute error, that by default is 0.000001. The value used by the absolute error can be set with te -e option.

USAGE

grib_compare [options] grib_file grib_file

OPTIONS

-r
Repack data. Sometimes after setting some keys involving properties of the packing algorithm a repacking of data is needed. This repacking is performed setting this -r option.

-b key,key,...
Black list. All the keys in this list are skipped when comparing the two files.

-c key,key,...
Keys to compare. Only the listed keys are compared.

-e tolerance
Only values whose difference is more than tolerance are considered different.

-w key[:{s/d/l}]{=/!=}value,key[:{s/d/l}]{=/!=}value,...
Where clause. Grib 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.

grib_compare examples

  1. If we want to know exactly which keys are different in two grib messages a bit by bit comparison does not help us. Moreover if we know that two grib messages are different by only a few keys and we want to be sure that only those keys are different a smart compare tool is needed.
    The grib_compare is made to deal with both cases.
    To see how grib_compare works we first set the short_name=2d (2 metre dew point temperature) in the file ../data/regular_latlon_surface.grib1
    >grib_set -s short_name=2d ../data/regular_latlon_surface.grib1 ../data/2d.grib1
    
    Then we can compare the two fields with grib_compare.
    >grib_compare ../data/regular_latlon_surface.grib1 ../data/2d.grib1
    [indicatorOfParameter] long  values are different: [167] and [168]
    [paramId] long  values are different: [167] and [168]
    [shortName] string values are different: [2t] and [2d]
    -- previous error in count=1 shortName=2d stepRange=0 levelType=sfc level=0 --
    
    In the output we see that not only is the short_name is changed from 2t to 2d, but also indicatorOfParameter and paramId are changed. This is because all the keys related to the short name are changed simultaneously. The exit code for the previous command is 1 as the comparison failed.
    If we already know that the keys shortName, indicatorOfParameter, paramId are different in the two grib messages, we can check that those are the only different keys grouping them in a blacklist with the -b option.
    >grib_compare -b shortName,indicatorOfParameter,paramId ../data/regular_latlon_surface.grib1 ../data/2d.grib1
    
    In this case the exit code is 0 because the comparison is considered successful according to the blacklist provided.

  2. grib_compare can also compare data values between two grib messages. In this case a precision can be provided through the -e option otherwise a the packingError is used. To show how data values are compared we can first repack a field with a different precision to see what grib_compare is giving in output to highlight this difference.
    For example if we want to pack a temperature expressed in Kelvin with 1 digit of precision after the decimal point we can set changeDecimalPrecision=1
    >grib_set -s changeDecimalPrecision=1 ../data/reduced_latlon_surface.grib1 ../data/precision_1.grib
    

    Now we can compare the two fields using grib_compare :
    >grib_compare ../data/reduced_latlon_surface.grib1 precision_1.grib1
    [decimalScaleFactor] long  values are different: [2] and [1]
    [bitsPerValue] long  values are different: [11] and [7]
    WARNING: packingError are different : [0.005] [0.05]
    [dataLength] long  values are different: [36894] and [23478]
    -- previous error in count=1 shortName=swh stepRange=0 levelType=sfc level=0 --
    

    In this case decimalScaleFactor, bitsPerValue and packingError are different, but the values are assumed to be the same because they are considered different only if the absolute value of their difference is greather than the packing value

Generated on Fri Mar 6 13:49:22 2009 for grib_api by  doxygen 1.5.4