Every second, the Sun's core fuses about 600 million tons of hydrogen into helium, and in the process converts 4 million tons of matter into energy. This energy, which can take between 10,000 and 170,000 years to escape the core, is the source of the Sun's light and heat. Far in the future, when hydrogen fusion in the Sun's core diminishes to the point where the Sun is no longer in hydrostatic equilibrium, its core will undergo a marked increase in density and temperature which will push its outer layers to expand, eventually transforming the Sun into a red giant. This process will make the Sun large enough to render Earth uninhabitable approximately five billion years from the present. After this, the Sun will shed its outer layers and become a dense type of cooling star (a white dwarf), and no longer produce energy by fusion, but still glow and give off heat from its previous fusion for trillions of years. After that it might become a super dense hypothetical black dwarf, giving off no more energy.
The Sun is about halfway through its main-sequence stage, during which nuclear fusion reactions in its core fuse hydrogen into helium. Each second, more than four million tonnes of matter are converted into energy within the Sun's core, producing neutrinos and solar radiation. At this rate, the Sun has so far converted around 100 times the mass of Earth into energy, about 0.03% of the total mass of the Sun. The Sun will spend a total of approximately 10 to 11 billion years as a main-sequence star before the red giant phase of the sun.[133] At the 8 billion year mark, the sun will be at its hottest point according to the ESA's Gaia space observatory mission in 2022.[134]
Wgrib2 is a processor for grib2 files. It is a utilityand library for manipulating grib files, The utility was designed to beused to reduce the need for custom Fortran programs to read, write and manipulate grib files.Wgrib2 has the following abilities.
- inventory and read grib2 files
- create subsets
- create regional subsets by cookie cutter or projections
- export to ieee, text, binary, CSV, netcdf and mysql
- import to ieee, text, binary, and netcdf
- write of new grib2 fields
- parallel processing by using threads (OpenMP)
- parallel processing by flow-based programming
Wgrib2 is versatile because it's command line is a simplelanguage. This makes wgrib2 useful in embedding. Some programs that embed wgrib2.
- g2ctla control maker for GraADS
- atl_g2ctl, alt_gmpalternative versions of g2ctl/gribmap for forGraADS
- grib-filter/g2subset cgi-bin programs for Nomads (NOAA OperationalModel Archive & Distribution System)
- g2grb.gs enables GrADS to write grib2 files
- grb1to2.pl grib1 to grib2 converter
- Xplane11 flight simulator
- rNOMADS R interface for NOAA weather data
OpenMP ConfigurationOpenMP is used to speed up wgrib2 by running loops overmultiple cores. OpenMP is enabled by default for most buildsand you can slow up your machine if you the wrong OpenMPconfiguration.The first configuration is to set up the number ofthreads that wgrib2 will use. The default configurationis set the number of threads equal to the number ofphysical cores. The default is reasonable except forwhen your computer becommes becomesunresonsive. For a 4 core CPU, I set the number of threadsto be 3, so I another core to handle other work.
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.