Skip Navigation Links 
NOAA logo - Click to go to the NOAA home page National Weather Service   NWS logo - Click to go to the NWS home page
Climate Prediction Center

About Us
   Our Mission
   Who We Are

Contact Us
   CPC Information
   CPC Web Team

HOME > Monitoring_and_Data > Oceanic and Atmospheric Data > Reanalysis: Atmospheric Data > wgrib2-import_(bin,ieee,text,grib)

wgrib2: -import_bin, -import_ieee, -import_text, -import_grib


wgrib2 will decode the grib file when necessary and save the decoded grid point values in a floating point array (DATA). The -import options read grid point values from a specified file and replace the values of DATA. You would use the -import options to fix old grib files or make new ones.

Note that the import functions will reset the precision of the grib writing (new files) to 12 bits. Any -set_metadata should be done after the -import functions.


-import_bin data.txt              .. a binary (native format floating point) file
-import_ieee            .. a big-endian 32-bit ieee file
-import_text data.txt		  .. a text file
                                     note that the -header and -no_header affect the data file format
-import_grib data.txt		  .. a grib2 file, only -g2clib 0 and -g2clib 1 supported
                                     conversion to we:sn and we:ns supported

Example 1

wgrib2 IN.grb -bin dump.bin              .. make a binary sequential file of the fields dump.bin             .. alter dump.bin
wgrib2 IN.grb -set_grib_type same -import_bin -grib_out
The -import options reads the data for one field and overwrites the current grid point values. The -grib_out option writes a new grib message with the new grid point values.

Example 2: using import to write a grib file

template.grb2             is a single message (field/record) grib2 file with the appropriate grid
                          usually a simple type like 6 hour forecast or analysis
new.bin                   is a binary file with a single field with th same grid as template.grb2

wgrib2 template.grb2 -import_bin new.bin -set_var TMP -set_lev "2 m above ground" -set_ftime "anl" \
     -set_date 1999123112 -grib_out new.grb2

This commands writes new.bin as a grib2 file as TMP2m analysis at 12Z Dec 31, 1999.

See also: -set_grib_type, -undefine, -grib_out, -set_date, -set_ftime, -set_lev, -set_var,

NOAA/ National Weather Service
National Centers for Environmental Prediction
Climate Prediction Center
5830 University Research Court
College Park, Maryland 20740
Climate Prediction Center Web Team
Page last modified: Feb 3, 2016.
Disclaimer Privacy Policy