[Thread Prev][Thread Next][Index]

Re: [ferret_users] masking using and/or



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


[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement