impgrib - Import GRIB data sets

SYNOPSIS

impgrib  [ parameter=value ... ]  [ inputfile outputfile ]
impgrib  [ parameter=value ... ]  [ inputfile ... directory ]
impgrib2 [ parameter=value ... ]  [ inputfile outputfile ]
Parameters for impgrib are: long_names, name_levels.
Parameters for impgrib2 are: list_variables, multiple_files, no_output, include_vars, select_grid.

DESCRIPTION

impgrib produces TeraScan datasets from GRIB files. impgrib generates one output TeraScan file per input GRIB file.  impgrib2 is a more generic version of impgrib and can convert a broader range of GRIB files into TeraScan datasets.

impgrib essentially decompresses the GRIB BDS section, with instructions extracted from the PDS and GDS sections as needed.

impgrib can output 2-D and 3-D data. Several parameters may be imported into one output file; each parameter must have the same dimensions, and be registered to the same grid-ID. 3D variables are automatically generated for variables with the same parameter-ID which are stored contiguously in the input GRIB file.

Two output forms are supported: with long variable names, or with short variable names. Variable names are provided by $REFDATA/grib/grib_vars.txt, which contains both long and short names for a given parameter ID. 2D dataset variable names may be extended with an associated level-value, indicating a constant level of an independent parameter for which the data is relevant (e.g., constant altitude level for air-temperature data, written as temperature_0500 for temperature at 500m). If parameter name_levels=no, variable names are not extended. Other reference files are $REFDATA/grib/grib_grid.txt and $REFDATA/grib/grib_levels.txt, which serve to look up grid and level parameters for given grid- and level-ID's respectively.  impgrib2 utilizes the file $REFDATA/grib/wmo_grib_vars.txt for defining the variables names used in the TeraScan dataset.

NOTE: Currently (8/1/96) impgrib has only been tested/verified for grid ID = 223 and 240.

REFERENCE: For further documentation on GRIB formats, see:

John D. Stackpole, "A GUIDE TO GRIB (Edition 1), OFFICE NOTE 388, THE WMO FORMAT FOR THE STORAGE OF WEATHER PRODUCT INFORMATION AND THE EXCHANGE OF WEATHER PRODUCT MESSAGES IN GRIDDED BINARY FORM", Automation Division, National Meteorological Center, National Weather Service, NOAA

A GRIB SUMMARY:

The World Meteorological Organization (WMO) Commission for Basic Systems (CBS) Extraordinary Meeting Number VIII (1985) approved a general purpose, bit-oriented data exchange format, designated FM 92- VIII Ext. GRIB (GRIdded Binary). It is an efficient vehicle for transmitting large volumes of gridded data to automated centers over high speed telecommunication lines using modern protocols. By packing information into the GRIB code, messages (or records - the terms are synonymous in this context) can be made more compact than character oriented bulletins, which will produce faster computer-to-computer transmissions. GRIB can equally well serve as a data storage format, generating the same efficiencies relative to information storage and retrieval devices.

Each GRIB record intended for either transmission or storage contains a single parameter with values located at an array of grid points, or represented as a set of spectral coefficients, for a single level (or layer), encoded as a continuous bit stream. Logical divisions of the record are designated as "sections", each of which provides control information and/or data. A GRIB record consists of six sections, two of which are optional:

(0) Indicator Section

(1) Product Definition Section (PDS)

(2) Grid Description Section (GDS) - optional

(3) Bit Map Section (BMS) - optional

(4) Binary Data Section (BDS)

(5) '7777' (ASCII Characters)

THE INDICATOR SECTION (IS). The indicator section serves to: identify the start of the record in a human readable form, indicate the total length of the message, and indicate the Edition number of GRIB used to construct or encode the message.

THE PRODUCT DEFINITION SECTION (PDS). The PDS contains indicators for the Parameter table Version, the originating center, the numerical model (or "generating process") that created the data, the geographical area covered by the data, the parameter itself, the values for the appropriate vertical level or layer where the data reside, the decimal scale factor, and date/time information.

