GRIB Library
The grib library has three functions for decoding data in format of GRIB-1, GRIB-2, or DGRB (Japanese Domestric Grid Binary format). GRIB-1 code is borrowed from wgrib.c and GRIB-2 code from NCEP library.
| Function | Parameter Type | Remark |
| g2unpack(fname[, fsec0, fsec1, fsec2, fsec3, fsec4, fsec5, fsec6, fsec7]) | strings | Unpacks GRIB2 data. The fname must be a GRIB file name and the optional parameters of fsec0 to fsec7 must be callback function names. Those functions will be called when a corresponding section message is found:
|
| g1unpack(fname[, fsec1, fsec2, fsec3, fsec4]) | strings | Unpacks GRIB1 data.
The fname must be a GRIB file name and the optional parameters of fsec1 to fsec4 must be callback function names (the functions will be called when a corresponding section message is found):
|
| dgunpack(fname[, func]); | strings | The fname must be a DGRB file name and the optional func must be a callback function name. The function will be called with six inputs: integer pointer to DGRB message, number of data, and bytes of a datum; and float pointer to decoded binary data, number of data, and bytes of a float datum |
| qregular(src, region, dst) | user, integer, user | Converts data on quasi-regular (thinned latitude/longitude) grids to regular grids. The src is a float-type pointer to 3447 data; the region code is from 37 to 44; and the dst is float-type pointer to 73x73 data. |
Example-1
load("grib.dll");
g2unpack("grid_file_name");
g2unpack("grid_file_name", "fsec0", "fsec1", "fsec2", "fsec3", "fsec4", "fsec5", "fsec6", "fsec7");
function fsec0(tid)
{
csv("sec0", tid);
}
function fsec1(ptr, n, e)
{
csv("sec1", ptr, n, e);
}
function fsec2(ptr, n, e)
{
csv("sec2", ptr, n, e);
}
function fsec3(ptr1, n1, e1, ptr2, n2, e2, ptr3, n3, e3)
{
csv("sec3", ptr1, n1, e1, ptr2, n2, e2, ptr3, n3, e3);
}
function fsec4(tid, ptr1, n1, e1, ptr2, n2, e2)
{
csv("sec4", tid, ptr1, n1, e1, ptr2, n2, e2);
}
function fsec5(tid, ptr, n, e)
{
csv("sec5", tid, ptr, n, e);
}
function fsec6(tid, ptr, n, e)
{
csv("sec6", tid, ptr, n, e);
}
function fsec7(ptr, n, e)
{
csv("sec7", ptr, n, e);
}
Example-2
load("grib.dll");
g1unpack("grid_file_name");
g1unpack("grid_file_name", "fsec1", "fsec2", "fsec3", "fsec4");
function fsec1(ptr, n, e)
{
csv("sec1", ptr, n, e);
}
function fsec2(ptr, n, e)
{
csv("sec2", ptr, n, e);
}
function fsec3(ptr, n, e)
{
csv("sec3", ptr, n, e);
}
function fsec4(ptr, n, e)
{
csv("sec4", ptr, n, e);
}
Example-3
load("grib.dll");
dgunpack("grid_file_name");
dgunpack("grid_file_name", "callback");
function callback(ptr1, n1, e1, ptr2, n2, e2)
{
csv(ptr1, n1, e1, ptr2, n2, e2);
}
