[gradsusr] variables in .gs scripts

Yi-Chih Huang dscpln at gmail.com
Mon Nov 14 21:58:43 EST 2011


Hello,

    I had read the documents about const and maskout online.  However,
probably my understanding about const and maskout is so shallow that I
can't use a combination of const and maskout to accomplish the function of
the if statement.  Thus, I posed the question.

    Thanks,

                   Yi-Chih


On Mon, Nov 14, 2011 at 9:41 PM, Yaqiang Wang <yaqiang.wang at gmail.com>wrote:

> You can find the usage of const and maskout from online help document.
> http://www.iges.org/grads/gadoc/gradfuncconst.html
> http://www.iges.org/grads/gadoc/gradfuncmaskout.html
>
> On Tue, Nov 15, 2011 at 10:28 AM, Yi-Chih Huang <dscpln at gmail.com> wrote:
> > Hello,
> >
> >     I work on regular grads.  I have searched online for the examples to
> use
> > const and maskout instead of if statement.  But I can't find any example.
> > Could anyone show me an example to use const and maskout instead of if
> > statement?
> >
> >     Thanks much for your help,
> >
> >                    Yi-Chih
> >
> >
> > On Mon, Nov 14, 2011 at 4:25 PM, Arlindo da Silva <dasilva at alum.mit.edu>
> > wrote:
> >>
> >> On Mon, Nov 14, 2011 at 3:40 PM, Yi-Chih Huang <dscpln at gmail.com>
> wrote:
> >>>
> >>> Hello,
> >>>
> >>>     I want to calculate variable 2 based on the value of some variable
> as
> >>> follows.
> >>>
> >>> When var1 = 100, then  var2 =  (calculation 1)
> >>> When var1 != 100, then  var2 = (calculation 2)
> >>>
> >>> I wrote a .gs script as follows.  But the condition rh=100 did not
> >>> effect.  Could anyone reveal what would be the right command in .gs
> script
> >>> to give the condition in which variables are in the .ctl file?
> >>>
> >>>
> >>>
> "malr=dalr*(1+2500000*q/287/tk)/(1+0.622*pow(2500000,2)*q/1004/287/tk/tk)"
> >>> "elr=-(tk(z+1)-tk(z-1))/(height(z+1)-height(z-1))"
> >>>
> >>> if (rh=100) then
> >>>    "mai=elr-malr"
> >>> else
> >>>    "mai=0"
> >>> endif
> >>
> >> GrADS expression parser and the scripting language do not share the same
> >> name space. Therefore you cannot have an if statement as above where you
> >> reference a gridded variable.  If you are using opengrads, the if()
> function
> >> could accomplish what you want:
> >> 'mai = if(rh,=,0,elr-malr,0)'
> >> For more information on if() see:
> >> if(EXPR1,OP,EXPR2,TRUE_EXPR,FALSE_EXPR)
> >> In regular grads, a combination of maskout()/const() functions can
> >> accomplish the same as the if() function above.
> >>    Arlindo
> >>
> >> --
> >> Arlindo da Silva
> >> dasilva at alum.mit.edu
> >>
> >> _______________________________________________
> >> 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
> >
> >
>
>
>
> --
> *************************************************
> Dr. Yaqiang Wang
> Chinese Academy of Meteorological Sciences (CAMS)
> 46, Zhong-Guan-Cun South Avenue
> Beijing, 100081
> China
>
> yaqiang.wang at gmail.com
>
> http://www.meteothinker.com
> **************************************************
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20111114/c79670f2/attachment-0003.html 


More information about the gradsusr mailing list