Using GrADS to retrieve HYCOM data

Mark Hess mhess at OCEANI.COM
Wed May 6 17:14:39 EDT 2009


All,

I can now open and display HYCOM MLD data in GrADS. My next step is to output a lat,lon,value ASCII file from the open dataset for a specified region.  The script (shown below) is a cannabalized/modified version of one sent to me by Arlindo some time ago (any errors in the script are mine not his).  While it does work, it is very slow. It was originally written to work from a local file so, I imagine the slow speed is because each time it writes a line in the ASCII file it needs to go out and pull that info from the http source.  Is there a way I can first write the desired data to a NetCDF or binary file on my local disk and then write the ASCII file pulling from that file?  I tried unsuccesfully to use the frwite command, but perhaps I am using the command incorrectly.

Mark

SCRIPT:

'reinit'
'sdfopen http://hycom.coaps.fsu.edu/opendap/nph-dods/datasets/hycom/global/GLBa0.08_rect/data/2d/rarchv.2009_125_00_2d.nc'
*
* find Imax, Jmax
*
'q dims'
rec=sublin(result,2)
*Imax=subwrd(rec,13)
Imax=2170
say 'Imax 'Imax
rec=sublin(result,3)
*Jmax=subwrd(rec,13)
Jmax=2300
say 'Jmax 'Jmax
*
* define scaling environment by displaying any variable (otherwise an error
* results...)
*
'set gxout shaded'
'set lev 0'
'set lon 190 260'
'set lat 20 48'
'd mld'
*
* open output file and print header...
*
rc = write('mld.txt','i j lonval latval var')
i=1750
while ( i <= Imax )
j=1500
while ( j <= Jmax )
'q gr2w 'i' 'j
rec = sublin(result,1)
lonv = subwrd(rec,3)
latv = subwrd(rec,6)
'set x 'i
'set y 'j
'd mld'
var = subwrd(result,4)
say ''i' 'j' 'lonv' 'latv' 'var
lonval = math_format('%6.3f',lonv)
latval = math_format('%6.3f',latv)
rc = write('mld.txt',''i' 'j' 'lonval' 'latval' 'var'')
j=j+1
endwhile
i=i+1
endwhile
rc = close('mld.txt')
'quit'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20090506/b86c4a55/attachment.html 


More information about the gradsusr mailing list