Versions Compared

Key

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

...

grib_copy [options] grib_file grib_file ... output_grib_file

OPTIONS


-f

Force. Force the execution not to fail on error.


-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.


-p key[:{s/d/i}],key[:{s/d/i}],...

Declaration of keys to print. For each key a string (key:s), a double (key:d) or an integer (key:i) type can be requested. Default type is string.


-P key[:{s/d/i}],key[:{s/d/i}],...

As -p adding the declared keys to the default list.


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

Where clause. Only grib messages matching the key/value constraints are copied to the output_grib_file. A valid constraint is of type key=value or key!=value. For each key a string (key:s), a double (key:d) or an integer (key:i) type can be defined. Default type is string.


-B order by directive

Order by. The output will be ordered according to the order by directive. Order by example: "step:i asc, centre desc" (step numeric ascending and centre descending)


-V

Version.


-W width

Minimum width of each column in output. Default is 10.


-M

Multi-field support off. Turn off support for multiple fields in single grib message.


-T T | B | M | A

Message type. T->GTS, B->BUFR, M->METAR (Experimental),A->Any (Experimental). The input file is interpreted according to the message type.


-g

Copy GTS header.


-G

GRIBEX compatibility mode.


-7

Does not fail when the message has wrong length


-v

Verbose.

grib_copy examples

    1. To copy only the pressure levels from a file

      Code Block
    1. >  grib_copy -w levtype=pl ../data/tigge_pf_ecmwf.grib2 out.grib
      

 

    1. To copy only the fields that are not on pressure levels from a file

      Code Block
    1. >  grib_copy -w levtype!=pl ../data/tigge_pf_ecmwf.grib2 out.grib
      

 

    1. To copy only the first three fields from a file

      Code Block
    1. >  grib_copy -w count=1/2/3 ../data/tigge_pf_ecmwf.grib2 out.grib
      

 

    1. A grib_file with multi field messages can be converted in single field messages with a simple grib_copy.

      Code Block
    1. >  grib_copy multi.grib simple.grib
      

 

    1. Use the square brackets to insert the value of a key in the name of the output file (This is a good way to split a large GRIB file)

      Code Block
    1. >  grib_copy in.grib 'out_[shortName].grib'
      

      Note: we need to quote the name of the output so the shell does not interpret the square brackets

 

    1. To copy fields whose typeOfLevel is either 'surface' or 'meanSea'

      Code Block
    1. >  grib_copy -w typeOfLevel=surface/meanSea orig.grib out.grib
      

 

    1. To copy selected fields and apply sorting (sorted by level in ascending order)

      Code Block
    1. >  grib_copy -w typeOfLevel=heightAboveGround -B'level:i asc' tigge_af_ecmwf.grib2 out.grib
      

      Note: we need to specify the ':i' to get a numerical sort. By default values are sorted as strings so a level of 100 would come before 20!