GRID DESCRIPTION SECTION (GDS). The purpose of the (optional) GDS is to provide a grid description for grids not defined by number in the PDS.

BIT MAP SECTION (BMS). The purpose of the (optional) BMS is to provide either a bit map or a reference to a bit map pre-defined by the center. The bit map consists of contiguous bits with a bit-to-data-point correspondence as defined in the grid description. A bit set equal to 1 implies the presence of a datum for that grid point in the BDS; a value of zero implies the absence of such.

BINARY DATA SECTION (BDS). The BDS contains the packed data and the binary scaling information needed to reconstruct the original data from the packed data. The required decimal scale factor is found in the PDS, above. The data stream is zero filled to an even number of octets.

END SECTION. The end section serves a human readable indication of the end of a GRIB record. It can also be used for computer verification that a complete GRIB record is available for data extraction. It should not be used as a search target since a '7777' bit combination could exist anywhere in the binary data stream.

PARAMETERS

long_names
Option for impgrib.  Specifies usage of long output parameter names. Valid responses are yes (long) or no (short). The default is yes.
name_levels
Option for impgrib.  Specifies whether output variable names are extended with a suffix indicating the associated level value. Valid responses are yes (include name-extension) or no (omit name extension). The default is yes.
list_variables
Option for impgrib2.  Specifies whether to output a list of the variable names contained within the GRIB file. Valid responses are yes or no. The default is no.
multiple_files
Option for impgrib2.  Specifies whether to output the data as multiple files.  This is useful if the GRIB file is time encoded.  The output filename will be concatenated with an "_hh" where hh represents the encoded hour.  Valid responses are yes or no. The default is no.
no_output
Option for impgrib2.  Specifies whether to skip generation of the TeraScan dataset.  This is useful if a list of the variables contained in the GRIB file is desired.  This option is intended to be used in conjunction with the print_variables option.  Valid responses are yes or no. The default is no.
include_vars
Option for impgrib2.  List of variables to include in the output subsets. If the list is prefixed with a minus sign, the listed variables are excluded from the subsets. Wildcards * and ? are allowed. The default is to include all variables.
select_grid
Option for impgrib2.  Specifies which output grid is to be used in creation of the TeraScan dataset; only variables contained in the selected grid will be written.  This option is only present when the GRIB file is encoded with multiple grids (earth locations).  The valid responses are grid numbers 1 through 255, and the prompting will display a list of the grids contained within the GRIB file being read.

EXAMPLES

In the first impgrib2 example, the input data file is encoded with multiple grids.  Note: Only regularly spaced grids can be converted to a TeraScan dataset with this version.  In this example, only variables contained in grid 23 will be output to the TeraScan dataset.
% impgrib2 imd.grib imd.tdf
list_variables : char(  3) ? [no]
multiple_files : char(  3) ? [no]
no_output      : char(  3) ? [no]
include_vars   : char(255) ? []
select_grid    : int       ? [23 24 39 40] 23

In the second impgrib2 example, the input data file is encoded for 1 time and 1 grid.  This example will output one TeraScan file containing all of the variables defined in the GRIB file.

% impgrib2 avn_000501_06_00 avn_000501_06_00.tdf
list_variables : char(  3) ? [no]
multiple_files : char(  3) ? [no]
no_output      : char(  3) ? [no]
include_vars   : char(255) ? []

In the third impgrib2 example, the input data file is encoded for multiple times and 1 grid. This example will output multiple TeraScan files with the names nww3_hh.tdf, where hh is the hours encoded within the GRIB file.

% impgrib2 nww3.all.grb nww3.tdf
list_variables : char(  3) ? [no]
multiple_files : char(  3) ? [no] yes
no_output      : char(  3) ? [no]
include_vars   : char(255) ? []

In the first impgrib example, the output data is generated using short variable names with a name extension. The parameter is temperature, with short name TMP. As a content listing of the output confirms, the extended name is TMP_0002, indicating that the parameter data is relevant for level 2, in this case 2.0m altitude:

% impgrib 
in/out files   : char(255) ? A07.000GR output
long_names     : char(  3) ? [yes] no
name_levels    : char(  3) ? [yes]


