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>
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">'reinit'</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">'set display color white'</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">f = '</span><a href="http://goldsmr2.sci.gsfc.nasa.gov/dods/MATMNXSLV" target="_blank" style="color:rgb(17,85,204);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">http://goldsmr2.sci.gsfc.nasa.gov:80/dods/MATMNXSLV</a><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">'</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">'sdfopen 'f</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<br>** Set the start and end times (month number)<br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">start_time=3</div><div>end_time=12*34<br style="background-color:rgb(255,255,255)">
<br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">'set parea 0.7 10.5 0.6 8'</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">'set lat 32.5'</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">'set lon 35'</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<br>** Set the time to the start time<br>time=start_time</div><div>** Loop through the times<br>while (time <=end_time<br>**Set time<br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">'set t ' time</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">'d t850-273.16'</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">cc=subwrd(result,4)</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">'q time'</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">ctime = subwrd(result,3)</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">chour = substr(ctime,9,15)</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">'draw string 0.5 8 'chour'='cc</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<br>** Set the time to the next year</div><div>time=time+12</div><div><br></div><div>endwhile<br style="background-color:rgb(255,255,255)"><br><br><div class="gmail_quote">On Sun, Mar 31, 2013 at 8:26 PM, avi kojokro <span dir="ltr"><<a href="mailto:kojokroavi@gmail.com" target="_blank">kojokroavi@gmail.com</a>></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's</span> <span>a better</span> <span>example of</span> <span>what i means</span><span>:<br>
<br><br>'reinit'<br>'set display color white'<br>f = '<a href="http://goldsmr2.sci.gsfc.nasa.gov:80/dods/MATMNXSLV" target="_blank">http://goldsmr2.sci.gsfc.nasa.gov:80/dods/MATMNXSLV</a>'<br>'sdfopen 'f<br>
<br><br><br>'set parea 0.7 10.5 0.6 8'<br>'set lat 32.5'<br>'set lon 35'<br><br>'set t 3 '<br>'d t850-273.16'<br>cc=subwrd(result,4)<br>'q time'<br>ctime = subwrd(result,3)<br>
chour = substr(ctime,9,15)<br>'draw string 0.5 8 'chour'='cc<br><br><br>'set t 15 '<br>'d t850-273.16'<br>cc=subwrd(result,4)<br>'q time'<br>ctime = subwrd(result,3)<br>chour = substr(ctime,9,15)<br>
'draw string 0.5 7.7 'chour'='cc<br><br><br>'set t 27 '<br>'d t850-273.16'<br>cc=subwrd(result,4)<br>'q time'<br>ctime = subwrd(result,3)<br>chour = substr(ctime,9,15)<br>'draw string 0.5 7.7 'chour'='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"><<a href="mailto:ukm.yunus@gmail.com" target="_blank">ukm.yunus@gmail.com</a>></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>'sdfopen <a href="http://foo.nc" target="_blank">foo.nc</a>'<br>lonvalue=90<br>latvalue=0<br>levvalue=850<br>tvalue=1<br>'set lon 'lonvalue<br>'set lat 'latvalue<br>'set t 'tvalue<br>'set lev 'levvalue<br>
'd variable1'<br>catch=sublin(result,4)<br>'set gxout fwrite'
<br>'set fwrite point.dat'<br>'d 'catch<br>'disable fwrite'<br><br></div>This is a basic one, modify it as your need requires. I'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"><<a href="mailto:kojokroavi@gmail.com" target="_blank">kojokroavi@gmail.com</a>></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'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>'set t 1 '<br>'define varav=ave(t850-273.16,t=1,t=1,1)'<br>'d varav'<br>cc=subwrd(result,4)<br>'draw string 0.5 8 jan='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">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>-- <br>Tom Robinson<br>President - Graduate Student Organization <br>Graduate Student - Department of Meteorology<br>732-718-2323<br>
</div>