[gradsusr] If Statements for Gridded Model Data Open GrADS
Stephen McMillan
smcmillan at planalytics.com
Thu Jun 23 16:47:50 EDT 2016
Matt,
There are several issues. First of all, replace the commas in clevs and
ccols with spaces, e.g., 'set clevs 1 2 3 ...'
Your line for defining NAMHail does not define a gridded field, only a
non-grid variable . You could use my previous suggestion, or you could do
something like this:
'define NAMHail=const(capesfc,0,-a)' i.e., take a variable--any
available variable--and replace all values with zero
Now, with NAMHail defined everywhere as zero, your code should work as I
think you want it to.
Good luck--
Stephen
On Thu, Jun 23, 2016 at 2:49 PM, Baker, Matt (Quebec - Atlantic) <
matt.baker at amecfw.com> wrote:
> Stephen,
>
>
>
> Here’s the code in its entirety:
>
>
>
> 'set grads off'
>
> 'set grid off'
>
>
>
> 'set gxout shaded'
>
> 'set clevs 1,2,3,4,5,6,7,8,9'
>
> 'set ccols 1,9,14,4,11,5,13,3,10,7'
>
> 'set csmooth on'
>
>
>
> 'define NAMHail = 0'
>
> 'NAMcape = CAPEsfc.'modelNumberNAM
>
> 'define NAMHail =
> if(NAMcape,>,1500,if(NAMcape,<,2200,1,NAMHail),NAMHail)'
>
> 'define NAMHail =
> if(NAMcape,>,2199,if(NAMcape,<,3100,3,NAMHail),NAMHail)'
>
> 'define NAMHail = if(NAMcape,>,3099,4,NAMHail)'
>
> 'd NAMHail'
>
>
>
> I’m getting grey and it’s a color that’s not even defined in the color
> pallet. When I just display NAMHail as 0 with none of the if statements
> being used, nothing is displayed.
>
>
>
> You’re right, NAMcape and SBCAPE are the same. I’m essentially trying to
> see how a hail parameter would work given some ingredients (Surface Based
> CAPE being one of those) and plotting it in GrADS.
>
>
>
> Cheers,
>
>
>
> Matt
>
>
>
> *From:* gradsusr-bounces at gradsusr.org [mailto:
> gradsusr-bounces at gradsusr.org] *On Behalf Of *Stephen McMillan
> *Sent:* June-23-16 2:21 PM
>
> *To:* GrADS Users Forum <gradsusr at gradsusr.org>
> *Subject:* Re: [gradsusr] If Statements for Gridded Model Data Open GrADS
>
>
>
> Matt,
>
>
>
> 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...'
>
>
>
> Stephen Mc
>
>
>
> On Thu, Jun 23, 2016 at 11:51 AM, Baker, Matt (Quebec - Atlantic) <
> matt.baker at amecfw.com> wrote:
>
> Hi Stephen,
>
>
>
> I’m attempting your route with the if statements; however, I want to make
> sure I’m executing them correctly.
>
>
>
> Here’s the new code with the Ifs.
>
>
>
> 'define NAMHail = if(NAMcape,>,1500,if(NAMcape,<,2200,*NAMHail+1*
> ,NAMHail),NAMHail)'
>
> 'define NAMHail = if(NAMcape,>,2199,if(NAMcape,<,3100,*NAMHail+3*
> ,NAMHail),NAMHail)'
>
> 'define NAMHail = if(NAMcape,>,3099,*NAMHail+4*,NAMHail)'
>
>
>
> 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.
>
>
>
> Cheers,
>
>
>
> Matt
>
>
>
> *From:* gradsusr-bounces at gradsusr.org [mailto:
> gradsusr-bounces at gradsusr.org] *On Behalf Of *Stephen McMillan
> *Sent:* June-22-16 2:09 PM
>
>
> *To:* GrADS Users Forum <gradsusr at gradsusr.org>
> *Subject:* Re: [gradsusr] If Statements for Gridded Model Data Open GrADS
>
>
>
> Matt,
>
>
>
> 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.
>
>
>
> Here's a partial example using the first set of conditions you provided:
>
>
>
> 'define
> NAMHail=if(NAMcape,>,1500,if(NAMcape,<,2200,NAMHail+1,NAMHail),NAMHail)'
>
>
>
> 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.
>
>
>
> Stephen McMillan
>
>
>
>
>
> On Wed, Jun 22, 2016 at 12:11 PM, Baker, Matt (Quebec - Atlantic) <
> matt.baker at amecfw.com> 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/
>
>
>
> 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> 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** amecfw.com
>
> ISO 9001:2008 Quality Management System (St. John's)
>
>
>
> [image: cid:image001.jpg at 01D1CC84.8BC9E9B0]
>
>
> 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* <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 for notices and company
> information in relation to emails originating in the UK, Italy or France.
>
>
> _______________________________________________
> 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
>
>
>
>
> _______________________________________________
> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20160623/83cb5704/attachment-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 5711 bytes
Desc: not available
Url : http://gradsusr.org/pipermail/gradsusr/attachments/20160623/83cb5704/attachment-0001.jpg
More information about the gradsusr
mailing list