A07.000GR: GRIB data found at offset 54, len 17134
A07.000GR: Sections found: PDS BDS 
A07.000GR: Grid ID 223
Parameter name  = TMP_0002    Parameter units = deg.K    Parameter ID = 11 
Parameter Layer = 2.000000 m                             Layer ID = 105 
% contents output
printout       : char(  3) ? [no] 
Contents of File: output    Page 1
Dimension       Size            Coord           Scale      Offset
 sample           144            x                  1           0
 line              73            y                  1           0
Attribute       Type            Units           Value
 history         byte                           
 projection      long            std_projection  rectangular
 et_affine       double                          -0.00359326 0 0 0.00359326 37
                                                  72.5
 center_lat      double          std_latitude     0  0.00 N
 center_lon      double          std_longitude   121 15.00 W
 map_angle       double          radians         0
 proj_param      double          std_latitude     0  0.00 N
 pass_date       long            std_date        95/09/27
 start_time      double          std_time        12:00:00
 satellite       string12                        unknown
Variable        Type            Units
 TMP_0002        float           deg.K          
Variable        Dimension       Size
 TMP_0002        line              73
 TMP_0002        sample           144
Variable            BadValue    ValidMin    ValidMax       Scale      Offset
 TMP_0002        -3.4028e+38 -3.4028e+38  3.4028e+38           1           0

In the second impgrib example, the output variable names will have the long format (default) without a name-extension. In contrast to example 1, the long name is temperature as opposed to TMP, which in this case is not given an appended level value:

% impgrib
in/out files   : char(255) ? A07.000GR output
long_names     : char(  3) ? [yes] 
name_levels    : char(  3) ? [yes] no
A07.000GR: GRIB data found at offset 54, len 17134
A07.000GR: Sections found: PDS BDS 
A07.000GR: Grid ID 223
 Parameter name  = temperature    Parameter units = deg.K    Parameter ID = 11 
 Parameter Layer = 2.000000 m                             Layer ID = 105 
% contents output
printout       : char(  3) ? [no] 
Contents of File: output    Page 1
Dimension       Size            Coord           Scale      Offset
 sample           144            x                  1           0
 line              73            y                  1           0
Attribute       Type            Units           Value
 history         byte                           
 projection      long            std_projection  rectangular
 et_affine       double                          -0.00359326 0 0 0.00359326 37
                                                  72.5
 center_lat      double          std_latitude     0  0.00 N
 center_lon      double          std_longitude   121 15.00 W
 map_angle       double          radians         0
 proj_param      double          std_latitude     0  0.00 N
 pass_date       long            std_date        95/09/27
 start_time      double          std_time        12:00:00
 satellite       string12                        unknown
Variable        Type            Units
 temperature     float           deg.K          
Variable        Dimension       Size
 temperature     line              73
 temperature     sample           144
Variable            BadValue    ValidMin    ValidMax       Scale      Offset
 temperature     -3.4028e+38 -3.4028e+38  3.4028e+38           1           0

In the third impgrib example, the long name format is used with the relevant name-extension. Thus, the parameter name here is temperature_0002, in contrast to example two above which omitted the level value from the parameter name: 

% impgrib A07.000GR output
long_names     : char(  3) ? [yes] 
name_levels    : char(  3) ? [yes] 
A07.000GR: GRIB data found at offset 54, len 17134
A07.000GR: Sections found: PDS BDS
A07.000GR: Grid ID 223
 Parameter name  = temperature_0002     Parameter units = deg.K    Parameter ID = 11 
 Parameter Layer = 2.000000 m                             Layer ID = 105 
% contents output
printout       : char(  3) ? [no] 
Contents of File: output    Page 1
Dimension       Size            Coord           Scale      Offset
 sample           144            x                  1           0
 line              73            y                  1           0
Attribute       Type            Units           Value
 history         byte                           
 projection      long            std_projection  rectangular
 et_affine       double                          -0.00359326 0 0 0.00359326 37
                                                  72.5
 center_lat      double          std_latitude     0  0.00 N
 center_lon      double          std_longitude   121 15.00 W
 map_angle       double          radians         0
 proj_param      double          std_latitude     0  0.00 N
 pass_date       long            std_date        95/09/27
 start_time      double          std_time        12:00:00
 satellite       string12                        unknown
