grib2ctl: see http://wesley.ncep.noaa.gov/grib2ctl.html 12/97: Perl5 version 9/97: v0.9.12.5 update grib2ctl.doc (about time) 1/11/96: renamed from swgrmap added support for regional models (eta, ngm, ruc, uw-nws) will even work on some ecmwf grib files. of course, this is purely accidental and is totally unsupported. ------------------------------------------------------------------------ revised: 5/98, 7/01, 8/09 Introduction The script grib2ctl.pl runs under Perl version 5 (Perl5). Grib2ctl.pl reads a grib file and tries to make a Grads control file. If the script doesn't work for you, at least the script is fairly simple and you can fix it. This program is unsupported and is to be used at your own risk. grib2ctl.pl was derived from grib2ctl which was written as a Bourne shell script. ["Pain, Pain, oh the Pain," cried the by-stander.] With the introduction of the Perl script, the shell script version is "really really" unsupported. How does "really really unsupported" compare with "unsupported"? I'm not sure but I think I'm allowed to laugh when you ask a question. Don't forget to send in your warranty card for your free upgrade. Installation To make grib2ctl.pl work, you need a copy of Perl5. Perl versions 1, 2, 3 and 4 will not work. (Type "perl -v" to see which version of perl is installed.) You should be able to find Perl on almost any Unix(-like) machine and even for Windows machines. By the way, if you paid more than media costs for Perl, you paid too much. The rest of the documentation is geared towards running grib2ctl.pl under UNIX/linux. (Windows is covered later.) Once you have found or installed Perl, you need to change the first line of grib2ctl.pl from #!/usr/bin/perl -w to reflect the location of Perl on your machine; for example, #!/usr/local/bin/perl -w Next you need to make grib2ctl.pl executable $ chmod 755 grib2ctl.pl (Don't type the dollar sign. It's a convention to show that the remainder of the line is on the command prompt.) Now you have to put grib2ctl.pl on your PATH or give the full pathname when you run the program. The examples below assume that grib2ctl.pl is on the path. Finally you need to install wgrib http://www.cpc.ncep.noaa.gov/products/wesley/wgrib.html and make sure that wgrib is on your PATH. Making GrADS control files Grib files often have two different times associated with them. For example a 5-day forecast has an initial time (ex. September 1) and a verification time (ex. September 6). GrADS understands both times and grib2ctl.pl can make control files for both formats. Using the initial time/analysis/reference time (for analyses). $ grib2ctl.pl grib_file >grib_file.ctl $ gribmap -i grib_file.ctl -0 <-- this is a zero $ grads run grads and open Landscape mode? (no for portrait): use default ga-> open grib_file.ctl open the control file ... execute some grads commands Using the verification time (for forecasts): $ grib2ctl.pl -verf grib_file >grib_file.ctl $ gribmap -i grib_file.ctl $ grads run grads and open Landscape mode? (no for portrait): use default ga-> open grib_file.ctl open the control file ... execute some grads commands The first line of both examples makes the control file and the second makes the index file. (Gribmap is part of GrADS.) grib2ctl allows a number of options including specifying the name of the index file. Type "grib2ctl.pl" to get the current list of options. The format is grib2ctl.pl [options] grib_file [optional index file] >control_file The options include: -ncep_opn .. use NCEP opn grib table for T62 NCEP fields -ncep_rean .. use NCEP reanalysis grib table for T62 NCEP fields -verf .. use forecast verification times -no_prs .. no prs suffix on variable name -no_suffix .. no suffix on variable name -365 .. 365 day calendar -ts[timestep] .. set timestep for individual time files (e.g. -ts6hr) -lc .. set lowercase option for parameter names -iso_profile .. set z coordinate to ocean isotherms -prs_profile .. set z coordinate to pressure (mb) -m_profile .. set z coordinate to meters above ground/msl -no_profile .. no z coordinates -raw .. raw grid -pdef_linear .. use linear interpolation for thinned Gaussian grids -iso_profile .. make profile using subsurface isoterms -analysis YYYYMMDDHH .. set initial time (e.g. -analysis 1999123100) initial time must have correct time spacing Note the -no_suffix option can cause problems if two different fields have the same name such as "surface temperature" and "cloud top temperature". In this example, both fields would be named "TMP" and the results would be unpredictable. Note that if you don't specify the index file name, the program will select the name for you. ---------------------------------------------------------------------- Grids grib2ctl can handle arbitrary lat-long, lambert conformal, polar stereographic, mercator and Gaussian grids. For the curvilinear grids, the code to generate the xdef/ydef are simplistic. They may need to be tweeked by editing the control file. ---------------------------------------------------------------------- Templates GrADS control file can use templates. For example, you have files of the form TMP.2009010100 TMP.YYYYMMDD TMP.2009010106 TMP.2009010112 .. TMP.2009010218 You can make a control file by grib2ctl.pl TMP.%y4%m2%d2%h2 >tmp.ctl or grib2ctl.pl TMP.200901%d2%h2 >tmp.ctl The tmp.ctl control file will use all the data. The supported templates are %y4, %y2, %m2, %m1, %d2, %d1, %h2, %h1, %f2, %f3 ---------------------------------------------------------------------- Variances, Ensembles The current version of grib2ctl does not know the difference between variances, means and ensemble members. Having variances & means or different ensemble members in the same file is a recipe for disaster. If you are using means and variances, they must be in separate files. The following 2 lines will make 2 files var.grb and novar.grb. (Ain't wgrib neat?) wgrib foo.grb | grep var | wgrib -i -grib foo.grb -o var.grb wgrib foo.grb | grep -v var | wgrib -i -grib foo.grb -o novar.grb Now grib2ctl can be run on var.grb and novar.grb. Note that the variable names and units in var.grb have NO indication that they are variance quantities. A similar technique can be used for sets of ensemble forecasts. ---------------------------------------------------------------------- Thinned Grids grib2ctl has support for thinned grids. It can either do nearest neighbor, linear (in longitude) interpolation. The nearest neighbor interpolation is the default and the linear interpolatin can be turned on by the -pdef_linear option (thanks Arlindo da Silva). For ECMWF thinned Gaussian grids, you have to use the option, -ec_gbl, because their grib files, while logical, don't conform to the grib1 standard. ---------------------------------------------------------------------- Windows Grib2ctl.pl works in Windows. I don't run it under windows but some users send me the fixes if anything breaks. ---------------------------------------------------------------------- 11/2007 option: -ec_gbl The ECMWF has been sending out reduced (thinned) Gaussian grid grib-1 data. The grib-1 documentation implicitly assumes that the thinned grids have a common left and right meridian. The people at ECMWF missed that implicit assumption. The -ec_gbl option forces grib2ctl to assume that the files are Gaussian and are incorrectly encoded using the ECMWF reduced Gaussian error. To use this option on correctly encoded reduced Gaussian file will cause a problem. ---------------------------------------------------------------------- bugs: (1) multiple vertical coordinates are not handled well (2) mixture of variance & means are not handled well (3) EC stream parameter is not handled well (4) time series with missing dates are not handled well (5) time series with no missing dates are not handled well (6) finite number of grids are supported (7) does not support infinite length GRIB files Comments: You can send them to Wesley Ebisuzaki, Wesley.Ebisuzaki@noaa.gov