gribtonc (1) - Linux Manuals

gribtonc: GRIB to netCDF decoder

NAME

gribtonc - GRIB to netCDF decoder

SYNOPSIS

gribtonc [-l logpath] [-v] [-t timeout] [-e errpath] [-g userparams.tbl] [-q qspecs] CDL_path netCDF_path

DESCRIPTION

This program decodes GRIB products (embedded in WMO product envelopes) on the NWS High-Resolution Data Service (HRS) feed, writing the decoded products into a single netCDF output file, specified by netCDF_path. In case the output netCDF file does not already exist, the CDL_path must be supplied to specify the structure for the desired netCDF file, which gribtonc creates. The default parameter translation is made according to a definition by UCAR, but the user may supply specific translations in a separate file by the -g tabfile option. The user-supplied translations will override the default ones. GRIB products are converted to the units specified for the appropriate netCDF variable, if this differs from the units used for the GRIB parameter. A set of CDL files for all the model outputs appearing on the HRS data stream is provided with gribtonc for use in decoding HRS GRIB data.

FORMAT OF GRIB TO NETCDF TRANSLATION TABLE

The format of the translation table is as follows: Each line contains

GRIB parameter number
netCDF parameter name (cannot start with digit, [A-Za-z0-9_] only )
netCDF long description
netCDF units
An optional comment

These are all separated by semicolon (";"). To comment a whole line, put any letter or special character (i.e. not a digit) in front of it. Trailing spaces are ignored before each semicolon, but not after. The GRIB number may have spaces in front. Parameters found in the separate file take presidence over the default parameter table, those not listed in the separate file are unchanged. All parameters will be named with a level suffix in addition to the name assigned in the separate file.

EXAMPLE

The command
gribtocdl -v -g my.tab sst.grib > sst.cdl

will decode the products in sst.grib and generate the corresponding CDL code into file sst.cdl. The file my.tab contains a specific conversion table to be used when naming a parameter from GRIB. Later the GRIB file may be converted to netCDF by using gribtonc:

gribtonc -v -g my.tab sst.cdl sst.nc < sst.grib

The file my.tab looks like this:

Grib;netCDF;long name               ;units;comments
 31 ;CI    ;Sea-ice cover           ;none ;(0-1)
 34 ;SSTK  ;Sea surface temperature ;K    ;
151 ;MSL   ;Mean sea-level pressure ;Pa   ;
167 ;T2M   ;2 metre temperature     ;K    ;

gribtonc can run as a subprocess of the LDM pqact(1) program, receiving a stream of GRIB products from standard input and decoding them as they arrive. gribtonc can also be used as a standalone decoder, decoding products on its standard input into netCDF form, as specified by netCDF_file GRIB products that do not conform to the specified file structure (e.g. they are defined on a different grid or contain a grid parameter not included in the specified netCDF file) are skipped.

To use gribtonc from the LDM pqact(1) program requires adding entries to the pqact configuration file that invoke gribtonc on appropriate HRS products. The PIPE action should be used in pattern-action entries. The form of such an entry is:


  HRS   pattern         PIPE    gribtonc-executable
                                gribtonc-options
                                cdl-file        netcdf-file

where pattern is a regular expression pattern matching product identifiers of products that are to be decoded and written to the output file netcdf-file.

Any directories that do not exist in netcdf-file will be created as needed, so date components, for example, may be part of the output file path, specified by using matched parts of the regular expression pattern. In case the output netcdf-file does not already exist, it will be created from the CDL specification in the file specified by cdl-file.

The path of the executable for gribtonc must be specified as the first argument to the PIPE command, and should be either an absolute path name or in a directory in the executable search path of pqact.

An example pqact.conf entry for decoding GRIB products from the ETA model as they appear on the HRS data stream is:

# ETA model on Lambert conformal grid to yyyymmddhh_eta.nc
HRS     ^Y.Q... KWBC (..)(..).*/mETA
        PIPE    /usr/local/ldm/decoders/gribtonc
        etc/eta.cdl
        data/GRIB/(1:yyyy)(1:mm)12_eta.nc

Since gribtonc reads GRIB products from its standard input, it may be invoked independently of pqact(1) by using I/O redirection.

OPTIONS

-l logpath
Log file pathname. The program uses Unidata's ulog(3) package to write error and log messages. The default is to write to the syslogd(8) daemon. If this option is specified, however, then messages will be written to the file logpath unless that pathname is "-", in which case all messages will be written to standard error.
-v
Verbose logging. Informative messages (level LOG_INFO) are logged, including a line for each GRIB product decoded. By default, only messages of severity LOG_NOTICE and greater are logged.
-t timeout
Timeout in seconds (default is 600). If there has been no input available on stdin for the duration of the specified timeout, the program exits gracefully.
-e errpath
If a GRIB product cannot be decoded, perhaps because it is truncated or otherwise corrupted, it is appended to this file.
-g tabfile
Use GRIB-netcdf translation defined in this file. The format of this file is described below.
-q qspecs
Specification for how to expand so-called quasi-regular or thinned grids into rectangular grids. This argument is a comma-delimited text string that specifies the method of interpolation used (currently lin for linear or cub for cubic), and the latitude and longitude increments in degrees for the resulting grid (e.g. dlat=2.5,dlon=5.0).
CDL_path
The path name of a file to be used as a template for the netCDF file, if the netCDF file specified as output does not exist. If the netCDF output file does exist, this argument is ignored. A path name relative to the directory specified by the LDM_ETCDIR environment variable may be used, but you must make sure this environment variable is defined in gribtonc
netCDF_path
The path name of the netCDF output file. This may be specified as an absolute path name or (more typically) relative to the directory from which gribtonc is invoked. Directories that do not exist in the path name of the output file will be created as needed.

EXAMPLE

The command
gribtonc -v -l- -q "lin,dlat=2.5,dlon=5.0" avn-x.cdl avn-x.nc < avn-x.wmo
will decode the products in avn-x.wmo into the netCDF file avn-x.nc, creating the latter file if it does not already exist from the ASCII CDL template file avn-x.cdl. If the data contain quasi-regular grids, they will be expanded to full regular grids on a 2.5 by 5.0 degree grid before being written into the output file.

DIAGNOSTICS

Error messages and log messages are written to the log file.

SEE ALSO

gribdump(1), netcdf(3), pqact(1), udunits(3), ulog(3)