Variable        Type            Units
 temperature_0002 float           deg.K          
Variable        Dimension       Size
 temperature_0002 line              73
 temperature_0002 sample           144
Variable            BadValue    ValidMin    ValidMax       Scale      Offset
 temperature_0002 -3.4028e+38 -3.4028e+38  3.4028e+38           1           0

In the fourth impgrib example, several input files are specified with a wild-card format, and the output is directed to the current directory '.' . The output variable names will have the long format (default) with a name-extension, as verified by a contents listing of all outputs:

% impgrib 7*/A*GRB .
long_names     : char(  3) ? [yes] 
name_levels    : char(  3) ? [yes] 
7_25_96_tests/A011000GRB: GRIB data found at offset 21, len 81534
7_25_96_tests/A011000GRB: Sections found: PDS GDS BDS 
7_25_96_tests/A011000GRB: Grid ID 240
 Parameter name  = pressure_reduced_to_MSL_0000    Parameter units = Pa    Parameter ID = 2 
 Parameter Layer = 0.000000 m                             Layer ID = 102 
7_25_96_tests/A071000GRB: GRIB data found at offset 21, len 81534
7_25_96_tests/A071000GRB: Sections found: PDS GDS BDS 
7_25_96_tests/A071000GRB: Grid ID 240
 Parameter name  = temperature_0002    Parameter units = deg.K    Parameter ID = 11 
 Parameter Layer = 2.000000 m                             Layer ID = 105
7_25_96_tests/A291000GRB: GRIB data found at offset 21, len 73388
7_25_96_tests/A291000GRB: Sections found: PDS GDS BDS 
7_25_96_tests/A291000GRB: Grid ID 240
 Parameter name  = wind_u_component_0000    Parameter units = m/s    Parameter ID = 33 
 Parameter Layer = 0.000000 none                             Layer ID = 208 
7_25_96_tests/A581000GRB: GRIB data found at offset 21, len 73388
7_25_96_tests/A581000GRB: Sections found: PDS GDS BDS 
7_25_96_tests/A581000GRB: Grid ID 240
 Parameter name  = wind_u_component_0010    Parameter units = m/s    Parameter ID = 33 
 Parameter Layer = 10.000000 m                             Layer ID = 105 
7_25_96_tests/A591000GRB: GRIB data found at offset 21, len 73388
7_25_96_tests/A591000GRB: Sections found: PDS GDS BDS 
7_25_96_tests/A591000GRB: Grid ID 240
 Parameter name  = wind_v_component_0010    Parameter units = m/s    Parameter ID = 34 
 Parameter Layer = 10.000000 m                             Layer ID = 105 
% contents A*GRB
printout       : char(  3) ? [no] 
Contents of File: A011000GRB    Page 1
Dimension       Size            Coord           Scale      Offset
 sample           360            x                  1           0
 line             181            y                  1           0
Attribute       Type            Units           Value
 history         byte                           
 projection      long            std_projection  rectangular
 et_affine       double                          -0.00898314 0 0 0.00898314 91
                                                  180.5
 center_lat      double          std_latitude     0  0.00 N
 center_lon      double          std_longitude   179 30.00 E
 map_angle       double          radians         0
 proj_param      double          std_latitude     0  0.00 N
 pass_date       long            std_date        96/07/24
 start_time      double          std_time        12:00:00
 satellite       string12                        unknown
Variable        Type            Units
 pressure_reduced_to_MSL_0000 float           Pa             
Variable        Dimension       Size
 pressure_reduced_to_MSL_0000 line             181
 pressure_reduced_to_MSL_0000 sample           360
Variable            BadValue    ValidMin    ValidMax       Scale      Offset
 pressure_reduced_to_MSL_0000 -3.4028e+38 -3.4028e+38  3.4028e+38           1           0
