Help to read grib files: FINAL SOLUTION

zilore mumba zmumba at YAHOO.COM
Thu Apr 13 04:38:57 EDT 2006


Idowu,
  Perhaps you could mention, when you write to UKMO, that the grib files from their global models (which we have at ACMAD on SYNERGIE) present no problem (to us) in creating ctl files and dsiplaying in GrADS. I suppose the files you are trying to work with are from the Africa-LAM model, which we do not have. If this is the case, perhaps the could code the later in a similar way to the former.
  BTW, if you are working on a Windows platform, this could also be a source of problems, because when you transfer files from *NIX to Windows, the later may try to interpret the data as ASCII.

  For you to create ctl file, proceed as:
  grib2ctl.pl grib_file_name >ctl_file_name
  the grib_file_name is the file you have in grib format
  the ctl_file_name is the name you have to give

  If your grib file contains a combination of analyses and forecasts, it is useful to use
grib2ctl.pl -verf grib_file_name >ctl_file_name

  Once you have created the ctl file you have to use gribmap as follows:
  gribmap -i ctl_file_name -0 -v
  the -v option is useful to show which records have matched (i.e. successfully scanned).

  Zilore Mumba

oluseun idowu <oluseun_idowu at YAHOO.COM> wrote:
    Thank you all for your help. I have written to the UK office to see if the grib files can be properly encoded.

Can you pls tell me the commands (step by step) to use when I want to, create the ctl with grib2ctl.pl and modify the X and Y steps? And again, to change the name of the variable so that I can input the final ctl file and eventually able to plot with GrADS.

Thanks

Henrique Barbosa <hmjbarbosa at GMAIL.COM> wrote:  Dear Oluseun,

There is a program call wgrib which is very usefull to find out what is
inside a misterius grib file. Here's the output I have from runing it
with your sample file:

71 hbarbosa at azusa hbarbosa> wgrib -verf -V sample_grib_file.grib

Undefined parameter table (center 74-2 table 160), using NCEP-opn
rec 1:0:date 2006032218 PVORT kpds5=4 kpds6= 205 kpds7=1 levels=(0,1)
grid=255 48hr fcst:
PVORT=Pot. vorticity [km^2/kg/s]
timerange 0 P1 48 P2 0 TimeU 1 nx 432 ny 432 GDS grid 0 num_in_ave
0 missing 0
center 74 subcenter 2 process 1 Table 160
latlon: lat -37.500000 to 40.080000 by -32.767000 nxny 186624
long 340.000000 to 57.580000 by -32.767000, (432 x 432) scan
64 mode 0 bdsgrid 1
min/max data 269.25 314.125 num bits 24 BDS_Ref 269.25 DecScale 0
BinScale -18

rec 2:560228:date 2006032300 PVORT kpds5=4 kpds6=205 kpds7=1
levels=(0,1) grid=255 54hr fcst:
PVORT=Pot. vorticity [km^2/kg/s]
timerange 0 P1 54 P2 0 TimeU 1 nx 432 ny 432 GDS grid 0 num_in_ave
0 missing 0
center 74 subcenter 2 process 1 Table 160
latlon: lat -37.500000 to 40.080000 by -32.767000 nxny 186624
long 340.000000 to 57.580000 by -32.767000, (432 x 432) scan
64 mode 0 bdsgrid 1
min/max data 266.75 310.375 num bits 24 BDS_Ref 266.75 DecScale 0
BinScale -18


As you can see, you grib file is wrongly encoded and it reports that
the step in X and Y
directions are -32.767 degrees.... and that is exactly what you get when you run
grib2ctl.pl

Well, what I did then was to create the ctl with grib2ctl.pl and
modify the X and Y steps.
I did it like:

X-step = (40.08 - (-37.5)) / 432 = 0.17958333
Y-step = (57.58 - (340-360)) / 432 = 0.17958333

Oh, I also changed the name of the variable because your grib file
uses a non-standard
table and grib2ctl was confused... So here is the final ctl for you file:

dset ^sample_grib_file.grib
index ^sample_grib_file.grib.idx
undef 9.999E+20
title sample_grib_file.grib
* produced by grib2ctl v0.9.12.5p33k
dtype grib 255
ydef 432 linear -37.500000 0.17958333
xdef 432 linear 340.000000 0.17958333
tdef 2 linear 18Z22mar2006 6hr
zdef 1 linear 1 1
vars 1
temp 0 4,205,1 ** temp
ENDVARS

now you just have to run gribmap on it and you should get it right.
I did and I am sending attached an image of the temperature field.

By the way, I would write to the UKMet guys if I were you. Just to check
why their grib files are encoded with the wrong X-Y-step.

Cheers,
Henrique


