<div dir="ltr">Matt,<div><br></div><div>It also occurred to me that the reason you're not seeing a display for values of 1 may be how you have your color contours set up. For example, if you are using 'set gxout shaded' or 'set gxout grfill' be sure to include a color for a value between 0 and 1 since a value of 1 would be included in that range. A better option could be 'set gxout fgrid' along with 'set fgvals...'</div><div><br></div><div>Stephen Mc</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 23, 2016 at 11:51 AM, Baker, Matt (Quebec - Atlantic) <span dir="ltr"><<a href="mailto:matt.baker@amecfw.com" target="_blank">matt.baker@amecfw.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-CA" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Hi Stephen,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">I’m attempting your route with the if statements; however, I want to make sure I’m executing them correctly.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Here’s the new code with the Ifs.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> 'define NAMHail = if(NAMcape,>,1500,if(NAMcape,<,2200,<b>NAMHail+1</b>,NAMHail),NAMHail)'<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> 'define NAMHail = if(NAMcape,>,2199,if(NAMcape,<,3100,<b>NAMHail+3</b>,NAMHail),NAMHail)'<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> 'define NAMHail = if(NAMcape,>,3099,<b>NAMHail+4</b>,NAMHail)'<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">That code currently only displays values of 1 when the SBCAPE is greater than 2200. I’m wondering why the expression that’s bolded
doesn’t return that value to NAMHail even though its being defined.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Cheers,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Matt<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif"> <a href="mailto:gradsusr-bounces@gradsusr.org" target="_blank">gradsusr-bounces@gradsusr.org</a> [mailto:<a href="mailto:gradsusr-bounces@gradsusr.org" target="_blank">gradsusr-bounces@gradsusr.org</a>]
<b>On Behalf Of </b>Stephen McMillan<br>
<b>Sent:</b> June-22-16 2:09 PM</span></p><div><div class="h5"><br>
<b>To:</b> GrADS Users Forum <<a href="mailto:gradsusr@gradsusr.org" target="_blank">gradsusr@gradsusr.org</a>><br>
<b>Subject:</b> Re: [gradsusr] If Statements for Gridded Model Data Open GrADS<u></u><u></u></div></div><p></p><div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">Matt,<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">The "if" construct you are using will not work on a gridded field, and it appears that's what you are trying to do. The extension "if" function was designed to work on such fields.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Here's a partial example using the first set of conditions you provided:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">'define NAMHail=if(NAMcape,>,1500,if(NAMcape,<,2200,NAMHail+1,NAMHail),NAMHail)'<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">That's, of course, assuming you have defined a field called "NAMHail" as zero prior to executing the "if" function. Alternatively, you could have 0 or -u (for undefined) as your false expression, without first defining NAMHail. After
that, you could execute the "if" again by adding an additional set of conditions, until you have applied all conditions. Another option is to nest several conditions, but it gets a little complicated that way.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Stephen McMillan<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On Wed, Jun 22, 2016 at 12:11 PM, Baker, Matt (Quebec - Atlantic) <<a href="mailto:matt.baker@amecfw.com" target="_blank">matt.baker@amecfw.com</a>> wrote:<u></u><u></u></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt">
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Thanks Bernd and Stephen,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">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.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">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?</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">As an example, is this statement written correctly?</span><u></u><u></u></p>
<p class="MsoNormal">if (NAMcape > 1500 & NAMcape < 2200)<u></u><u></u></p>
<p class="MsoNormal"> 'NAMHail = NAMHail + 1'<u></u><u></u></p>
<p class="MsoNormal">endif<u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Again, NAMHail is defined by: ‘NAMHail = 0’ before the if the statements.
</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Thanks for the help!</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Matt
</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif">
</span><a href="mailto:gradsusr-bounces@gradsusr.org" target="_blank"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif">gradsusr-bounces@gradsusr.org</span></a><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif">
[mailto:</span><a href="mailto:gradsusr-bounces@gradsusr.org" target="_blank"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif">gradsusr-bounces@gradsusr.org</span></a><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif">]
<b>On Behalf Of </b>Stephen McMillan<br>
<b>Sent:</b> June-22-16 12:39 PM<br>
<b>To:</b> GrADS Users Forum <</span><a href="mailto:gradsusr@gradsusr.org" target="_blank"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif">gradsusr@gradsusr.org</span></a><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif">><br>
<b>Subject:</b> Re: [gradsusr] If Statements for Gridded Model Data Open GrADS</span><u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">Hi Matt,<u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">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:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><a href="http://opengrads.org/doc/udxt/libbjt/" target="_blank">http://opengrads.org/doc/udxt/libbjt/</a><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">The "if" function syntax:<u></u><u></u></p>
</div>
<div>
<h2><a name="m_153034743582396559_m_6480877319877440318_if_expr1_op_expr2_"><strong>if</strong>(<em>EXPR1,OP,EXPR2,TRUE_EXPR,FALSE_EXPR</em>)</a><u></u><u></u></h2>
<p>This function compares <em>EXPR1</em> and <em>EXPR2</em>, where 5 arguments are expected. if their relation is true,
<em>TRUE_EXP</em> is returned, otherwise expression <em>FALSE_EXPR</em> is returned.<u></u><u></u></p>
<p class="MsoNormal"><a name="m_153034743582396559_m_6480877319877440318_item_op"><em><b>OP</b></em></a>
<u></u><u></u></p>
<p style="margin-left:36.0pt">One of the following: ==, =, >, <, >=, <=, !=<u></u><u></u></p>
<p class="MsoNormal"><a name="m_153034743582396559_m_6480877319877440318_item_expr2_2c_true"><em><b>EXPR2, TRUE_EXPR, FALSE_EXPR</b></em></a>
<u></u><u></u></p>
<p style="margin-left:36.0pt">These can be a expression, constant or -u.<u></u><u></u></p>
<p style="margin-left:36.0pt"> <u></u><u></u></p>
<p style="margin-left:36.0pt">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.<u></u><u></u></p>
<p style="margin-left:36.0pt">Stephen McMillan<u></u><u></u></p>
</div>
</div>
</div>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<div>
<div>
<p class="MsoNormal">On Wed, Jun 22, 2016 at 9:24 AM, Baker, Matt (Quebec - Atlantic) <<a href="mailto:matt.baker@amecfw.com" target="_blank">matt.baker@amecfw.com</a>> wrote:<u></u><u></u></p>
</div>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt">
<div>
<div>
<div>
<div>
<p class="MsoNormal">Hi all,<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">I have a question regarding Open GrADS.<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">I’m trying to use
<i>if statements</i> 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.<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">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.<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"> if (modelNumberNAM>0)<u></u><u></u></p>
<p class="MsoNormal"> set_maps(_map,_hasNegativeNAM)<u></u><u></u></p>
<p class="MsoNormal"> 'set grads off'<u></u><u></u></p>
<p class="MsoNormal"> 'set grid off'<u></u><u></u></p>
<p class="MsoNormal"> 'set gxout contour'<u></u><u></u></p>
<p class="MsoNormal"> 'set ccolor 0'<u></u><u></u></p>
<p class="MsoNormal"> 'set clopts -1 1 0.15'<u></u><u></u></p>
<p class="MsoNormal"> 'set cint 1'<u></u><u></u></p>
<p class="MsoNormal"> 'set cthick 6'<u></u><u></u></p>
<p class="MsoNormal"> 'set clab on'<u></u><u></u></p>
<p class="MsoNormal"> 'set csmooth on'<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"> 'NAMcape = CAPEsfc.'modelNumberNAM<u></u><u></u></p>
<p class="MsoNormal"> if (NAMcape > 1500 & NAMcape < 2200)<u></u><u></u></p>
<p class="MsoNormal"> 'NAMHail = NAMHail + 1'<u></u><u></u></p>
<p class="MsoNormal"> endif<u></u><u></u></p>
<p class="MsoNormal"> if (NAMcape > 2199 & NAMcape < 3100)<u></u><u></u></p>
<p class="MsoNormal"> 'NAMHail = NAMHail + 2'<u></u><u></u></p>
<p class="MsoNormal"> endif<u></u><u></u></p>
<p class="MsoNormal"> if (NAMcape > 3099)<u></u><u></u></p>
<p class="MsoNormal"> 'NAMHail = NAMHail + 3'<u></u><u></u></p>
<p class="MsoNormal"> endif<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"> 'set lev 500'<u></u><u></u></p>
<p class="MsoNormal"> 'NAMrh500=RHprs.'modelNumberNAM<u></u><u></u></p>
<p class="MsoNormal"> if (NAMrh500 < 35)<u></u><u></u></p>
<p class="MsoNormal"> 'NAMHail = NAMHail + 3'<u></u><u></u></p>
<p class="MsoNormal"> endif<u></u><u></u></p>
<p class="MsoNormal"> if (NAMrh500 > 35 & NAMrh500 < 44)<u></u><u></u></p>
<p class="MsoNormal"> 'NAMHail = NAMHail + 1'<u></u><u></u></p>
<p class="MsoNormal"> endif<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"> endif<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"> 'set gxout contour'<u></u><u></u></p>
<p class="MsoNormal"> 'set ccolor 0'<u></u><u></u></p>
<p class="MsoNormal"> 'set clopts -1 1 0.15'<u></u><u></u></p>
<p class="MsoNormal"> 'set cint 200'<u></u><u></u></p>
<p class="MsoNormal"> 'set cthick 6'<u></u><u></u></p>
<p class="MsoNormal"> 'set clab on'<u></u><u></u></p>
<p class="MsoNormal"> 'set csmooth on'<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"> 'd NAMcape'<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">Thanks!<u></u><u></u></p>
<p class="MsoNormal" style="text-autospace:none">
<u></u><u></u></p>
<p class="MsoNormal" style="text-autospace:none">
<b><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#5f2167">Matt Baker</span></b><u></u><u></u></p>
<p class="MsoNormal" style="text-autospace:none">
<span style="font-size:8.0pt;font-family:"Arial",sans-serif;color:#5f2167">Meteorologist, Met-Ocean Services, Amec Foster Wheeler Environment & Infrastructure
</span><u></u><u></u></p>
<p class="MsoNormal" style="text-autospace:none">
<span style="font-size:8.0pt;font-family:"Arial",sans-serif;color:#5f2167">133 Crosbie Road, PO Box 13216, St. John’s, NL A1B 4A5, Canada</span><u></u><u></u></p>
<p class="MsoNormal" style="text-autospace:none">
<a href="mailto:matt.baker@amecfw.com" target="_blank"><span style="font-size:8.0pt;font-family:"Arial",sans-serif">matt.baker@amecfw.com</span></a><u><span style="font-size:8.0pt;font-family:"Arial",sans-serif;color:#5f2167"></span></u><span style="font-size:8.0pt;font-family:"Arial",sans-serif;color:#5f2167">
</span><a href="http://amecfw.com" target="_blank"><span style="font-size:8.0pt;font-family:"Arial",sans-serif">amecfw.com</span></a><u></u><u></u></p>
<p class="MsoNormal" style="text-autospace:none">
<span style="font-size:8.0pt;font-family:"Arial",sans-serif;color:#5f2167">ISO 9001:2008 Quality Management System (St. John's)</span><u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
</div>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="padding:0cm 0cm 0cm 0cm">
<p class="MsoNormal"><img border="0" width="115" height="118" src="cid:image001.jpg@01D1CD4C.07E5BC00" alt="cid:image001.jpg@01D1CC84.8BC9E9B0"><span><u></u><u></u></span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><br>
<span style="font-size:9.0pt;font-family:"Arial",sans-serif;color:#5f2167">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,
<b>please forward this email to: </b></span><a href="mailto:unsubscribe@amecfw.com" target="_blank"><b><span style="font-size:9.0pt;font-family:"Arial",sans-serif">unsubscribe@amecfw.com</span></b></a><b><span style="font-size:9.0pt;font-family:"Arial",sans-serif;color:#5f2167">
and include “Unsubscribe” in the subject line</span></b><span style="font-size:9.0pt;font-family:"Arial",sans-serif;color:#5f2167">. If applicable, you will continue to receive invoices, project communications and similar factual, non-commercial electronic
communications.<br>
<br>
Please click </span><a href="http://amecfw.com/email-disclaimer" target="_blank"><span style="font-size:9.0pt;font-family:"Arial",sans-serif">http://amecfw.com/email-disclaimer</span></a><span style="font-size:9.0pt;font-family:"Arial",sans-serif;color:#5f2167">
for notices and company information in relation to emails originating in the UK, Italy or France.</span><u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
_______________________________________________<br>
gradsusr mailing list<br>
<a href="mailto:gradsusr@gradsusr.org" target="_blank">gradsusr@gradsusr.org</a><br>
<a href="http://gradsusr.org/mailman/listinfo/gradsusr" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a><u></u><u></u></p>
</blockquote>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
_______________________________________________<br>
gradsusr mailing list<br>
<a href="mailto:gradsusr@gradsusr.org" target="_blank">gradsusr@gradsusr.org</a><br>
<a href="http://gradsusr.org/mailman/listinfo/gradsusr" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a><u></u><u></u></p>
</blockquote>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div></div></div>
</div>
<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" rel="noreferrer" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a><br>
<br></blockquote></div><br></div>