fwrite a grib data file from nc data

Emily yi_zhou01 at YAHOO.CA
Thu Oct 1 10:44:10 EDT 2009


Hi Eric,

I figured out the problem, and can display the wind time series with height.. The problem is that I include a ' symbol in my ctl file by mistake. Thanks.
Emily


--- On Wed, 9/30/09, Eric Altshuler <ela at COLA.IGES.ORG> wrote:

From: Eric Altshuler <ela at COLA.IGES.ORG>
Subject: Re: fwrite a grib data file from nc data
To: GRADSUSR at LIST.CINECA.IT
Received: Wednesday, September 30, 2009, 10:20 PM

Hi Emily,

What is the size of the binary file? It should be 7*5*4=140 bytes. If it's not that size, check your script for any bugs I may have missed. If it is 140 bytes, then I don't know why grads can't open the binary file. In fact, even if the file exists but has a size of 0 bytes, grads should open it. Make sure the file is actually being created. If it doesn't exist, I have no idea why.

Best regards,
Eric

----- Original Message -----
From: "Emily" <yi_zhou01 at YAHOO.CA>
To: GRADSUSR at LIST.CINECA.IT
Sent: Wednesday, September 30, 2009 9:47:24 PM GMT -05:00 US/Canada Eastern
Subject: Re: fwrite a grib data file from nc data

Hi Eric,

Thank you for figuring out the bugs. I corrected the problems, and rerun the gs to get a new grd file. However after scaning the discription file, it still can not open the binary file. It shows:

open error, cann't open the binary file.
My grads version is grads2.0 a3 for window XP.

BTW, my vwnd ddf file as below:
================
DSET d:\gradsfile\ncdata\vwnd.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
vwnd 29 t,z,y,x  grid_northward_wind
lat=>glat 0 y,x Latitude
lon=>glon 0 y,x Longitude
endvars
===========


Emily,
York University, Toronto

--- On Wed, 9/30/09, Eric Altshuler <ela at COLA.IGES.ORG> wrote:



From: Eric Altshuler <ela at COLA.IGES.ORG>
Subject: Re: fwrite a grib data file from nc data
To: GRADSUSR at LIST.CINECA.IT
Received: Wednesday, September 30, 2009, 5:18 PM


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20091001/20955958/attachment.html 


More information about the gradsusr mailing list