On 4/12/06, Henrique Barbosa wrote:
> Dear Oluseun,
>
> Verify the invalid descriptor. If you have 432 X-values, your X-step
> cannot be -32.767... that would mean almost going 40 times around
> the globe!
>
> Please check the grads help pages:
>
> http://grads.iges.org/grads/gadoc/descriptorfile.html
>
> There you will learn howto properly setup XDEF
>
> Cheers,
> Henrique
>
>
> On 4/12/06, oluseun idowu wrote:
> >
> > Dear Diane,
> > Many thanks for your help. I gave the command
> >
> > [oluseun at b129pc124 ~]$ gribmap -v -i sample_grib_file.ctl
> >
> > This is the error message
> >
> > Open Error: Missing or invalid dimension increment value
> > --> The invalid description file record is:
> > --> xdef 432 linear 340.000000 -32.767000
> >
> >
> > The data file was not opened.
> > File name is: sample_grib_file.ctl
> >
> > Anyway as you suggested, I attach the file to this email and again, the data
> > was received from UK Met Office
> > from their limited area model
> >
> > I will expect your reply. Thanks once more!
> >
> > Idowu
> >
> > Below is the description of the file as given to me from UK Met Office.
> > ----------------------------------------------------------------------
> > OK, I've attached a sample grib file to this e-mail. It contains the
> > level-1 model temperature field at T+48 and T+54. Once you confirm you
> > can read this I'll put the full data-set for one forecast onto our ftp
> > server: email.metoffice.gov.uk. This will be ~660Mb of data. We can get
> > these file-sizes down if you can work with data over a smaller
> > geographical area or you don't need all the vertical levels.
> >
> > Luke.
> > ----------------------------------------------------------------------------------------------------------------------------------------------------
> >
> >
> >
> > Diane Stokes wrote:
> >
> > Dear Idowu,
> >
> > That's just a warning message. It's possible that reasonable variable
> > names were chosen for your data. Did you try to run gribmap on the new
> > ctl file yet?
> >
> > gribm ap -v -i sample_grib_file.grib.ctl
> > The "-v" (verbose) option is important as it will tell you which records
> > matched. Other options may be necessary as well, but the above is a start.
> >
> > If g ribmap does not work, please post your control file to the list.
> >
> > That may help us to help you.
> >
> > Also, where did you get your sample grib file, sample_grib_file.grib?
> >
> > Diane
> >
> >
> > oluseun idowu wrote:
> > > Dear Diane,
> > > Thanks for your help. I can find the grib2ctl.pl in my system now though
> > > under grib_files folder. The next problem is that in an attempt to make
> > > grib.ctl file the error message below was reported. Any further help?
> > >
> > > [oluseun at b129pc124 ~]$ ./grib_files/grib2ctl.pl sample_grib_file.grib
> > > >sample_grib_file.grib.ctl
> > >
> > > Undefined parameter table (center 74-2 table 160), using NCEP-opn
> > >
> > > Undefined parameter table (center 74-2 table 160), using NCEP-opn
> > >
> > >
> > >
> > >
> > > */Diane Stokes /* wrote:
> > >
> > > The web address is actually:
> > >
> > >
> > http://www.cpc.ncep.noaa.gov/products/wesley/grib2ctl.html
> > >
> > > There's some useful information there in addition to the link to the
> > > script.
> > >
> > > Diane
> > >
> > > See Hai Ooi wrote:
> > > > Dear Oluseun Idowu,
> > > >
> > > > The grib2 ctl.pl is available in the website you
> > > > indicated
> > > > [http://www.cpc.noaa.gov/products/wesley/grib2ctl.html]
> > > > Anyway, hope the attached perl file can help you to
> > > > resolve your problem. If in doubt, please refer to the
> > > > usage document in the above-mentioned webpage.
> > > >
> > > > Best regards.
> > > >
> > > > Ooi
> > > >
> > > >
> > > >
> > > > Send instant messages to your online friends
> > > http://uk.messenger.yahoo.com
> > >
> > >
> > >
> > ------------------------------------------------------------------------
> > > To help you stay safe and secure online, we've developed the all new
> > > *Yahoo! Security Centre*
> > > .
> > >
> >
> > --
> > Diane Stokes
> > Environmental Modeling Center
> & gt; National Weather Service/NOAA
> >
> >
> >
> >
> >
> > ________________________________
> > Yahoo! Cars NEW - sell your car and browse thousands of new and used cars
> > online search now ________________________________
> >
> >
> >
> >
>




---------------------------------
  Yahoo! 360° NEW – Your one place to blog, create, publish & share!




---------------------------------
Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20060413/717c5a3e/attachment.html 


More information about the gradsusr mailing list