<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:black">All,<br>
<br>
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:black">I sent this around last night but it was probably too early/late for most people to see it so I thought I would send it again:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:black"><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<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Roberto Mera<o:p></o:p></p>
<p class="MsoNormal">Kendall Science Fellow in Climate Attribution<o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:12.0pt">Union of Concerned Scientists<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt">1825 K St. NW Suite 800<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt">Washington, DC 20006<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt">202-331-5447 (o)<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>