[gradsusr] Setting color bar for animation

Goodson,Ron [Edm] Ron.Goodson at EC.gc.ca
Wed Mar 23 13:19:36 EDT 2011


Hi Clay
 
(I was typing when I saw Jeffrey's note .. so modified my answer but
...)
 
Its like he said - you don't need the "set rbrange" for what you want.
 
The only reason I use my make_clevs.gs script is because I often want to
programatically determine the clevs based upon "whatever" .. rather than
hard-code it.  And .. even if I was hardcoding - I don't like having to
type in a huge
number of entries.
 
I almost never use ccols because I define my own colours and do a 'set
rbcols' at the beginning so I have my own rainbow colours.
 
I do what Jeffrey has when I have clevs that are not equally spaced
(such as for precipitation amounts) and when the colours don't vary
smoothly (so I have to pick-and-choose discrete numbers from my defined
colours rather than letting GrADS default to the rainbow colours).
 
I've attached my "setup.gs" script which does the 'set rbcols'  and a
slightly fiddled version of the grads-script-library "colors.gs"
(fiddled only to give the colours I want).  I execute this script just
once .. before any other scripts that use my "standard" colour table.
If I want to change colour tables .. I have other files that assign the
rgb values and do the rbcols in a similar fashion (like when I need
grey-scale imagery).
 
For animation -- I have a couple of scripts that are similar to the
standard xanim.gs - but use widgets instead of the keyboard to control
the animation (eg .. step forward or back).  I can send you those if you
want .. but it might only confuse you more.
 
 
ron
 
________________________________

From: gradsusr-bounces at gradsusr.org
[mailto:gradsusr-bounces at gradsusr.org] On Behalf Of Clay Blankenship
Sent: March 23, 2011 9:43 AM
To: GrADS Users Forum
Subject: Re: [gradsusr] Setting color bar for animation


OK, from the command line I can use make_clevs to specify any range of
levels and plot and get the color bar.  But both of my scripts dd.gs (a
script to plot, specify a range, and make a color bar) and ani.gs
(animation) do not plot the full color bar when I specify the range with
script arguments.  I can't figure out what's going on... 

Also, I am still looking for a way to display the current ccols and
clevs.  Do you have to use 'q shades'?

One more thing, this animation script regulates its speed by redrawing
the plot a certain number of times; is there a better way to do that?

Thanks,
Clay

****dd.gs***********
function dd (args)
*Plot a variable and its color scale.
* dd variable [ -cmin minimum value ]
*             [ -cmax maximum value ]
*             [ -cint color scale ]

variable=subwrd(args,1)

ccint=''
ccmin=''
ccmax=''
string=''
space=' '
n=2

while(n<9)
idx=subwrd(args,n)
opt=subwrd(args,n+1)
if(idx='');break;endif
if(idx='-cint');ccint=opt;endif
if(idx='-cmin');ccmin=opt;endif
if(idx='-cmax');ccmax=opt;endif
if(idx='-string');string=opt;endif
n=n+2
endwhile

'c'
'set gxout shaded'
if(ccint!=''); 'set cint 'ccint;endif
if(ccmin!=''); 'set cmin 'ccmin;endif
if(ccmax!=''); 'set cmax 'ccmax;endif
if(ccmin!=''); if(ccmax!=''); 'set rbrange 'ccmin ' 'ccmax; endif;endif

*CBB 3/22/11 set the levels
'make_clevs ' cmin cmax cint
'd 'variable

*Add date and user-input string
'q time'
say result
cctime=subwrd(result,3)
coln=substr(cctime,3,1)
if coln = ':'
dmy   =substr(cctime,7,9)
else
dmy   =substr(cctime,1,12)
day   =substr(cctime,1,3)
my   =substr(cctime,4,9)

*dmy   =substr(cctime,4,9)  *cbb changed   
endif

* 'draw title 'dmy space string
 'draw title 'day space my space string

'q shades' 

'cbar2' 

****END***********

***ani.gs************

* Display animation 
*     ga> run ani variable [ -I slowness (default=10) ]
*                            [ -cint, -ci  contour interval ]
*                            [ -cmin, -mn  minimum contour level ]
*                            [ -cmax, -mx  maximum contour level ]
*   ex. ga> run ani t-t.2 -ci 0.1 -mn -0.5 -I 5 -cmax 0.3
*          >>>> plot (t-t.2) with slowness=5, contour_interval=0.1
*               minimum contour level=-0.5, maximum contour level=0.3
*
*                                                  Nov. 9, 1999 Masami
Nonaka
*
function ani (args)

variable=subwrd(args,1)

