[gradsusr] Help with averages - all undefined values

Sujata Mandke amin at tropmet.res.in
Thu Dec 2 01:38:54 EST 2021


Dear Jason,

  The error may be resulting from
calculation of anomaly in 'while
loop'. I am not sure.

However, you can try following
grads script. This script will create
binary grads output file "(hgt.monclim.bin)" 
containing monthly mean hgt anomalies for
(756 time steps) for the period 1948-2010.

You have to create corresponding grads control
(.ctl) file for created hgt anomalies for the
period (1948-2010) and then you can plot
in Grads for the time period you require (1981-2010).
--------------
'reinit'
'clear'
'sdfopen C:\OpenGrADS-2.2\data\hgt.mon.mean.nc'
'q file'
say result
say 'write variable name'
pull var1
say 'write xsize'
pull xl
say 'write ysize'
pull yl
say 'write starting year of data'
pull year_start
say 'write ending year of data'
pull year_end

'set fwrite hgt.monclim.bin' 
'set gxout fwrite'
'set x 1 'xl
'set y 1 'yl
i_start=1
i_end=12
t_inc=12
im=i_start
while (im <= i_end)
say im
'set t 1'
 nnmt=im
'define a='var1'(t='nnmt')'
 j=year_start
 while (j <year_end)  
  j=j+1
  nnmt=nnmt+t_inc
'define a=a+('var1'(t='nnmt'))' 
 endwhile
'define a=a/('year_end'-'year_start'+1)'
'd a' 
 im=im+1 
endwhile
'disable fwrite'
**********************

Hope this Grads script works.
Let me know, if there is
problem in using the above script.
With best regards
Dr. Sujata Mandke,
Scientist, IITM, Pune-8

----- Original Message -----
From: "jason" <jason at solargrafix.com>
To: "gradsusr" <gradsusr at gradsusr.org>
Sent: Wednesday, December 1, 2021 11:54:27 PM
Subject: Re: [gradsusr] Help with averages - all undefined values

Hello,

I edited my code as you suggested, and now I get an error that says 
"Cannot contour grid - all undefined values".  Here is the code I am 
using...

'sdfopen C:\OpenGrADS-2.2\data\hgt.mon.mean.nc'
'set t 1 12'
'define hgtclim = ave(hgt, t+0, t=756, 12)'
'modify hgtclim seasonal'
'set t 397 756'

count = 397
while (count <= 756)

'set t 'count

'set gxout shaded'
'set csmooth on'
'set grads off'
'cgpa -150 150 2  -gxout shaded -kind 
g11->g10->g9->g8->g7->g6->g5->g4->g3->g2->g1'
'define anom = hgt - hgtclim'
'd anom'

fmt='%02.0f'
cc=math_format(fmt,count)

'gxprint C:\models\TEST\GPA-'cc'.png x1024 y768'

count = count + 1
'c'
endwhile




