[gradsusr] time mean zonal mean meridional wind for 12 vertical levels

Ricardo Hallak hallak at model.iag.usp.br
Fri Mar 26 10:02:47 EDT 2010


Hi Teddy,

when you define a new variable inside a while structure, the new variable is
rewritten at each interaction, and the previous define setting (the previous
level in your case) is deleted to save machine memory. As a result, your new
variable is "known" only for the level 12 (the last interaction inside the
while structure).

Use 'set z 1 12' before the define commands if you need a new variable be
available for all levels (of course, omit the while structure). The define
function will automatically set the new variable for all "open" dimensions at
the moment of definitions (as an example, the new variable could also  be set
for 'set lat initlat endlat'; set lon initlon endlon'; and so on). So, just use:

'set z 1 12'
'define timeaveV = ave(v, t=1, t=120)'
'define zonalAVGV = ave(timeaveV, lon=0, lon=360)'

After that, you can set z for a specific level and display the new var.

Hope this helps,
Ricardo 

On Thu, 25 Mar 2010 22:43:51 -0700 (PDT), Teddy Allen wrote
> Dear GrADS users,
> I am relatively new to writing GrADS loops and wanted to know if 
> anybody could provide pointers to my simple script below:
> 
> * create zonal time average for meridional wind
> iz = 1
> while (iz<13)
> 'set z ' iz
> 'define timeaveV = ave(v, t=1, t=120)'
> 'define zonalAVGV = ave(timeaveV, lon=0, lon=360)'
> iz = iz+1
> endwhile
>  
> Basically, I have a monthly mean meridional wind file with 10 years 
> of monthly data (12 months x 10 years = 120 time steps) for 12 
> vertical levels. I would like to calculate the time mean zonal mean 
> value for each of the 12 vertical levels. For some reason when I 
> execute this script I get the same line plot for each level. I was 
> hoping to get 12 unique line plots or curves for zonalAVGV, one for 
> each vertical level. Does anybody notice the error in the script 
> that prevents this? If it matters, I am using GrADS version 2.0.a7 
> on a windows XP system.   Sincerely, teddy allen   http://www.teddyallen.com
> "To move quickly, go alone. To move far, go together." 
> African Proverb




More information about the gradsusr mailing list