READ_GRIB is now being used by numerous people at a wide variety of places. Alert users at the
following locations have found bugs that I've created, suggested improvements, and provided
testing of READ_GRIB. Many thanks.
| NOAA | Universita di Genova e della Basilicata |
| Uni. of Miami | Nanjing Institute of Meteorology, China |
| Uni. of Wisconsin Space Science and Engineering | Universidad de Concepcion |
| Uni. of Virginia ENVI-SCI | Universities of Innsbruck |
| Boeing Aircraft | GKSS Forschungszentrum Institute for Coastal Research |
| Colorado State | University of Kiel Leibniz Institute of Marine Sciences |
| C-CORE Consulting | energy & meteo systems GmbH |
| Weather Services International (WSI), Inc. | School of Environmental Sciences University of East Anglia |
| M.I.T. | RPS Kirk McClure Morton |
| University of Southampton, UK | Maurice Lamontagne Institute Peches et Oceans Canada |
| University of Quebec | School of Engineering University of Edinburgh |
READ_GRIB reads WMO international exchange GRiB formatted data files into MATLAB. It has various input modes, including extraction of individial GRiB records by record number, extraction by parameter name (which is not unique), and generating an inventory of the GRiB file contents. It has been tested on the following standard model output files: AVN, ETA, RUC, ECMWF, and WAM. The default GRiB parameter table used is the NCEP Operational table.
Version 1.4.0
is a bug fix for Version 1.3.1 It repairs a memory leak in the code that unpacks the Binary
Data Segment. This bug was hidden in V1.3.1 and prior under MATLAB R13 and less. But it
became fatal in R14. The memory needed for BDS_unpack is now handled according to R14 requirements.
Calls to READ_GRIB now look like:
>> grib_struct=read_grib(gribname,irec,'HeaderFlag',0,'ParamTable','ECMWF128');
DOWNLOAD the read_grib.m SVN rev 1 (V1.4.2) tar file.
INSTALLATION:
The tar file contents untar into the directory read_grib.r1. The files
can be left here and the path to read_grib be included in the startup.m
file.
COMPILATION:
The decoding of the binary sections of the GRiB records uses
c-code written by Wesley Ebisuzaki .
Click here
for GRiB format documentation.
There is now only 1 mex file, written in c, that needs to be compiled. Fire up
MATLAB in the read_grib directory and type the following:
TUTORIALThe calling syntax for READ_GRIB is:
grib_struct=read_grib(gribname,irec,p1,v1,p2,v2,...)The first 2 arguments are required:
READ_GRIB outputs a MATLAB structure containing the GRiB contents for the requested records. Call read_grib('output_struct') for a better description.
Examples: Assume the existence of a GRiB file that contains a few records from the NCEP operational ETA model. This file is called eta.grb.
>> grib_struct=read_grib('eta.grb','inv');
>> grib_struct=read_grib('eta.grb',[1 3])
Searching for first GRIB marker...
GRiB Record marker "GRIB" found at chars 1-4
GRiB header =
GRIB
GRec= 1 : FPos1= 4 : GLen= 29412 : FPos2= 29412 : EOGRiB=7777 ***
GRec= 2 : FPos1= 29412 : GLen= 20388 : FPos2= 49800 : EOGRiB=7777
GRec= 3 : FPos1= 49800 : GLen= 20388 : FPos2= 70188 : EOGRiB=7777 ***
GRec= 4 : FPos1= 70188 : GLen= 36180 : FPos2= 106368 : EOGRiB=7777
grib_struct =
1x2 struct array with fields:
sec1_1
lengrib
edition
file
record
description
parameter
units
level
gridtype
pds
gds
bms
bds
fltarray
The decoded records are in the .fltarray fields of the 1x2 grib_struct structure.
The parameter names are in the .parameter fields of the grib_struct:
>> {grib_struct(1:2).parameter}
'PRES [SFC]' 'VGRD []'
The times of the parameters in the GRiB are in the .pds fields of the grib_struct:
>> grib_struct(1).pds
ans =
len: 28
PTV: 2
IC: 'NCEP (WMC)'
GenProcID: 80
GridID: 255
HASGDS: 1
HASBMS: 0
parameter: 'PRES'
units: 'Pa'
description: 'Pressure '
layer: '1 - Surface [SFC]'
h_p_etc: [2x1 double]
year: 92
month: 12
day: 13
hour: 0
min: 0
fcast_time_unit: 'hour'
P1: 0
P2: 6
TRI: 'N/A'
TRI_N: 0
TRI_Nmissing: 0
century: 20
SubCID: 1
DecSF: -1
pdsvals: [28x1 double]
>> grib_struct=read_grib('eta.grb',-1);