[gradsusr] Script errors

Jeffrey Duda jdduda at iastate.edu
Tue Jan 11 12:42:06 EST 2011


Darren,
The reason you are getting errors in your clevs statement is because you
have the variables to represent the levels placed inside the quotes.  Remove
them from the quotes so your statement looks like:

'set clevs 'clev1' 'clev2' 'clev3' '...' 'clevn

The way you have your definition of minval and your if statement won't work
unless you are running some version of Grads that allows that (opengrads or
something???).  Since you're defining minval and maxval within quotes, that
variable will exist within the Grads command window as a field variable (not
the same thing as a script variable). However, you can use the sublin and
subwrd commands to get the result of your definition statement to get minval
and maxval to be script variables.  Don't use quotes in your if statement.
I'm surprised the script didn't give you an error with that.  I would
suggest rewriting the the lines as:

if (minval < 0)
 minval = 0

and likewise for the maxval if statement.  Hope this works for you.

Jeff

On Tue, Jan 11, 2011 at 11:32 AM, Murphy, Darren W <dwmurphy at nps.edu> wrote:

>  Jeff,
>
> Changing the value from 0 to 0.0 didn’t change the results.
>
> I’ve updated the script with some changes in reference to Austin and your
> suggestions.  However, I still have the issue of entering the minval>0 if
> statement with a value <0, and an error for clevs.
>
> Thanks,
> Darren
>
>
> prompt 'Enter EOF #:'
> pull EF
>
> eofnum = EF
>
> 'clear'
> 'set poli on'
> 'set ccolor 0'
>
> 'open
> /Users/Darren/Desktop/output/MaxT_2x2x1dy_NormByMeanSTD_Afg_1979to2009_1to365_EOF_eof.ctl'
>
>
> 'q dims'
> res2 = sublin(result,2)
> res3 = sublin(result,3)
> lon1 = subwrd(res2,6)
> lon2 = subwrd(res2,8)
> lat1 = subwrd(res3,6)
> lat2 = subwrd(res3,8)
>
> 'set z 'eofnum
>
> 'maxval = max(max(eof,lon='lon1',lon='lon2'),lat='lat1',lat='lat2')'
> 'minval = min(min(eof,lon='lon1',lon='lon2'),lat='lat1',lat='lat2')'
>
>
> * These are the BLUE shades
> 'set rgb 16 0 0 255'
> 'set rgb 17 55 55 255'
> 'set rgb 18 110 110 255'
> 'set rgb 19 165 165 255'
> 'set rgb 20 220 220 255'
>
> * These are the RED shades
> 'set rgb 21 255 220 220'
> 'set rgb 22 255 165 165'
> 'set rgb 23 255 110 110'
> 'set rgb 24 255 55 55'
> 'set rgb 25 255 0 0'
>
> 'cval1 = minval/5*4'
> 'cval2 = minval/5*3'
> 'cval3 = minval/5*2'
> 'cval4 = minval/5*1'
>
> 'cval5 = maxval/5*1'
> 'cval6 = maxval/5*2'
> 'cval7 = maxval/5*3'
> 'cval8 = maxval/5*4'
>
>
> if ('minval' > 0.0)
> 'minval = 0.0'
> prompt 'minval greater than 0 '
> 'cval1 = maxval/10*1'
> 'cval2 = maxval/10*2'
> 'cval3 = maxval/10*3'
> 'cval4 = maxval/10*4'
> 'cval5 = maxval/10*5'
> 'cval6 = maxval/10*6'
> 'cval7 = maxval/10*7'
> 'cval8 = maxval/10*8'
>
> endif
>
> if ('maxval' < 0.0)
> prompt 'maxval less than 0 '
> 'maxval = 0.0'
> 'cval1 = minval/10*8'
> 'cval2 = minval/10*7'
> 'cval3 = minval/10*6'
> 'cval4 = minval/10*5'
> 'cval5 = minval/10*4'
> 'cval6 = minval/10*3'
> 'cval7 = minval/10*2'
> 'cval8 = minval/10*1'
>
> endif
>
> 'set gxout shaded'
> 'set clevs minval cval1 cval2 cval3 cval4 cval5 cval6 cval7 cval8 maxval'
> 'set ccols 16 17 18 19 20 1 21 22 23 24 25'
>
> 'set mpt * off'
> 'set mpdset hires'
> 'set mpt 0 0 1 7'
> 'set mpt 1 0 1 7'
> 'draw map'
>
> 'set background 1'
> 'set annot 0 5'
> 'd eof(z='eofnum')'
>
> 'run /Users/Darren/Desktop/cbarm.gs'
>
> 'close 1'
>
>
> On 1/10/11 9:48 AM, "Jeffrey Duda" <jdduda at iastate.edu> wrote:
>
> Darren,
> Did you try putting in 0.0 instead of just 0?  Perhaps there is a
> difference in how Grads is reading the precision of that number and in how
> your system is.
>
> Jeff
>
> On Mon, Jan 10, 2011 at 10:38 AM, Murphy, Darren W <dwmurphy at nps.edu>
> wrote:
>
> Austin,
>
> Thanks for checking out the script.  I had been doing some testing of the
> script and changing the logic to check to see if it was by default entering
> the statement.  I forgot to change it back.  Those lines should read...
>
>
> >> if (minval > 0)
> >> prompt 'minval greater than 0'
>
> The problem persists though.  With minval of -0.52 it still enters the
> minval>0 statement.
>
> Thanks,
> Darren
>
> On 1/10/11 7:57 AM, "Austin Conaty" <Austin.L.Conaty at nasa.gov> wrote:
>
> > Darren,
> >
> > if (minval <= 0)
> > prompt 'minval greater than 0'
> >
> > I think this is where you have a logic problem
> >
> > If minval less than or equal to zero
> > prompt minval greater than zero
> >
> > Is this really what you mean to do?
> >
> > Murphy, Darren W wrote:
> >> All,
> >>
> >> I’m using Grads 2.0.a9.
> >>
> >> The script below throws a couple of errors.  Earlier I thought it was an
> >> string
> >> not compatible with numeric calculations.  Following Jeff Duda’s (Thank
> you
> >> Jeff) advice I found some errors in the script syntax.  I can verify
> that the
> >> script is accepting the user input, and that that the “maxval” and
> “minval”
> >> values are correct.
> >>
> >> The first issue is the if statements.  I have a value of minval being
> -.52
> >> and
> >> still entering the if statement for minval greater than 0.
> >>
> >> Second I am getting an error “SET error:  Missing or invalid arguments
> for
> >> CLEVS
> >> option”.  I can also verify that the cvals1 through cval8 are being
> >> calculated,
> >> but perhaps I have a syntax error on that line?
> >>
> >> Thank you,
> >> Darren
> >>
> >>
> >>
> >> prompt 'Enter EOF #: '
> >> pull EF
> >>
> >> eofnum = EF
> >>
> >> 'clear'
> >> 'set poli on'
> >> 'set ccolor 0'
> >>
> >> 'open
> >>
> /Users/Darren/Desktop/output/MaxT_2x2x1dy_NormByMeanSTD_Afg_1979to2009_1to365
> >> _EOF_eof.ctl'
> >>
> >> 'q dims'
> >> res2 = sublin(result,2)
> >> res3 = sublin(result,3)
> >> lon1 = subwrd(res2,6)
> >> lon2 = subwrd(res2,8)
> >> lat1 = subwrd(res3,6)
> >> lat2 = subwrd(res3,8)
> >>
> >> 'set z 'eofnum
> >>
> >> 'maxval = max(max(eof,lon='lon1',lon='lon2'),lat='lat1',lat='lat2')'
> >> 'minval = min(min(eof,lon='lon1',lon='lon2'),lat='lat1',lat='lat2')'
> >>
> >> * BLUE shades
> >> 'set rgb 16 0 0 255'
> >> 'set rgb 17 55 55 255'
> >> 'set rgb 18 110 110 255'
> >> 'set rgb 19 165 165 255'
> >> 'set rgb 20 220 220 255'
> >>
> >> * RED shades
> >> 'set rgb 21 255 220 220'
> >> 'set rgb 22 255 165 165'
> >> 'set rgb 23 255 110 110'
> >> 'set rgb 24 255 55 55'
> >> 'set rgb 25 255 0 0'
> >>
> >> 'cval1 = 'minval'/5*4'
> >> 'cval2 = 'minval'/5*3'
> >> 'cval3 = 'minval'/5*2'
> >> 'cval4 = 'minval'/5*1'
> >>
> >> 'cval5 = 'maxval'/5*1'
> >> 'cval6 = 'maxval'/5*2'
> >> 'cval7 = 'maxval'/5*3'
> >> 'cval8 = 'maxval'/5*4'
> >>
> >> if (minval <= 0)
> >> prompt 'minval greater than 0'
> >> 'minval = 0'
> >> 'cval1 = 'maxval'/10*1'
> >> 'cval2 = 'maxval'/10*2'
> >> 'cval3 = 'maxval'/10*3'
> >> 'cval4 = 'maxval'/10*4'
> >> 'cval5 = 'maxval'/10*5'
> >> 'cval6 = 'maxval'/10*6'
> >> 'cval7 = 'maxval'/10*7'
> >> 'cval8 = 'maxval'/10*8'
> >>
> >> endif
> >>
> >> if (maxval < 0)
> >> prompt 'maxval less than 0 '
> >> 'maxval = 0'
> >> 'cval1 = 'minval'/10*8'
> >> 'cval2 = 'minval'/10*7'
> >> 'cval3 = 'minval'/10*6'
> >> 'cval4 = 'minval'/10*5'
> >> 'cval5 = 'minval'/10*4'
> >> 'cval6 = 'minval'/10*3'
> >> 'cval7 = 'minval'/10*2'
> >> 'cval8 = 'minval'/10*1'
> >>
> >> endif
> >>
> >> 'set gxout shaded'
> >> 'set clevs minval cval1 cval2 cval3 cval4 cval5 cval6 cval7 cval8
> maxval'
> >> 'set ccols 16 17 18 19 20 1 21 22 23 24 25'
> >>
> >> 'set mpt * off'
> >> 'set mpdset hires'
> >> 'set mpt 0 0 1 7'
> >> 'set mpt 1 0 1 7'
> >> 'draw map'
> >>
> >> 'set background 1'
> >> 'set annot 0 5'
> >> 'd eof(z='eofnum')'
> >>
> >> 'run /Users/Darren/Desktop/cbarm.gs <http://cbarm.gs> '
> >>
> >>
> >> 'close 1'
> >>
> >
>
>
> _______________________________________________
> 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
>
>


-- 
Jeff Duda
Iowa State University
Meteorology Graduate Student
3134 Agronomy Hall
www.meteor.iastate.edu/~jdduda
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20110111/698b9fd0/attachment-0003.html 


More information about the gradsusr mailing list