From grib file to binary file

Eric Altshuler ela at COLA.IGES.ORG
Thu Jul 17 19:16:04 EDT 2008


Hello Anelise,

The dimensions for ydef (and possibly for xdef) in your teste.ctl file are wrong. ydef should have a dimension of 157, the same as it is in the ctl files for the grib datasets. The situation for xdef is more complicated because the datasets are global in longitude. If you open such a dataset in grads, and it is the first dataset you open in that grads session, the dimension environment will automatically "wrap around" in longitude. What this means is that data at the starting longitude (0.0 degrees in this case) is duplicated internally by grads, i.e. if the longitudes of the grid points in the dataset are:

0.0 1.25 2.5 ... 357.5 358.75 (288 longitudes)

then grads will duplicate the data along 0.0 degrees:

0.0 1.25 2.5 ... 357.5 358.75 0.0 (289 longitudes)

so that the x-dimension of the internally stored data is actually 289 instead of 288. If you write data in 'fwrite' mode without changing the range of longitude with 'set x' or 'set lon', the resulting fwrite file will have an x-dimension of 289. You probably don't want this. To prevent the wrap-around, do the following before writing the fwrite file:

set x 1 288

or, alternatively,

set lon 0 358.75

The first option is easier since it's necessary to calculate the easternmost longitude (358.75 in this case). Now, your fwrite file should be slightly smaller than before (288*157*4*2 = 361728 bytes). In your teste.ctl file, the dimensions of xdef and ydef should be 288 and 157. It should work now.

Best regards,

Eric L. Altshuler
Assistant Research Scientist
Center for Ocean-Land-Atmosphere Studies
4041 Powder Mill Road, Suite 302
Calverton, MD 20705-3106
USA

E-mail: ela at cola.iges.org
Phone: (301) 902-1257
Fax: (301) 595-9793

----- Original Message -----
From: "Anelise Baur" <anelisebaur at YAHOO.COM.BR>
To: GRADSUSR at LIST.CINECA.IT
Sent: Thursday, July 17, 2008 4:04:11 PM GMT -05:00 US/Canada Eastern
Subject: From grib file to binary file


Hello grads users!
Â
I’m trying to write a single binary file, the first records from two different grib files (nww3.UGRD.grb and nww3.VGRD.grb, from NOAA’s site). When I open this new file in GRADS I keep getting errors, particularly for the second variable. Can someone help me?
My procedures were:
Â
1º I’ve created the .ctl files (nww3.UGRD.ctl and nww3.VGRD.ctl) with grib2ctl.pl; I’ve obtained the following files:
Â
dset ^nww3.UGRD.grb
index ^nww3.UGRD.grb.idx
undef 9.999E+20
title nww3.UGRD.grb
* produced by grib2ctl v0.9.12.5p39c
dtype grib 233
options yrev
ydef 157 linear -78.000000 1
xdef 288 linear 0.000000 1.250000
tdef 61 linear 12Z28apr2008 3hr
zdef 1 linear 1 1
vars 1
UGRDsfc 0 33,1,1 ** surface u wind [m/s]
ENDVARS
Â
Â

dset ^nww3.vgrd.grb
index ^nww3.vgrd.grb.idx
undef 9.999E+20
title nww3.vgrd.grb
* produced by grib2ctl v0.9.12.5p39c
dtype grib 233
options yrev
ydef 157 linear -78.000000 1
xdef 288 linear 0.000000 1.250000
tdef 61 linear 12Z28apr2008 3hr
zdef 1 linear 1 1
vars 1
VGRDsfc 0 34,1,1 ** surface v wind [m/s]
ENDVARS
Â
2º I’ve created the grb.idx files (nww3.UGRD.grb.idx and nww3.VGRD.grb.idx) with grib2ctl.pl and gribmap.
Â
3º I’ve opened nww3.UGRD.ctl and nww3.VGRD.ctl in the GRADS.
Â
4º I did ‘set gxout fwrite’, then ‘d UGRDsfc’ and ‘d VGRDsfc’. I’ve obtained the binary file grads.fwrite (with 354kb).
Â
5º Then, I’ve created a .ctl file for the file grads.fwrite, called teste.ctl:
Â
dset ^grads.fwrite
undef 9.999E+20
title teste20_06
ydef 158 linear -78.000000 1
xdef 289 linear 0.000000 1.250000
tdef 1 linear 12Z28apr2008 3hr
zdef 1 linear 1 1
vars 2
u 0 99 ** surface v wind [m/s]
v 0 99 ** surface v wind [m/s]
ENDVARS
Â
6º I’ve opened teste.ctl in the GRADS, and I’ve written ‘set gxout shaded’, then ‘d u’, without problems. The problem appears when I display the next variable,v. GRADS doesn’t recognize v. The error is:
Â
Â
Low Level I/O Error: Read error on data file
Data file name = e:/swan_pendrive/02_07/25_06/25_06/grads.fwrite
Error reading 289 bytes at location 90457
Data Request Error: Error for variable 'v'
Error ocurred at column 1
DISPLAY error: Invalid expression
Expression = v
Â
Â
It indicates a problem with the binary file grads.fwrite.
Â
Thanks in advance,
Â
Anelise Pereira Baur
Universidade Federal do Rio Grande do Sul
Instituto de Matemática
anelisebaur at yahoo.com.br


      Novos endereços, o Yahoo! que você conhece. Crie um email novo com a sua cara @ymail.com ou @rocketmail.com.
http://br.new.mail.yahoo.com/addresses



More information about the gradsusr mailing list