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