Skip Navigation Links www.nws.noaa.gov 
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-lon
 

wgrib2: -lon

Introduction

The -lon option prints the value of the grid point closest to the specified longitude latitude. The latitude-longitude of the grid point are also printed. If you use the verbose mode, the grid coordinates (i,j) and the number of the element are also printed. Any number of -lon options can be used.

-sh-2.05b$ wgrib2 eta.t00z.awphys18.grb2 -d 1 -s -lon 249 39 -lon 255 33
1:0:d=2003090300:MSLET:mean sea level:18 hour fcst:lon=249.035,lat=38.9912,val=101685:
lon=254.964,lat=32.9671,val=101668
-sh-3.00$ wgrib2 rtma.t12z.2dvaranl_ndfd.grb2.c2 -d 1 -v -lon -120 30
1:0:lon=240.008805,lat=29.988418,i=220037,ix=72,iy=206,val=0
In the latter example, the point at lon=240.008805,lat=29.988418 is the 220037th element in the array and its coordinates are (72,206). Note that these coordinates are after the data has been converted into a WE:SN scan order.

Usage

-lon LONGITUDE LATITUDE
      LONGITUDE = 0 .. 360
      LATITUDE = -90 .. 90

Example

$ wgrib2 test.grb2 -s -lon -90 20
1:0:d=2005090200:HGT:1000 mb:60 hour fcst:lon=270,lat=20,val=121.3
2:133907:d=2005090200:HGT:975 mb:60 hour fcst:lon=270,lat=20,val=344.4
3:263511:d=2005090200:HGT:950 mb:60 hour fcst:lon=270,lat=20,val=573
4:389058:d=2005090200:HGT:925 mb:60 hour fcst:lon=270,lat=20,val=806.5
...

Want Speed?

You want extract the values for a 1000 different points. So you call wgrib2 1000 times and complain that wgrib2 is slow. Well decoding a jpeg2000 compressed file 1000 times does take time.

  1. convert the file to simple packing which is faster to read
  2. run the 1000 wgrib2 jobs on 1000 CPUs. This works for me. :)
  3. convert the 1000 wgrib2 jobs into 1 wgrib2 job.
Running 1000 wgrib2 jobs is inefficient because you are uncompressing the file 1000 times! On feature of wgrib2 is that options can be repeated.
   Uncompressing file 3 times - SLOW
$ wgrib2 -lon lon1 lat1 >value.dat
$ wgrib2 -lon lon2 lat2 >>value.dat
$ wgrib2 -lon lon3 lat3 >>value.dat

   Uncompressing file with one pass/decode  - FAST
$ wgrib2 -lon lon1 lat1 -lon lon2 lat2 -lon lon3 lat3 >value.dat
The wgrib2 (1.9.5.1) is configured for 5000 arguments on the command line. That means you can extract up to 1000 points at one time. (see wgrib2 -config)
bash-3.2$ getconf ARG_MAX
131072
bash-3.2$ xargs --show-limits
Your environment variables take up 2300 bytes
POSIX lower and upper limits on argument length: 2048, 129024
Maximum length of command we could actually use: 126724
Size of command buffer we are actually using: 126724

See also: -lola See also: -config


NOAA/ National Weather Service
National Centers for Environmental Prediction
Climate Prediction Center
5200 Auth Road
Camp Springs, Maryland 20746
Climate Prediction Center Web Team
Page last modified: Feb 8, 2013
Disclaimer Privacy Policy