[gradsusr] If Statements for Gridded Model Data Open GrADS

Frank Colby Frank_Colby at uml.edu
Wed Jun 22 12:33:40 EDT 2016


Matt,

I don't think you can use the compound test in one if statement. That 
is, you can do

if(NAMcape > 1500)
    if(NAMcape < 2200)
       NAMHail = NAMHail + 1
    endif
end if

which should do what you want.

Frank
On 6/22/2016 12:11 PM, Baker, Matt (Quebec - Atlantic) wrote:
>
> Thanks Bernd and Stephen,
>
> Essentially if the CAPE, LI, and 500 mb relative humidity are within a 
> certain range, I want to add to NAMHail variable (NAMHail = NAMHail + 
> 1) and then display the variable with contour lines.
>
> Stephen, in my code there are already if statements for this. Is there 
> something wrong with my syntax and could that be the reason GrADS 
> isn’t executing in the if statement?
>
> As an example, is this statement written correctly?
>
> if (NAMcape > 1500 & NAMcape < 2200)
>
> 'NAMHail = NAMHail + 1'
>
> endif
>
> Again, NAMHail is defined by:  ‘NAMHail = 0’ before the if the 
> statements.
>
> Thanks for the help!
>
> Matt
>
> *From:*gradsusr-bounces at gradsusr.org 
> [mailto:gradsusr-bounces at gradsusr.org] *On Behalf Of *Stephen McMillan
> *Sent:* June-22-16 12:39 PM
> *To:* GrADS Users Forum <gradsusr at gradsusr.org>
> *Subject:* Re: [gradsusr] If Statements for Gridded Model Data Open GrADS
>
> Hi Matt,
>
> In addition to Bernd's suggestion, also check out the "if" function, 
> which should have come with your opengrads package as part of the 
> following extension function set:
>
> http://opengrads.org/doc/udxt/libbjt/ 
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__opengrads.org_doc_udxt_libbjt_&d=CwMGaQ&c=lqHimbpwJeF7VTDNof4ddl8H-RbXeAdbMI2MFE1TXqA&r=6tSfNfW9eok2dvPp1qvMgNtd3pXLhNg0FMEbTXyDrbI&m=R2wE3ABOgZSkEecrNzXKCrGNBI-1ggl2FOBCoFl-0IU&s=-e8J0y0k4721djnHE87Jw9gSRHvi54JAu7Y5nLvuuxs&e=>
>
> The "if" function syntax:
>
>
>     *if*(/EXPR1,OP,EXPR2,TRUE_EXPR,FALSE_EXPR/)
>
> This function compares /EXPR1/ and /EXPR2/, where 5 arguments are 
> expected. if their relation is true, /TRUE_EXP/ is returned, otherwise 
> expression /FALSE_EXPR/ is returned.
>
> /*OP*/
>
> One of the following: ==, =, >, <, >=, <=, !=
>
> /*EXPR2, TRUE_EXPR, FALSE_EXPR*/
>
> These can be a expression, constant or -u.
>
> I have found this function to be very useful and much easier to handle 
> than using maskout and const, although there are probably cases where 
> the latter is more appropriate or advisable.
>
> Stephen McMillan
>
> On Wed, Jun 22, 2016 at 9:24 AM, Baker, Matt (Quebec - Atlantic) 
> <matt.baker at amecfw.com <mailto:matt.baker at amecfw.com>> wrote:
>
>     Hi all,
>
>     I have a question regarding Open GrADS.
>
>     I’m trying to use /if statements/ for scalar model data (eg. GFS
>     and NAM) over a grid and I’m wondering if it’s possible to do
>     this. As an example, I’m using if statements for these parameters:
>     surface based CAPE, LI, and 500 mb relative humidity to create an
>     index to plot on a map. So far GrADS isn’t showing that this is
>     working, however, I can plot the model data individually so I
>     don’t think it’s a case of missing data.
>
>     Here’s some of the code for the NAM model. Note that I define the
>     variable NAMHail to equal 0 at the start of the function.
>
>     if (modelNumberNAM>0)
>
>     set_maps(_map,_hasNegativeNAM)
>
>     'set grads off'
>
>     'set grid off'
>
>     'set gxout contour'
>
>     'set ccolor 0'
>
>     'set clopts -1 1 0.15'
>
>     'set cint 1'
>
>     'set cthick 6'
>
>     'set clab on'
>
>     'set csmooth on'
>
>     'NAMcape = CAPEsfc.'modelNumberNAM
>
>     if (NAMcape > 1500 & NAMcape < 2200)
>
>     'NAMHail = NAMHail + 1'
>
>     endif
>
>     if (NAMcape > 2199 & NAMcape < 3100)
>
>     'NAMHail = NAMHail + 2'
>
>     endif
>
>     if (NAMcape > 3099)
>
>     'NAMHail = NAMHail + 3'
>
>     endif
>
>     'set lev 500'
>
>     'NAMrh500=RHprs.'modelNumberNAM
>
>     if (NAMrh500 < 35)
>
>     'NAMHail = NAMHail + 3'
>
>     endif
>
>     if (NAMrh500 > 35 & NAMrh500 < 44)
>
>     'NAMHail = NAMHail + 1'
>
>         endif
>
>     endif
>
>     'set gxout contour'
>
>     'set ccolor 0'
>
>     'set clopts -1 1 0.15'
>
>     'set cint 200'
>
>     'set cthick 6'
>
>     'set clab on'
>
>     'set csmooth on'
>
>     'd NAMcape'
>
>     Thanks!
>
>     *Matt Baker*
>
>     Meteorologist, Met-Ocean Services, Amec Foster Wheeler Environment
>     & Infrastructure
>
>     133 Crosbie Road, PO Box 13216, St. John’s, NL A1B 4A5, Canada
>
>     matt.baker at amecfw.com <mailto:matt.baker at amecfw.com>_­­_amecfw.com
>     <https://urldefense.proofpoint.com/v2/url?u=http-3A__amecfw.com&d=CwMGaQ&c=lqHimbpwJeF7VTDNof4ddl8H-RbXeAdbMI2MFE1TXqA&r=6tSfNfW9eok2dvPp1qvMgNtd3pXLhNg0FMEbTXyDrbI&m=R2wE3ABOgZSkEecrNzXKCrGNBI-1ggl2FOBCoFl-0IU&s=g_JqNnrO9dR8ueeiY-RNw3_0y2jRcgluurn82daZx8c&e=>
>
>     ISO 9001:2008 Quality Management System (St. John's)
>
>     mailbox:///C:/Users/DrC/AppData/Roaming/Thunderbird/Profiles/5n6c2dk1.default/Mail/exchange.uml.edu/Inbox?number=1006&header=quotebody&part=1.1.2&filename=image001.jpg
>
>
>     This message is the property of Amec Foster Wheeler plc and/or its
>     subsidiaries and/or affiliates and is intended only for the named
>     recipient(s). Its contents (including any attachments) may be
>     confidential, legally privileged or otherwise protected from
>     disclosure by law. Unauthorised use, copying, distribution or
>     disclosure of any of it may be unlawful and is strictly
>     prohibited. We assume no responsibility to persons other than the
>     intended named recipient(s) and do not accept liability for any
>     errors or omissions which are a result of email transmission. If
>     you have received this message in error, please notify us
>     immediately by reply email to the sender and confirm that the
>     original message and any attachments and copies have been
>     destroyed and deleted from your system. This disclaimer applies to
>     any and all messages originating from us and set out above. If you
>     do not wish to receive future unsolicited commercial electronic
>     messages from us, *please forward this email to:
>     unsubscribe at amecfw.com and include “Unsubscribe” in the subject
>     line*. If applicable, you will continue to receive invoices,
>     project communications and similar factual, non-commercial
>     electronic communications.
>
>     Please click http://amecfw.com/email-disclaimer
>     <https://urldefense.proofpoint.com/v2/url?u=http-3A__amecfw.com_email-2Ddisclaimer&d=CwMGaQ&c=lqHimbpwJeF7VTDNof4ddl8H-RbXeAdbMI2MFE1TXqA&r=6tSfNfW9eok2dvPp1qvMgNtd3pXLhNg0FMEbTXyDrbI&m=R2wE3ABOgZSkEecrNzXKCrGNBI-1ggl2FOBCoFl-0IU&s=uAlfLNcBnALNJGYROOWnLyP3IY8OBTWGOLBOLp3g2jE&e=>for
>     notices and company information in relation to emails originating
>     in the UK, Italy or France.
>
>
>     _______________________________________________
>     gradsusr mailing list
>     gradsusr at gradsusr.org <mailto:gradsusr at gradsusr.org>
>     http://gradsusr.org/mailman/listinfo/gradsusr
>     <https://urldefense.proofpoint.com/v2/url?u=http-3A__gradsusr.org_mailman_listinfo_gradsusr&d=CwMGaQ&c=lqHimbpwJeF7VTDNof4ddl8H-RbXeAdbMI2MFE1TXqA&r=6tSfNfW9eok2dvPp1qvMgNtd3pXLhNg0FMEbTXyDrbI&m=R2wE3ABOgZSkEecrNzXKCrGNBI-1ggl2FOBCoFl-0IU&s=XfUh0zvoWAask7j5PAYPU4hpN_7PiDP36pzFnqdtRSQ&e=>
>
>
>
> _______________________________________________
> 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/20160622/399d7820/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 5711 bytes
Desc: not available
Url : http://gradsusr.org/pipermail/gradsusr/attachments/20160622/399d7820/attachment-0001.jpe 


More information about the gradsusr mailing list