User Tools

Site Tools


atmos:software:readgrib

Read_GRiB (“read_grib”) is a World Meteorological Organization (WMO) GRiB file reader.

To Download tar file, click here: read_grib. Website located: here.

Read_grib reads GRiB formatted data files into Matlab.

Installation

The downloaded tar file contents untars into the directory read_grib.r3.

Compilation

Compilation is relatively simple as there only one file needs compilation. Move into the read_grib directory as start Matlab. Type the following: » mex BDS_unpack_mex5.c

Tutorial

The syntax for read_grib is: grib_struct=read_grib(gribname,irec,p1,v1,p2,v2,…) where,

  • gribname - filename containing GRiB records.
  • irec - specifies which GRiB records to read. If irec is a vector, it specifies which GRiB records to return. If irec is a scalar, is specifies how far to read into the GRiB file. If irec==-1, READ_GRIB reads all records(default). Irec can be a cell array of parameter names to extract. Type read_grib('paramtable') for a list of parameter names. Irec can also be the string 'inv{entory}', so that READ_GRIB prints a GRiB contents list.

Examples

*To get an inventory of the grib, » grib_struct=read_grib('eta.grb','inv');

*To extract (decode) the first and third records in the grib, » grib_struct=read_grib('eta.grb',[1 3])

*The decoded records are in the .fltarray fields of the 1×2 grib_struct structure. The parameter names are in the .parameter fields of the grib_struct: » {grib_struct(1:2).parameter}

*The times of the parameters in the GRiB are in the .pds fields of the grib_struct: » grib_struct(1).pds

*To extract all records in the grib, » grib_struct=read_grib('eta.grb',-1);

atmos/software/readgrib.txt · Last modified: 2020/01/29 17:25 by 127.0.0.1