4/14/2022: wgrib2 v3.1.1 is released
Changes for wgrib2 v3.1.1- fixes check_pdt_len for some ECMWF and ICON files with vertial coordinates
- fixes -unix_time because of glibc
- more support for unix time: -set_date, -import_netcdf
- tested: gcc/gfortran on Ubuntu 20.04, Redhat 7
- tested: icc/ifort on Redhat 7
- tested: AOCC v3.2 (clang, flang) on Ubuntu 20.04
- minor tested: Windows 10 using cygwin64
- minor tested: gcc/gfortran on Ubuntu 18.04
Usage
- each option corresponds to a subroutine call
- type wgrib2 to see primary options
- inventory format is specified on command line by options
- if no "inv" option is specified, -s is used
Joining the development effort
- Source code: knowledge of C and some grib-2
- Changes to existing source code has to use the same licence as the original code
- New code (files) must either be GNU or public domain.
- Github? No.
- Bug reports are important
- Some inovations by first time contributors
- first implementation of lat-lon of common grids
- write netcdf files
- callable wgrib2 (making wgrib2 a subroutine)
- write to mysql files
- AEC compression
- python interface
Contact wesley.e...@noaa.govContributions by
- Wesley Ebisuzaki: many modules
- Reinoud Bokhorst: tosubmsg, checksum
- DWD (Gregor Schee, Daniel Lee and others): AEC compression
- Jaakko Hyvätti: gribtab
- John Howard: callable wgrib2
- Dusan Jovic: staggered grids, proj4 code
- Kristian Nilssen: netcdf module
- Karl Pfeiffer: georeferencing
- Pablo Romero: unix_time
- Manfred Schwarb: many modules
- Arlindo da Silva: openGrADS, bbox
- Niklas Sondell: mysql module
- Sam Trahan: satellite tables
- George Trojan: python interface, improvements to wgrib2api
- Sergey Varlamov: netcdf module improvements, georeferencing updates
- thanks to the people who report the bugs and more who provide the fixes!
Documentation
- problems-error message
- Slides for talk to CUNY students 6/2016: grib1/grib2
- intro_grib2.pdf using GFS fcst
- Understanding the default inventory
- converting from wgrib to wgrib2 in scripts
- Powerpoint presentation 4/6/2011 at NCEP
- Changes in wgrib2 from 5/2012 to 1/2015 (pdf)
- submessages
- writing a simple function
- selecting fields to decode
- option types: init inv out misc
- bin, ieee, text format
- small fast databases
- usage questions
- using pipes and multiprocessing
- compile questions
- limitations
- make wgrib2 faster
- calling wgrib2 from C
- user defined grib tables
- special files
- some tricks
- some tricks for NCEP users
- one-line tricks
The options
- the common options
- all the commands
Some solutions
- Time interpolation of two grib files
- interpolation to new grid: new_grid, Lat-Lon nearest neighbor, Lat-Lon by Cressman
- CSV (comman separated value) file: -csv, -spread
- Windows_10 version of wgrib2
- Fast averaging
Selecting Fields/Records/MessageSelect/Ignore by name/level/time/etc
- -match process records that match a posix extended regular expression
- -not process records not matching a regular expression
- -match_inv the inventory used by -match and -not
- -i reads inventory from stdin for record selection
Select by number (better to use previous method)
- -d dump specific record
- -for select a range of records to process (nth message)
- -for_n select a range of records to process (nth message/submessage)
Selective Processing: if optionsAfter selecting the fields to process, you can refine the processing bythe "if" options. With wgrib2 v3.0.0, the IFstructure was improved. Scripts that used the older IF structure still work;however, the new IF structure is easier to read.If possible, it is better to use the match options than the if options.The -match/-not options prevent unwanted records from being processed whichsaves time over the if options which process the fields.Individual Grid Point Data
- -ij print value at grid point (i, j)
- -ijlat print lat, lon, value at grid point (i, j)
- -ilat print lat, lon, value of Nth grid point
- -lon prints the lat-lon, and value of the grid point nearest the specified lat-lon
- -max prints the maximum value
- -min prints the minimum value
- -stats prints some statistics about the fields
- -V verbose inventory (shows stats)
Regridding, Interpolating to new grids Wgrib2 has the ability to convert grib files from one gridto another. The conversion uses a user-selected interpolationscheme: bilinear (default), bicubic, nearest neighbor, budget, and spectral.The supported grids include lat-lon, gaussian, Lambert conformal, polar stereographic,and WMO-defined rotated lat-lon grid. This capability uses the NCEP IPOLATES2 libraryand is an optional package. Note: the interpolation uses scalar and vector interpolationschemes. For the vector quantities the V field must immediatelyfollow the corresponding U field.
- new_grid
- -new_grid_interpolation set interpolation type used by -new_grid
- wgrib2m fast regrid using multiple processes
Exporting data to other programs
- -netcdf: write data in netcdf format
- -mysql: export data to a mysql database
- -mysql_speed: export data to a mysql database
- -spread: write data for spreadsheets
- -csv: write in column separated values, another one for spreadsheets
- -text: data in text format
- -bin: data native binary floating point
- -ieee: data in big endian IEEE format
- -ijbox: write a rectangular grid of data
- -AAIG: arcinfo ascii grid, GIS
For a short list of options, type "wgrib -h"
For a complete list, type "wgrib -help all"
To search for an option, type "wgrib -help keyword"
Writing grib2Wgrib2 has adopted the template approach for writing grib. Youhave a sample grib2 message (template), and you modify the grid point valuesand metadata to create a new grib message that you can write.This is similar to how ECMWF's ECCodes writes grib. The other approachis to supply many parameters to create a grib message which is usedby NCEP's g2 library.
- from wgrib2 command line
- from GrADS using g2grb.gs
- fron python using write
- from fortran using grb2_write
Machines able to run wgrib2
64-bit with IPOLATES- Redhat 7 Enterprise: gcc/gfortran (primary development system)
- Redhat 7 Enterprise: gcc/gfortran, icc/ifortran
- SUSE Enterprise: gcc/gfortran, icc/ifortran
- Ubuntu 20.04: gcc/gfortran (primary development system)
- Ubuntu 20.04: AOCC's clang and flang (development system) with OpenJPEG
- Ubuntu 20.04: nvidia with OpenJPEG
- ARM: needed to be compiled with USE_NETCDF4=1, USE_JASPER=0 (old report)
- Redhat linux: 32-bit with IPOLATES, not tested recently, use netcdf4 (old report)
- Mandriva linux (old report)
- AIX: use makefile, some fiddling with libraries is necessary, not tested recently
- Solaris, needs gnu make and gcc (old report)
- Solaris-10 (old report)
- HPUX, needs changes to makefiles (old report)
- Windows: using Cygwin system produces 32-bit binaries (old report)
- Windows: using Cygwin system produces 64-bit binaries
- Windows: compiled MingW (not recent), Watcom C, icc/ifort (old report)
- Windows/linux subsystem (ubuntu): compiled with gcc/gfortran (old report)
- Intel-based Mac using gcc and gfortran
The makefile works on Redhat and Ubuntu (with needed installed options).For other systems, you may have to modify the makefile. The makefilerequires gnu make which is a common version of make.System dependencies: 32 vs 64 bit, big vs little endian, Windows vs Linux/UNIXThe wgrib2 source code is written to be portable; there are noissues with big vs little endian or the size of the integer aslong as it is 32 bits or more. The source code is written inANSI/ISO C (C89), with optional features that requirePOSIX or POSIX-2. There has been a debate about moving the base rquirements to C99.
- big vs little endian: either works
- 32-bit machine: files limited to 2GB files, netcdf3 may not work
- Windows: 2GB+ files with 64-bit cygwin, 2GB with other windows C compilers
- Windows: only 64-bit cygwin is supported
- POSIX: all POSIX code is optional. Regex support is POSIX and useful.
- JPEG2000: OpenJPEG library or Jasper library
Source Code and Compling HintsThe wgrib2 source code is written to the POSIX-2 standard. Features requiringPOSIX2, such as regular expressions, can usually be turned offin the makefile. The wgrib2 code can be compiled with 32 or 64 bit pointers and integers.However, the code has to be compiled in a like manner for all the libraries.Some packages are optional (netcdf, mysql) and enabling these options can reallyincrease the executable size. df19127ead