[gradsusr] Hello to all users of Grads

Thomas Robinson ter at hawaii.edu
Mon Apr 1 02:37:13 EDT 2013


Aloha Avi,

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:

'reinit'
'set display color white'
f = 'http://goldsmr2.sci.gsfc.nasa.gov:80/dods/MATMNXSLV<http://goldsmr2.sci.gsfc.nasa.gov/dods/MATMNXSLV>
'
'sdfopen 'f

** Set the start and end times (month number)
start_time=3
end_time=12*34

'set parea 0.7 10.5 0.6 8'
'set lat 32.5'
'set lon 35'

** Set the time to the start time
time=start_time
** Loop through the times
while (time <=end_time
**Set time
'set t ' time
'd t850-273.16'
cc=subwrd(result,4)
'q time'
ctime = subwrd(result,3)
chour = substr(ctime,9,15)
'draw string 0.5 8 'chour'='cc

** Set the time to the next year
time=time+12

endwhile


On Sun, Mar 31, 2013 at 8:26 PM, avi kojokro <kojokroavi at gmail.com> wrote:

>
> Thank you.
> I did not phrase the question correctly, I think that the example I gave is
> not good. I will try to explain myself again.
> First I must say that I am working with windows not Linux.
> I want to get data from a server that already gives me a monthly averages,
> here's a better example of what i means:
>
>
> 'reinit'
> 'set display color white'
> f = 'http://goldsmr2.sci.gsfc.nasa.gov:80/dods/MATMNXSLV'
> 'sdfopen 'f
>
>
>
> 'set parea 0.7 10.5 0.6 8'
> 'set lat 32.5'
> 'set lon 35'
>
> 'set t 3 '
> 'd t850-273.16'
> cc=subwrd(result,4)
> 'q time'
> ctime = subwrd(result,3)
> chour = substr(ctime,9,15)
> 'draw string 0.5 8 'chour'='cc
>
>
> 'set t 15 '
> 'd t850-273.16'
> cc=subwrd(result,4)
> 'q time'
> ctime = subwrd(result,3)
> chour = substr(ctime,9,15)
> 'draw string 0.5 7.7 'chour'='cc
>
>
> 'set t 27 '
> 'd t850-273.16'
> cc=subwrd(result,4)
> 'q time'
> ctime = subwrd(result,3)
> chour = substr(ctime,9,15)
> 'draw string 0.5 7.7 'chour'='cc
>
> How do I create a loop to do it automatically, the server provides data from
> 1979 to 2013, and I want to get only the data of March.
>
> I hope I have explained myself better.
> Regards
> avi.
>
>
>
> 2013/4/1 Muhammad Yunus Ahmad Mazuki <ukm.yunus at gmail.com>
>
>> The average function itself has what you needed. ave(var1,t=1,t=360,*12*),
>> this means it will average values from t=1,t=13,t=25 ... until
>> t=360.Example of point value extraction.
>>
>> 'sdfopen foo.nc'
>> lonvalue=90
>> latvalue=0
>> levvalue=850
>> tvalue=1
>> 'set lon 'lonvalue
>> 'set lat 'latvalue
>> 'set t 'tvalue
>> 'set lev 'levvalue
>> 'd variable1'
>> catch=sublin(result,4)
>> 'set gxout fwrite'
>> 'set fwrite point.dat'
>> 'd 'catch
>> 'disable fwrite'
>>
>> 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).
>>
>> Yunus.
>>
>>
>> On Sun, Mar 31, 2013 at 2:25 PM, avi kojokro <kojokroavi at gmail.com>wrote:
>>
>>> I'm trying to do a script of averages like this example :
>>>
>>>
>>> 'set t 1 '
>>> 'define varav=ave(t850-273.16,t=1,t=1,1)'
>>> 'd varav'
>>> cc=subwrd(result,4)
>>> 'draw string 0.5 8 jan='cc
>>>
>>> I want my script calculates every 12 months, how do I create a loop
>>> script that calculates every 12 month average of the same month.
>>> I will give an example of what I mean: I want to begin to calculate average
>>> of January 1979 and then later to calculate directly the January 1980 and
>>> so on.
>>> Is it possible that the result will write directly to the Excel file,
>>> then how to write the command to it.
>>>
>>> Please note that I first started Grads.
>>>
>>> Thank you so much.
>>>
>>> avi
>>>
>>>
>>>
>>> _______________________________________________
>>> gradsusr mailing list
>>> gradsusr at gradsusr.org
>>> http://gradsusr.org/mailman/listinfo/gradsusr
>>>
>>>
>>
>> _______________________________________________
>> gradsusr mailing list
>> gradsusr at gradsusr.org
>> http://gradsusr.org/mailman/listinfo/gradsusr
>>
>>
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
>


-- 
Tom Robinson
President - Graduate Student Organization
Graduate Student - Department of Meteorology
732-718-2323
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20130331/927f4ac7/attachment-0003.html 


More information about the gradsusr mailing list