slow=''
ccint=''
ccmin=''
ccmax=''
cbar=''
n=2

while(n<10000)
idx=subwrd(args,n)
opt=subwrd(args,n+1)
if(idx='');break;endif
if(idx='-I');slow=opt;endif
if(idx='-Int');slow=opt;endif
if(idx='-cint');ccint=opt;endif
if(idx='-cmin');ccmin=opt;endif
if(idx='-cmax');ccmax=opt;endif
if(idx='-ci');ccint=opt;endif
if(idx='-mn');ccmin=opt;endif
if(idx='-mx');ccmax=opt;endif
n=n+2
endwhile

defaultslow=10
if(slow=''); slow=defaultslow;endif

'q dims'
 say result
aline=sublin(result,5)
cctime1=subwrd(aline,11)
cctime2=subwrd(aline,13)
tmin=substr(cctime1,1,9)
tmax=substr(cctime2,1,9)
it=tmin
'set dbuff on'
while (it <=tmax)
 'set t 'it
i=0
while (i <slow)
if(ccint!=''); 'set cint 'ccint;endif
if(ccmin!=''); 'set cmin 'ccmin;endif
if(ccmax!=''); 'set cmax 'ccmax;endif
if(ccmin!=''); if(ccmax!=''); 'set rbrange 'ccmin ' 'ccmax; endif;endif

*CBB 3/22/11 setting max min clevs
'make_clevs ' cmin cmax cint

 'display 'variable

 'run date.gs'



 'query shades'
shdinfo = result
if(subwrd(shdinfo,1)!='None');'run fcbar.gs';endif

'swap'
i=i+1
endwhile
 it=it+1
endwhile
 'set t ' tmin ' ' tmax


****END***********






On Mar 22, 2011, at 5:23 PM, Goodson,Ron [Edm] wrote:


	I see in my original note I mislead you .. when I said I do my
make_clevs.gs before cbar.  As was noted by Jeffrey . the settings of
clevs, ccols (all that stuff) must happen before the display of the
variable.  So swap those two lines of "display" and "make_clevs".
	 
	 
	 
	The other thing I usually do right at the start of my programs
(and only has to be done once .. unlike settings clevs, ccols which must
be done before each display)  is to setup some custom colours through
"set rgb" (one entrie per colour) and rbcols (to set the order of the
colours).   You don't need to do this if you are using the GrADS
standard scheme of 16 colours.
	 
	 
	ron

________________________________

	From: gradsusr-bounces at gradsusr.org [
mailto:gradsusr-bounces at gradsusr.org] On Behalf Of Clay Blankenship
	Sent: March 22, 2011 4:05 PM
	To: GrADS Users Forum
	Subject: Re: [gradsusr] Setting color bar for animation
	
	
	OK, that make_clevs works for me when I do a simple 'd' on my
variable, but when I try to use a little fancier script (not even an
animation, just trying to pass the range on the command line), I lose
the min and max values.   

	If I do:

	c
	make_clevs 0 2 0.2
	d soilwat5
	cbar

	I get a colorbar from 0 to 2 in steps of .2, even though the
variable range is 0 to 1 (so far, so good).

	If I do:
	 
	dd soilwat5 -cmin 0 -cmax 2 -cint 0.2

	I get a colorbar from 0 to 1 in steps of 0.2.  The colors are
the same for the different ranges, it just doesn't show the ones above
1.  Is this because clevs are set and ccols are not?  I was hoping ccols
would get set automatically like it does when you don't specify levels.

	This happens whether or not I use the make_clevs line in the
following script.

	BTW, this seems really basic, but I can't figure out how to see
the current values of ccols and clevs.
	cbar is getting its ccols and clevs from 'q shades', but it
doesn't  react to ccols and clevs until a plot has been made.

	Script follows.

	Thanks for the help,
	Clay




-- 
Clay Blankenship                 * USRA Research Scientist
clay.b.blankenship at nasa.gov      * 256-961-7638
320 Sparkman Drive               * Huntsville, AL 35805 USA
National Space Science and Technology Center at NASA-MSFC/UAH






-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20110323/abe89987/attachment-0003.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: setup.gs
Type: application/octet-stream
Size: 344 bytes
Desc: setup.gs
Url : http://gradsusr.org/pipermail/gradsusr/attachments/20110323/abe89987/attachment-0006.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: colors.gs
Type: application/octet-stream
Size: 4577 bytes
Desc: colors.gs
Url : http://gradsusr.org/pipermail/gradsusr/attachments/20110323/abe89987/attachment-0007.obj 


More information about the gradsusr mailing list