Logic Question

Eric Altshuler ela at COLA.IGES.ORG
Wed Mar 25 23:29:41 EDT 2009


Hello Mark,

I think the following will do what you want:

var1m=const(maskout(var1,var1-var2),0,-u)
var2m=const(maskout(var2,var2-var1),0,-u)
varxm=const(maskout(var1,-abs(var1-var2)),0,-u)
d var1m+var2m-varxm

var1m will equal var1 where var1>=var2 and zero where var1<var2.
var2m will equal var2 where var2>=var1 and zero where var2<var1.

The sum of var1m and var2m will equal var1 where var1>var2 and will equal var2 where var2>var1. However, at grid points where var1=var2, var1m+var2m will be equal to var1+var2 (and also equal to 2*var1 and 2*var2). In this case, var1 (or var2) must be subtracted from var1+var2 to get the correct value. To handle the situation where var1=var2, varxm will equal var1 (and also var2) where var1=var2 and zero where var1<>var2. So, finally, the expression var1m+var2m-varxm will equal var1 where var1>=var2 and will equal var2 where var2>=var1.

I tried this out with my own data and it seems to work. The maskout and const functions are amazingly useful for problems like this.

Best regards,

Eric L. Altshuler
Assistant Research Scientist
Center for Ocean-Land-Atmosphere Studies
4041 Powder Mill Road, Suite 302
Calverton, MD 20705-3106
USA

E-mail: ela at cola.iges.org
Phone: (301) 902-1257
Fax: (301) 595-9793

----- Original Message -----
From: "Mark Sponsler" <msponsler at COMCAST.NET>
To: GRADSUSR at LIST.CINECA.IT
Sent: Wednesday, March 25, 2009 6:54:20 PM GMT -05:00 US/Canada Eastern
Subject: Logic Question

I need your expert assistance

The goal is to display the greater of 2 variables, comparing them grib
point by grib point onto a single image in one display operation.  I
believe that 'if' and '>' can't be used in a define statement, hence the
dilemma:

Logically for each grib point I want to:

if (var1 >= var2)
   d var1
else
if (var2 > var1)
   d var2
endif

So I'm trying to figure out how to set up a define statement to accomplish
that.

define var3 = (logic here...)
d var3

Any thoghts would be most appreciated.



More information about the gradsusr mailing list