Page tree

GRIB-API support is being discontinued at the end of 2018. Please consider upgrading to ecCodes


Skip to end of metadata
Go to start of metadata

DESCRIPTION

List content of GRIB files printing values of some keys. It does not fail when a key is not found.

USAGE

grib_ls [options] grib_file grib_file ...

OPTIONS

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

-F format
C style format for floating point values.

-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. 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 an integer (key:i) type can be specified. Default type is string.
In the value you can also use the forward-slash character "/" to specify an OR condition (i.e. a logical disjunction)

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

-l Latitude,Longitude[,MODE,file]
Value close to the point of a Latitude/Longitude.
Allowed values for MODE are:

  • 4 (4 values in the nearest points are printed) Default
  • 1 (the value at the nearest point is printed)
  • file (file is used as mask. The closer point with mask value>=0.5 is printed)

-s key[:{s/d/i}]=value,key[:{s/d/i}]=value,...
Key/values to set. For each key a string (key:s) or a double (key:d) or an integer (key:i) type can be defined. By default the native type is set.

-i index
Data value corresponding to the given index is printed. Note this index is zero-based, so the first value is at index 0.

-n namespace
All the keys belonging to namespace are printed. Some useful namespaces are: "time", "parameter", "geography" and "statistics".

-m
Mars keys are printed.

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

-g
Copy GTS header.

-T T | B
Message type. T -> GTS, B -> BUFR. The input file is interpreted according to the message type.

-G
GRIBEX compatibility mode.

-7
Does not fail when the message has wrong length

-x
Fast parsing option, only headers are loaded.

grib_ls examples

  1. Without options a default list of keys is printed.
    The default list is different depending on the type of GRIB message.

    > grib_ls ../data/reduced*.grib1 ../data/regular*.grib1 ../data/reduced*.grib2
  2. To print offset and count number in file use the keys offset and count
    Also the total count in a set of files is available as countTotal

    > grib_ls -p offset,count,countTotal ../data/reduced*.grib1
  3. To list only a subset of messages use the -w (where option).
    Only the pressure levels are listed with the following line.

    > grib_ls -w levelType=pl ../tigge_pf_ecmwf.grib2 
  4. All the GRIB messages not on pressure levels are listed as follows:

    > grib_ls -w levelType!=pl ../tigge_pf_ecmwf.grib2
  5. All the GRIB messages whose pressure levels are either "pl" or "sfc":

    > grib_ls -w levelType=pl/sfc ../tigge_pf_ecmwf.grib2
  6. To get the closest grid point to a latitude/longitude.

    > grib_ls -l 51.46,-1.33,1 -p paramId,name ../data/reduced_gaussian_surface.grib2
    ../data/reduced_gaussian_surface.grib2
    paramId     shortName    value 
    167         2t          282.002     
    1 of 1 grib messages in ../data/reduced_gaussian_surface.grib2
    
    1 of 1 total grib messages in 1 files
    Input Point: latitude=51.46  longitude=-1.33
    Grid Point chosen #3 index=749 latitude=51.63 longitude=0.00 distance=93.81 (Km)
    Other grid Points
    - 1 - index=845 latitude=48.84 longitude=0.00 distance=306.86 (Km)
    - 2 - index=944 latitude=48.84 longitude=356.40 distance=333.66 (Km)
    - 3 - index=749 latitude=51.63 longitude=0.00 distance=93.81 (Km)
    - 4 - index=844 latitude=51.63 longitude=356.25 distance=168.37 (Km)
  7. To get a list ordered by the "level" key (ascending order).
    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!

    > grib_ls -B "level:i asc" tigge_af_ecmwf.grib2

 

  • No labels