[gradsusr] Reading ASCII output from daily data

mehwish ramzan mehwish.ramzan at gmail.com
Tue Aug 19 04:46:14 EDT 2014


Dear GrADS users,

Please help me in solving this problem.

I am converting my model output from hourly to daily for one year using
following procedure,

grib2ctl.pl r_pgb.2000010100 >r_p.ctl

then i edit the r_p.ctl file as follows to convert hourly data to daily
data;

dset ^r_pgb.%y4%m2%d2%h2
index ^r_pgb.2000010100.idx
options template
undef 9.999E+20

and
modify

tdef 360 linear   01jan2000 1dy

now when i display the variables in this control file, it works well.

The second step i want to do to extract few variables in ascii format from
the above control file. For that i used script from GrADS page to obtain
data for specific domain; (http://www.iges.org/grads/gadoc/ascii.html)


'open r_p.ctl'
'set x 113  155'
'set y 90   140'
outfile='variables.txt'
'!/bin/rm -f 'outfile
'set gxout print'
fmt='%8.3f'
numcols=43
'set prnopts 'fmt' 'numcols' 1'
'd lon'
lon_data = result
'd lat'
lat_data = result
'd tmp2m-273.15'
v1_data = result
'd pratesfc*60*60'24*
v2_data = result
'd tmpsfc-273.15'
v3_data = result
i=1
while (1)
 lons = sublin(lon_data,i)
 lats  = sublin(lat_data,i)
 line1 = sublin(v1_data,i)
 line2 = sublin(v2_data,i)
 line3 = sublin(v3_data,i)
 if (lons='' | lats='' | line1='' | line2='' | line3=''); break; endif
 if (i>1)
   j=1
   while (j<=numcols)
      str = subwrd(lons,j); lon = math_format(fmt,str)
      str = subwrd(lats,j); lat = math_format(fmt,str)
      str = subwrd(line1,j); v1 = math_format(fmt,str)
      str = subwrd(line2,j); v2 = math_format(fmt,str)
      str = subwrd(line3,j); v3 = math_format(fmt,str)
      record = lon' 'lat' 'v1' 'v2' 'v3
      rc = write(outfile,record,append)
      j=j+1
    endwhile
  endif
  i=i+1
endwhile


It is giving me output file as well. I copied the output data to EXCEL
spreadsheet. Now i am confused about reading the output data.

The grid spacing between two lat/lon is 0.5 degree and there are 360 days
in one year. Want to get values for each grid for all 360 days.

Please tell me where i am making mistake?

Thank you so much.

With Best Regards,

Mehwish
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20140819/390e2ebc/attachment.html 


More information about the gradsusr mailing list