Carol,
Points can be TRUE (1), FALSE (0) or MISSING. In your example
MISSING is being used as a FLASE, but it really isn't. If a point
is MISSING, the result of using that point in any binary operation
will also be missing (and, or, +, -, *, /, etc.). Thus the "and"
and "or" operations produce the same result. By following Paul's
suggestion you are ensuring that you use FALSE instead of MISSING.
In practice, the use of MISSING makes a nicer mask for graphical
purposes, because "0"'s behave like valid values on the plot.
To my eye, the most elegant way to express your examples would be
yes? let mask1= y[gy=sst] lt 20
yes? let mask2= y[gy=sst] gt 0
yes? let mask3 = mask1 and mask2
yes? let mask4 = mask1 or mask2
yes? fill/l=1 IF mask3 then sst
yes? fill/l=1 IF mask4 then sst
- Steve
=======================================================
On 2/3/2012 12:59 PM, Paul Young wrote:
Hi Carol,
I can get the desired result by adding "else 0" to the mask1
and mask2 definitions (which I thought was implied):
let mask1 = if y[gy=sst] lt 20 then 1 else 0
let mask2 = if y[gy=sst] gt 0 then 1 else 0
let mask3 = if (mask1 and mask2) then 1 !funnily
enough, no need for "else 0" here
fill/l=1 sst*mask3 !Just Eq to 20N
I can also get it by making the mask in one shot:
let mask = if y[gy=sst] gt 0 and y[gy=sst] lt 20 then 1 else
0
Hope this helps.....but perhaps a ferret expert can clarify
when the "else 0" is needed?
Thanks!
Paul
On Feb 3, 2012, at 12:56 PM, Carol Ladd wrote:
I am trying
to create a lat/lon mask using if statements. I
create two overlapping masks and then want to combine
them. I would assume I should use “or” to combine the
two regions. However, using either “and” or “or” in
the masking definition, I get the same result. Is
this a bug or am I doing something wrong? I am using
Ferret v6.65.
See the
following script for a quick example:
use
coads_climatology
sh d
let mask1=if
y[gy=sst] lt 20 then 1
let mask2=if
y[gy=sst] gt 0 then 1
let mask3 =
if (mask1 and mask2) then 1
let mask4 =
if (mask1 or mask2) then 1
fill/l=1
sst*mask1
pause
fill/l=1
sst*mask2
pause
fill/l=1
sst*mask3
pause
fill/l=1
sst*mask4
q
Thanks.
Carol
|