[gradsusr] Average in two different time and locations

Ricardo Hallak hallak at model.iag.usp.br
Tue Feb 5 16:19:52 EST 2013


Dear Theresa,

try this piece of script below:

 'reinit'
 'open E:\test.ctl'
 'set t 5'
 'set lat 7'
 'set lon 107'
* 'define r1= sst'  !NOT NECESSARY, since you have already set a single point.
 'd sst'
r1=subwrd(result,4)
say r1
'close 1'
 'sdfopen sst.nc' 
 'set t 5'
 'set lat 7'
 'set lon 107'
 *'define r2= sst' !NOT NECESSARY 
'd sst'
 r2=subwrd(result,4)
say r2

'define aver= ('r1'+'r2')/2'
 
'd aver'
 Ar=subwrd(result,4)
 say Ar
  
NOTE that, now, r1 and r2 are "script variables" (not "grads prompt variables"), since they were "captured" with "subwrd", and not with "define". So, r1 and r2 have to appear between quotes in the Ar definition. Note also that you can not use this kind of construction in the grads prompt terminal:

'd sst'
 r2=subwrd(result,4)

So, script variables CAN NOT be directly displayed in the grads graphic window: they exist only in the script memory.

On the other hand, DEFINED variables exist in the "GrADS prompt memory" and in the "script memory". These defined variables can be directly displayed in the grads graphic window. Of course, to make computations with defined variables, you don't need to put quotes in the variables. Is it clear enough?
 
Please, let me know if this doesn't work as you expect.

Regards,
Ricardo

On Tue, 5 Feb 2013 18:10:01 +0000, T. haghroosta wrote
> Dear Ricardo,
>  
> The script that you helped me to write, was run correctly. Now I would like to calculate the average of one parameter in two different files. I wrote this script, but it doesn't show me any outputs. Could you please tell me what is the problem?
>  
> 'reinit'
> 'open E:\test.ctl'
> 'set t 5'
> 'set lat 7'
> 'set lon 107'
> 'define r1= sst'
> 'close 1'
> 'sdfopen sst.nc'
> 'set t 5'
> 'set lat 7'
> 'set lon 107'
> 'define r2= sst'
> 'define aver= (r1+r2)/2'
> 'd aver'
> Ar=subwrd(result,4)
> say Ar
> 
> Regards,
>  
> T. 
> 
> > 
> > 
> > Today's Topics:
> > 
> > 1. Re: Average in two different time and locations (T. haghroosta)
> > 
> > 
> > ----------------------------------------------------------------------
> >

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20130205/07eacbaa/attachment-0003.html 


More information about the gradsusr mailing list