<div dir="rtl"><div dir="ltr" style="text-align:left">To Thomas Robinson <span id="result_box" class="" lang="en"><span class="">Thanks for</span> <span class="">the example,</span> <span class="">I tried</span> <span class="">the script</span> <span class="">in this </span></span><span id="result_box" class="" lang="en"><span class=""><span id="result_box" class="" lang="en"><span class="">way</span></span></span> <span class="">as</span> you<span class=""> showing me :<br>
<br><br><br>&#39;reinit&#39;<br>&#39;set display color white&#39;<br>f = &#39;<a href="http://goldsmr2.sci.gsfc.nasa.gov:80/dods/MATMNXSLV">http://goldsmr2.sci.gsfc.nasa.gov:80/dods/MATMNXSLV</a>&#39;<br>&#39;sdfopen &#39;f<br>
<br><br>start_time=3<br>end_time=12*34<br><br>&#39;set parea 0.7 10.5 0.6 8&#39;<br>&#39;set lat 32.5&#39;<br>&#39;set lon 35&#39;<br><br>set t &#39;start_time&#39;<br>while (time &lt;=end_time<br>&#39;set t  &#39;time<br>
<br> <br>&#39;d t850-273.16&#39;<br>cc=subwrd(result,4)<br>&#39;q time&#39;<br>ctime = subwrd(result,3)<br>chour = substr(ctime,9,15)<br>&#39;draw string 0.5 8 &#39;chour&#39;=&#39;cc<br><br><br>time=time+12<br>endwhile<br>
<br><br>&#39;printim avrg.png x1000 y700&#39;<br>&#39;end&#39;<br><br></span></span><br><span id="result_box" class="" lang="en"><span class="">But</span> <span class="">I get</span> <span class="">an error , </span></span><span id="result_box" class="" lang="en"><span class="">And</span> <span class="">I attach</span> <span class="">a screenshot</span> <span class="">of the error , </span></span><span id="result_box" class="" lang="en"><span class="">What</span> <span class="">did I do wrong?.</span></span></div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote"><div dir="ltr">2013/4/1 Thomas Robinson <span dir="ltr">&lt;<a href="mailto:ter@hawaii.edu" target="_blank">ter@hawaii.edu</a>&gt;</span></div><blockquote class="gmail_quote" style="margin:0 .8ex;border-left:1px #ccc solid;border-right:1px #ccc solid;padding-left:1ex;padding-right:1ex">
Aloha Avi, <div><br></div><div>It looks like your code for each time step is the same.  You can loop using while/endwhile.  Try this and change the variable end_time to whatever you want it to be:</div><div><br></div><div>
<div class="im">
<span style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">&#39;reinit&#39;</span><br style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
<span style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">&#39;set display color white&#39;</span><br style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
<span style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">f = &#39;</span><a href="http://goldsmr2.sci.gsfc.nasa.gov/dods/MATMNXSLV" style="color:rgb(17,85,204);font-size:13px;font-family:arial,sans-serif" target="_blank">http://goldsmr2.sci.gsfc.nasa.gov:80/dods/MATMNXSLV</a><span style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">&#39;</span><br style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">

<span style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">&#39;sdfopen &#39;f</span><br style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
<br></div>** Set the start and end times (month number)<br style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">start_time=3</div><div>end_time=12*34<div class="im"><br style>
<br style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif"><span style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">&#39;set parea 0.7 10.5 0.6 8&#39;</span><br style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">

