<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:&quot;Tahoma&quot;,&quot;sans-serif&quot;;color:black">All,<br>
<br>
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;;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:&quot;Tahoma&quot;,&quot;sans-serif&quot;;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>
&nbsp; <br>
record = sublin(record,2)<br>
<br>
i = 0<br>
<br>
counter = record<br>
<br>
while(i &lt; counter)<br>
<br>
&nbsp; record = read(file)<br>
&nbsp; <br>
&nbsp; record = sublin(record,2)<br>
&nbsp; <br>
&nbsp; ilat0 = subwrd(record,2)<br>
&nbsp; ilon0 = subwrd(record,1)<br>
&nbsp; ilon1 = subwrd(record,3)<br>
&nbsp; ilat1 = subwrd(record,4)<br>
&nbsp; <br>
&nbsp; <br>
*say ilon0 ilat0 ilon1 ilat1<br>
<br>
&nbsp;linia(ilat0,ilon0,ilon1,ilat1,size,color)<br>
&nbsp; <br>
&nbsp; i = i &#43; 1<br>
<br>
endwhile<br>
<br>
return<br>
<br>
&nbsp; function linia(lon0,lat0,lon1,lat1,size,color)<br>
* Draws a line limited by two circles in _color<br>
&nbsp;&nbsp;&nbsp; 'set line 'color<br>
&nbsp;&nbsp;&nbsp; 'q w2gr 'lon0' 'lat0<br>
*&nbsp;&nbsp;&nbsp; 'q w2xy 'lon0' 'lat0<br>
&nbsp;&nbsp;&nbsp; x0=subwrd(result,3)<br>
&nbsp;&nbsp;&nbsp; y0=subwrd(result,6)<br>
&nbsp;&nbsp;&nbsp; xlo=x0-0.0540406<br>
&nbsp;&nbsp;&nbsp; xhi=x0&#43;0.0540406<br>
&nbsp;&nbsp;&nbsp; ylo=y0-0.0540406<br>
&nbsp;&nbsp;&nbsp; yhi=y0&#43;0.0540406<br>
*&nbsp;&nbsp; say x0' 'y0' 'lon0' 'lat0<br>
*&nbsp;&nbsp;&nbsp; say xlo' 'xhi' 'ylo' 'yhi <br>
&nbsp;&nbsp;&nbsp; 'areal=aave(ht,x='xlo',x='xhi',y='ylo',y='yhi')'<br>
&nbsp;&nbsp;&nbsp; 'd areal'<br>
&nbsp;&nbsp;&nbsp; areal=subwrd(result,6)<br>
&nbsp;&nbsp;&nbsp; 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>
*&nbsp;&nbsp;&nbsp; 'draw mark 3 'x0' 'y0' 'size''<br>
*'draw mark 3 'x1' 'y1' .07'<br>
&nbsp; return<o:p></o:p></span></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</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>&nbsp;</o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
</body>
</html>