fwrite a grib data file from nc data

Eric Altshuler ela at COLA.IGES.ORG
Wed Sep 30 17:18:18 EDT 2009


Hi Emily,

fwrite writes data in binary format, not GRIB. Remove the line 'DTYPE grib' from the ctl file. You also have two bugs in your script:

while (t0<222)

should be:

while (t0<=222)

and also

while (h>850)

should be:

while (h>=850)

Using < and >, the values for t=222 and lev=850 will not be written because the last iteration of the loops will be for t=221 and lev=875.

I also don't see any entry for the v wind in your ctl file for the netcdf data. If it is not in the dataset, your wind speed calculation will fail because of missing v wind.

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: "Emily" <yi_zhou01 at YAHOO.CA>
To: GRADSUSR at LIST.CINECA.IT
Sent: Wednesday, September 30, 2009 4:02:13 PM GMT -05:00 US/Canada Eastern
Subject: fwrite a grib data file from nc data


Hi group memeber,

I write a gs file to create a data set which is time series changing with height.
My original data is NARR netCDF data sets (8 times per day)
The ddf file as below:
==========
DSET d:\gradsfile\ncdata\uwnd.200812.nc
DTYPE netcdf
TITLE NARR 4D field Lambert Conformal Conic projection
UNDEF 32766 missing_value
UNPACK scale_factor=0.01f add_offset=47.66f
PDEF 349 277 lcc 1 -145.5 1 1 50 50 -107 32463.41 32463.41
XDEF 615 linear 150 0.3333
YDEF 255 linear 2 0.3333
ZDEF 29 levels 1000, 975, 950, 925, 900, 875, 850, 825, 800, 775, 750, 725, 700,
650, 600, 550, 500, 450, 400, 350, 300, 275, 250, 225, 200, 175, 150, 125, 100
tdef 248 linear 00:00z01dec2008 3hr
vars 3
uwnd 29 t,z,y,x grid_eastward_wind
lat=>glat 0 y,x Latitude
lon=>glon 0 y,x Longitude
endvars
===============
vwnd200812.ddf is simillar with above.

My gs file as below:
=============
'reinit'
'open d:\gradsfile\ncdata\uwnd200812.ddf'
'open d:\gradsfile\ncdata\vwnd200812.ddf'
*'set grads off'
*'set grid off'
'set gxout fwrite'
'set fwrite d:\gradsfile\ncdata\wind-height09z28dec2008.grd'
'set dfile 1'
'set lon 283.3'
'set lat 43.66'
*'set time 09z28dec2008'
'set dfile 2'
'set lon 283.3'
'set lat 43.66'
*'set time 09z28dec2008'
h=1000
t0=218
while(t0<222)
'set t 't0''
while(h>850)
'set lev 'h''
'u=0.01*uwnd.1+47.66'
'v=0.01*vwnd.2+47.66'
'wind=mag(u,v)'
'd wind'
h=h-25
endwhile
t0=t0+1
endwhile
say 'ok'
===============
My ctl file is as below:
==========
DSET d:\gradsfile\ncdata\wind-height09z28dec2008.grd'
DTYPE grib
TITLE Wind-Height 09z12dec2008
UNDEF 32766 missing_value
XDEF 1 linear 1 1
YDEF 1 linear 1 1
ZDEF 7 levels 1000, 975, 950, 925, 900, 875, 850
tdef 5 linear 03z28dec2008 3hr
vars 1
wind 7 99 wind_height
endvars
=========
When I open the ctl file from Grads, it shows:
can not open station/index map file (null)
the data file was not open.

I don't know what's wrong with it. Is there any one can tell me the reason? Thanks.

Regards


Emily
York University, Toronto



More information about the gradsusr mailing list