<span style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">&#39;set lat 32.5&#39;</span><br style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
<span style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">&#39;set lon 35&#39;</span><br style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
<br></div>** Set the time to the start time<br>time=start_time</div><div>** Loop through the times<br>while (time &lt;=end_time<br>**Set time<br style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
<span style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">&#39;set t &#39; time</span><div class="im"><br style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
<span style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">&#39;d t850-273.16&#39;</span><br style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
<span style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">cc=subwrd(result,4)</span><br style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
<span style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">&#39;q time&#39;</span><br style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
<span style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">ctime = subwrd(result,3)</span><br style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
<span style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">chour = substr(ctime,9,15)</span><br style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
<span style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">&#39;draw string 0.5 8 &#39;chour&#39;=&#39;cc</span><br style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
<br></div>** Set the time to the next year</div><div>time=time+12</div><div><br></div><div>endwhile<div><div class="h5"><br style><br><br><div class="gmail_quote">On Sun, Mar 31, 2013 at 8:26 PM, avi kojokro <span dir="ltr">&lt;<a href="mailto:kojokroavi@gmail.com" target="_blank">kojokroavi@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="rtl"><div style="text-align:left"><br></div><div dir="ltr" style="text-align:left"><span lang="en"><span>Thank you.</span><br>

<span>I did not phrase</span> <span>the</span> <span>question correctly</span><span>, I think that</span> <span>the example</span> <span>I gave</span> <span>is not good.</span> <span>I</span> <span>will try</span> <span>to explain myself</span> <span>again.</span><br>


<span>First I</span> <span>must say</span> <span>that I am</span> <span>working</span> <span>with windows</span> <span>not Linux</span><span>.<br></span></span><span lang="en"><span>I want to get</span> <span>data</span> <span>from a server</span> <span>that already</span> <span>gives me a</span> <span>monthly averages,</span> <span>here&#39;s</span> <span>a better</span> <span>example of</span> <span>what i means</span><span>:<br>


<br><br>&#39;reinit&#39;<br>&#39;set display color white&#39;<br>f = &#39;<a href="http://goldsmr2.sci.gsfc.nasa.gov:80/dods/MATMNXSLV" target="_blank">http://goldsmr2.sci.gsfc.nasa.gov:80/dods/MATMNXSLV</a>&#39;<br>&#39;sdfopen &#39;f<br>


<br><br><br>&#39;set parea 0.7 10.5 0.6 8&#39;<br>&#39;set lat 32.5&#39;<br>&#39;set lon 35&#39;<br><br>&#39;set t 3 &#39;<br>&#39;d t850-273.16&#39;<br>cc=subwrd(result,4)<br>&#39;q time&#39;<br>ctime = subwrd(result,3)<br>


chour = substr(ctime,9,15)<br>&#39;draw string 0.5 8 &#39;chour&#39;=&#39;cc<br><br><br>&#39;set t 15 &#39;<br>&#39;d t850-273.16&#39;<br>cc=subwrd(result,4)<br>&#39;q time&#39;<br>ctime = subwrd(result,3)<br>chour = substr(ctime,9,15)<br>


&#39;draw string 0.5 7.7 &#39;chour&#39;=&#39;cc<br><br><br>&#39;set t 27 &#39;<br>&#39;d t850-273.16&#39;<br>cc=subwrd(result,4)<br>&#39;q time&#39;<br>ctime = subwrd(result,3)<br>chour = substr(ctime,9,15)<br>&#39;draw string 0.5 7.7 &#39;chour&#39;=&#39;cc<br>


<br></span></span><span lang="en"><span>How do I create</span> <span>a loop</span> <span>to do it</span> <span>automatically</span><span>, the server</span> <span>provides</span> <span>data</span> <span>from 1979 to</span> 2013<span>,</span> <span>and</span> <span>I want</span> <span>to get</span> <span>only the data</span> <span>of March.</span><br>


<br><span>I hope</span> <span>I have explained</span> <span>myself</span> <span>better.</span><br><span>Regards</span></span><br></div><div dir="ltr" style="text-align:left">avi.<br>
</div><br><div class="gmail_extra"><br><br><div class="gmail_quote"><div dir="ltr">2013/4/1 Muhammad Yunus Ahmad Mazuki <span dir="ltr">&lt;<a href="mailto:ukm.yunus@gmail.com" target="_blank">ukm.yunus@gmail.com</a>&gt;</span></div>



<blockquote class="gmail_quote" style="margin:0px 0.8ex;border-left:1px solid rgb(204,204,204);border-right:1px solid rgb(204,204,204);padding-left:1ex;padding-right:1ex"><div dir="ltr"><div><div>The average function itself has what you needed. ave(var1,t=1,t=360,<b>12</b>), this means it will average values from t=1,t=13,t=25 ... until t=360.Example of point value extraction.<br>




<br>&#39;sdfopen <a href="http://foo.nc" target="_blank">foo.nc</a>&#39;<br>lonvalue=90<br>latvalue=0<br>levvalue=850<br>tvalue=1<br>&#39;set lon &#39;lonvalue<br>&#39;set lat &#39;latvalue<br>&#39;set t &#39;tvalue<br>&#39;set lev &#39;levvalue<br>





&#39;d variable1&#39;<br>catch=sublin(result,4)<br>&#39;set gxout fwrite&#39;
<br>&#39;set fwrite point.dat&#39;<br>&#39;d &#39;catch<br>&#39;disable fwrite&#39;<br><br></div>This is a basic one, modify it as your need requires. I&#39;m not sure about excel, but this will create a binary file, which can be opened by GrADS (using a controller file) and Scilab (which I use for further analysis).<br>




<br></div>Yunus.<br></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div>On Sun, Mar 31, 2013 at 2:25 PM, avi kojokro <span dir="ltr">&lt;<a href="mailto:kojokroavi@gmail.com" target="_blank">kojokroavi@gmail.com</a>&gt;</span> wrote:<br>




</div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><div dir="rtl"><div dir="ltr" style="text-align:left"><span lang="en"><span>I&#39;m trying</span> <span>to do</span> <span>a script of </span></span><span lang="en"><span><span lang="en"><span>averages</span></span></span> <span>like this</span> <span>example</span> <span>:<br>





<br><br>&#39;set t 1 &#39;<br>&#39;define varav=ave(t850-273.16,t=1,t=1,1)&#39;<br>&#39;d varav&#39;<br>cc=subwrd(result,4)<br>&#39;draw string 0.5 8 jan=&#39;cc<br><br></span></span><span lang="en"><span>I want</span> <span>my</span> <span>script</span> <span>calculates</span> <span>every 12</span> <span>months,</span> <span>how do I create</span> <span>a loop</span> <span>script</span> <span>that</span> <span>calculates</span> <span>every 12</span> <span>month</span> <span>average</span> <span>of the same</span> <span>month.<br>





</span></span><span lang="en"><span>I</span> <span>will give</span> <span>an example of what</span> <span>I mean</span><span>:</span> <span>I want to begin</span> <span>to calculate</span> <span>average of</span> <span>January 1979</span> <span>and then</span> <span>later</span> <span>to calculate</span> <span>directly</span> <span>the</span> <span>January 1980</span> <span>and so on.<br>





</span></span><span lang="en"><span>Is it possible</span> <span>that the</span> <span>result</span> <span>will write</span> <span>directly to the</span> <span>Excel</span> <span>file</span><span>, then</span> <span>how to</span> <span>write</span> <span>the command</span> <span>to it.</span><br>





<br><span>Please note</span> <span>that I</span> <span>first started</span> <span>Grads.<br><br></span></span>Thank you so much. <br><span><font color="#888888"><br></font></span></div><span><font color="#888888"><div dir="ltr" style="text-align:left">




avi<br>
</div><div dir="ltr" style="text-align:left"><br></div><div style="text-align:right"><br></div></font></span></div>
<br></div></div>_______________________________________________<br>
gradsusr mailing list<br>
<a href="mailto:gradsusr@gradsusr.org" target="_blank">gradsusr@gradsusr.org</a><br>
<a href="http://gradsusr.org/mailman/listinfo/gradsusr" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a><br>
<br></blockquote></div><br></div>
<br>_______________________________________________<br>
gradsusr mailing list<br>
<a href="mailto:gradsusr@gradsusr.org" target="_blank">gradsusr@gradsusr.org</a><br>
<a href="http://gradsusr.org/mailman/listinfo/gradsusr" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a><br>
<br></blockquote></div><br></div></div>
<br>_______________________________________________<br>
gradsusr mailing list<br>
<a href="mailto:gradsusr@gradsusr.org" target="_blank">gradsusr@gradsusr.org</a><br>
<a href="http://gradsusr.org/mailman/listinfo/gradsusr" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div></div></div><span class="HOEnZb"><font color="#888888">-- <br>Tom Robinson<br>President - Graduate Student Organization <br>Graduate Student - Department of Meteorology<br>
732-718-2323<br>
</font></span></div>
<br>_______________________________________________<br>
gradsusr mailing list<br>
<a href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</a><br>
<a href="http://gradsusr.org/mailman/listinfo/gradsusr" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a><br>
<br></blockquote></div><br></div>