Contents of File: A071000GRB    Page 1
Dimension       Size            Coord           Scale      Offset
 sample           360            x                  1           0
 line             181            y                  1           0
Attribute       Type            Units           Value
 history         byte                           
 projection      long            std_projection  rectangular
 et_affine       double                          -0.00898314 0 0 0.00898314 91
                                                  180.5
 center_lat      double          std_latitude     0  0.00 N
 center_lon      double          std_longitude   179 30.00 E
 map_angle       double          radians         0
 proj_param      double          std_latitude     0  0.00 N
 pass_date       long            std_date        96/07/24
 start_time      double          std_time        12:00:00
 satellite       string12                        unknown
Variable        Type            Units
 temperature_0002 float           deg.K          
Variable        Dimension       Size
 temperature_0002 line             181
 temperature_0002 sample           360
Variable            BadValue    ValidMin    ValidMax       Scale      Offset
 temperature_0002 -3.4028e+38 -3.4028e+38  3.4028e+38           1           0
Contents of File: A291000GRB    Page 1
Dimension       Size            Coord           Scale      Offset
 sample           360            x                  1           0
 line             181            y                  1           0
Attribute       Type            Units           Value
 history         byte                           
 projection      long            std_projection  rectangular
 et_affine       double                          -0.00898314 0 0 0.00898314 91
                                                  180.5
 center_lat      double          std_latitude     0  0.00 N
 center_lon      double          std_longitude   179 30.00 E
 map_angle       double          radians         0
 proj_param      double          std_latitude     0  0.00 N
 pass_date       long            std_date        96/07/24
 start_time      double          std_time        12:00:00
 satellite       string12                        unknown
Variable        Type            Units
 wind_u_component_0000 float           m/s            
Variable        Dimension       Size
 wind_u_component_0000 line             181
 wind_u_component_0000 sample           360
Variable            BadValue    ValidMin    ValidMax       Scale      Offset
 wind_u_component_0000 -3.4028e+38 -3.4028e+38  3.4028e+38           1           0
Contents of File: A581000GRB    Page 1
Dimension       Size            Coord           Scale      Offset
 sample           360            x                  1           0
 line             181            y                  1           0
Attribute       Type            Units           Value
 history         byte                           
 projection      long            std_projection  rectangular
 et_affine       double                          -0.00898314 0 0 0.00898314 91
                                                  180.5
 center_lat      double          std_latitude     0  0.00 N
 center_lon      double          std_longitude   179 30.00 E
 map_angle       double          radians         0
 proj_param      double          std_latitude     0  0.00 N
 pass_date       long            std_date        96/07/24
 start_time      double          std_time        12:00:00
 satellite       string12                        unknown
Variable        Type            Units
 wind_u_component_0010 float           m/s            
Variable        Dimension       Size
 wind_u_component_0010 line             181
 wind_u_component_0010 sample           360
Variable            BadValue    ValidMin    ValidMax       Scale      Offset
 wind_u_component_0010 -3.4028e+38 -3.4028e+38  3.4028e+38           1           0
Contents of File: A591000GRB    Page 1
Dimension       Size            Coord           Scale      Offset
 sample           360            x                  1           0
 line             181            y                  1           0
Attribute       Type            Units           Value
 history         byte                           
 projection      long            std_projection  rectangular
 et_affine       double                          -0.00898314 0 0 0.00898314 91
                                                  180.5
 center_lat      double          std_latitude     0  0.00 N
 center_lon      double          std_longitude   179 30.00 E
 map_angle       double          radians         0
 proj_param      double          std_latitude     0  0.00 N
 pass_date       long            std_date        96/07/24
 start_time      double          std_time        12:00:00
 satellite       string12                        unknown
Variable        Type            Units
 wind_v_component_0010 float           m/s            
Variable        Dimension       Size
 wind_v_component_0010 line             181
 wind_v_component_0010 sample           360
Variable            BadValue    ValidMin    ValidMax       Scale      Offset
 wind_v_component_0010 -3.4028e+38 -3.4028e+38  3.4028e+38           1           0

 


Last Update: $Date: 2002/09/12 00:06:01 $