[Thread Prev][Thread Next][Index]

[ferret_users] masking with OR and undefined values doesn't work as expected



Hi ferreters, hi developers,


masking is a bit counterintuitive in ferret when involving undefined values:


yes? let a = {1,2,-1E34,4}
yes? let b = {1,-1E34,3,4}
yes? let bla = if (a OR b) then 1
yes? list bla
             VARIABLE : IF (A OR B) THEN 1
             SUBSET   : 4 points (X)
 1   / 1:  1.000
 2   / 2:   ....
 3   / 3:   ....
 4   / 4:  1.000

'OR' implies that 'bla' should be equal to 1 for all 4 data points, because at all 4 points either a or b is actually defined. However, it sets all points to undefined that are undefined in either a or b.


Also this not very elegant version won't work:

yes? let bla = if (a NE -1E34 OR b NE -1E34) then 1
yes? list bla
             VARIABLE : IF (A NE -1E34 OR B NE -1E34) THEN 1
             SUBSET   : 4 points (X)
 1   / 1:  1.000
 2   / 2:   ....
 3   / 3:   ....
 4   / 4:  1.000


Of course this is only a problem when undefined values are involved. Otherwise masking with OR works as expected:

yes? let a = {1,1,2,1}
yes? let b = {1,2,1,1}
yes? let bla = if (a EQ 2 OR b EQ 2) then 1
yes? list bla
             VARIABLE : IF (A EQ 2 OR B EQ 2) THEN 1
             SUBSET   : 4 points (X)
 1   / 1:   ....
 2   / 2:  1.000
 3   / 3:  1.000
 4   / 4:   ....


A workaround is to set undefined values to zero and then do the masking. However, this makes 'real' zero values indistinguishable from undefined values, which could otherwise be kept apart by 'if (a or a EQ 0) then ...'.

Sorry if I missed a note on this in the ferret documentation.



Best wishes,
Hella


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

Privacy Policy | Disclaimer | Accessibility Statement