On 12/1/2021 12:00 PM, gradsusr-request at gradsusr.org wrote:
> Send gradsusr mailing list submissions to
> 	gradsusr at gradsusr.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> 	http://gradsusr.org/mailman/listinfo/gradsusr
> or, via email, send a message with subject or body 'help' to
> 	gradsusr-request at gradsusr.org
>
> You can reach the person managing the list at
> 	gradsusr-owner at gradsusr.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of gradsusr digest..."
>
>
> Today's Topics:
>
>     1. Re: Help with average (Sujata Mandke)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 1 Dec 2021 16:53:00 +0530 (IST)
> From: Sujata Mandke <amin at tropmet.res.in>
> To: gradsusr <gradsusr at gradsusr.org>
> Cc: jason at solargrafix.com
> Subject: Re: [gradsusr] Help with average
> Message-ID:
> 	<95880721.1298614.1638357780213.JavaMail.zimbra at tropmet.res.in>
> Content-Type: text/plain; charset=utf-8
>
> Hello Jason,
>
>    It appears from your grads script that
> you have a 63-year (1948-2010)time series
> of monthly mean height data(a variable
> named hgt with 756 time steps)and you
> want to create a climatology and then
> look at the monthly anomalies for
> the period 1981-20210.
>
>
> If this is your requirement, then you do not
> need two input files. Your error is due to the
> differences in dimension of the two files.
>
> You can easily get monthly mean height anomalies
> for 1981-2010 using only one input data file
> as follows:
>
> 'sdfopen C:\OpenGrADS-2.2\data\hgt.mon.mean.nc'
> 'set t 1 12'
> 'define hgtclim = ave(hgt, t+0, t=756, 12)'
> 'modify hgtclim seasonal'
> 'set t 397 756'
> 'define anom = hgt - hgtclim'
>
> Alternatively, you can first calculate
> climatology using the steps given above
> and then  use counter for estimating anomalies:
>
>
> count = 397
> while (count <= 756)
>
> 'set t 'count
>
> 'define anom = hgt - hgtclim'
>
> fmt='%02.0f'
> cc=math_format(fmt,count)
>
> 'gxprint C:\models\TEST\GPA-'cc'.png x1024 y768'
>
> count = count + 1
> 'c'
> endwhile
> ---------------
> You may be getting error due
> to time set as t=757 in ave command
> instead of t=756. As time=757 does not exist
> in your input height data file.
>
> Hopefully, the above solution helps.
> Please let me know if the problem
> persist even after using these steps.
>
> With best regards
> Dr. Sujata Mandke> Please let me know if the problem
> persist even after using these steps.
> Scientist,IITM, Pune-8
>
> -------------
>
>
> ----- Original Message -----
> From: "Jason M. Warren" <jason at solargrafix.com>
> To: "gradsusr" <gradsusr at gradsusr.org>
> Sent: Tuesday, November 30, 2021 10:13:44 AM
> Subject: [gradsusr] Help with average
>
> Hello,
>
> I have a file with monthly height data dating back to 1948.? I would
> like to create monthly averages of the data from 1981 to 2010 to create
> anomaly maps.
>
> I have been trying to create a script that will create the averages
> using ave.? Then subtract data from another height map I have to display
> the height anomalies. Here is what I have...
>
> 'clear'
> 'set datawarn off'
>
> 'sdfopen C:\OpenGrADS-2.2\data\hgt.mon.mean.nc'
>
> 'sdfopen C:\OpenGrADS-2.2\data\GFSGPA.nc'
>
> 'set dfile 1'
> 'define hgt = hgt'
>
> 'set dfile 2'
> 'set t 1 80'
> 'define gpa = gpa'
>
> count = 1
> while (count <= 80)
>
> 'set t 'count
>
> 'define ave(hgt,t=397,t=757,12)'
> 'modify hgt seasonal'
>
> 'd hgt-gpa'
>
> fmt='%02.0f'
> cc=math_format(fmt,count)
>
> 'gxprint C:\models\TEST\GPA-'cc'.png x1024 y768'
>
> count = count + 1
> 'c'
> endwhile
>
>
> What I get when I run this script is the following...
>
> Error in gagchk: axis sizes are not the same
> Operation error:? Incompatable grids
>   ? Error ocurred at column 11
> DISPLAY error:? Invalid expression
>   ? Expression = gpa-height
> Error in xcbar.gs: No shading information
> DEFINE error: Failed to find '=' after parsing the defined variable name
>   ????????????? The name may be too long or contain non-alphanumeric
> characters
> Defined variable is now climatological
>
> I am very confused, and I would appreciate any help.
>
> Thanks,
>
> Jason Warren
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
>
> ------------------------------
>
> End of gradsusr Digest, Vol 141, Issue 1
> ****************************************
_______________________________________________
gradsusr mailing list
gradsusr at gradsusr.org
http://gradsusr.org/mailman/listinfo/gradsusr



More information about the gradsusr mailing list