Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Excerpt
hiddentrue

suppose you have two large GRIB files and their messages are not in order, how do you compare them? One technique is to use the "-r" key for grib_compare. This will compute the md5 hash value of each message (meta-data only) and sort both files (in memory) by that md5 value before doing the comparison.

grib_compare: index based comparison

Step-by-step guide

suppose you have two large GRIB files and their messages are not in order, how do you compare them? One technique is to use the "-r" key for grib_compare. This will compute the md5 hash value of each message (meta-data only) and sort both files (in memory) by that md5 value before doing the comparison.

  1. Another technique is to build index files from both inputs (using grib_index_build) and then compare those index files. This can be considerably faster. The user has to decide on which keys to build the index files. An example is shown here.
  2. Here is the version with "-r":

    Code Block
    languagebash
    % grib_compare -r $input1 $input2

    And now using grib_index_build with MARS keys:

    Code Block
    languagebash
    #!/bin/sh
    grib_index_build -o idx1 $input1 >/dev/null
    grib_index_build -o idx2 $input2 >/dev/null
    grib_compare idx1 idx2
    rm -f idx1 idx2  # Clean up


  3. By default grib_index_build uses the MARS keys (those in the "mars" namespace). Otherwise the user can pass his/her own desired keys via the "-k" option.

    An even faster version of the 2nd script can be done if we launch the two grib_index_build processes in the background (run them concurrently):

    Code Block
    languagebash
    #!/bin/sh
    grib_index_build -o idx1 $input1 >/dev/null  &
    grib_index_build -o idx2 $input2 >/dev/null  &
    wait  # For the background tasks for finish
    grib_compare idx1 idx2
    rm -f idx1 idx  # Clean up



Content by Label
showLabelsfalse
max5
spaces~usa
showSpacefalse
sortmodified
reversetrue
typepage
cqllabel = "kb-how-to-article" and type = "page" and space = "~usa"
labelskb-how-to-article

...