<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">All,<br>
<br>
I have a script that allows me to process a text file of latitude longitudes (stations) and I'm trying to output area averages of a particular file based on the points generated from the text file.<br>
<br>
I'm basically calculating the grid point spatially associated with a specific station.
<br>
<br>
So far it works to give me the x1, x2, y1, y2 but I can't make it loop over all the points for area average of the gridded file.<br>
<br>
My version of grads: Config: v2.0.a9.oga.1 little-endian readline printim grib2 netcdf hdf4-sds hdf5 opendap-grids,stn athena geotiff shapefile<br>
<br>
Here is the script (some of the material is likely obsolete as I got the code from an earlier project):<br>
<br>
function main(arg)<br>
<br>
file = subwrd(arg,1)<br>
size = subwrd(arg,2)<br>
color = subwrd(arg,3)<br>
<br>
record = read(file)<br>
<br>
record = sublin(record,2)<br>
<br>
i = 0<br>
<br>
counter = record<br>
<br>
while(i < counter)<br>
<br>
record = read(file)<br>
<br>
record = sublin(record,2)<br>
<br>
ilat0 = subwrd(record,2)<br>
ilon0 = subwrd(record,1)<br>
ilon1 = subwrd(record,3)<br>
ilat1 = subwrd(record,4)<br>
<br>
<br>
*say ilon0 ilat0 ilon1 ilat1<br>
<br>
linia(ilat0,ilon0,ilon1,ilat1,size,color)<br>
<br>
i = i + 1<br>
<br>
endwhile<br>
<br>
return<br>
<br>
function linia(lon0,lat0,lon1,lat1,size,color)<br>
* Draws a line limited by two circles in _color<br>
'set line 'color<br>
'q w2gr 'lon0' 'lat0<br>
* 'q w2xy 'lon0' 'lat0<br>
x0=subwrd(result,3)<br>
y0=subwrd(result,6)<br>
xlo=x0-0.0540406<br>
xhi=x0+0.0540406<br>
ylo=y0-0.0540406<br>
yhi=y0+0.0540406<br>
* say x0' 'y0' 'lon0' 'lat0<br>
* say xlo' 'xhi' 'ylo' 'yhi <br>
'areal=aave(ht,x='xlo',x='xhi',y='ylo',y='yhi')'<br>
'd areal'<br>
areal=subwrd(result,6)<br>
say 'areal'<br>
*'q w2xy 'lon1' 'lat1<br>
*x1=subwrd(result,3)<br>
*y1=subwrd(result,6)<br>
*'draw line 'x0' 'y0' 'x1' 'y1<br>
* 'draw mark 3 'x0' 'y0' 'size''<br>
*'draw mark 3 'x1' 'y1' .07'<br>
return<br>
</div>
</body>
</html>