Re: What is mean by True or False in mask function.?

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Thu Apr 22 2010 - 09:26:41 MDT

Hi Sabeerali,

The mask function confuses me too. You have to be careful about what
you mean by "mask". With this function, "mask" and "protect" are the
same meaning here.

The way I think of it is "The mask function protects values in the
first argument at locations where values in the second argument are
equal to the value in the third argument".
Everywhere else, the values are set to missing. Of course, the first
argument is not physically changed itself. The changes are reflected
in whatever variable you have on the left side of the equal sign.

So, for:

    out1 = mask(a, (ma0.ne.2), True)

This means that out1 will be "protected" at locations where ma0 is not
equal to 2.

In other words, any place that ma0 is not equal to 2, out1 will be
equal to a. Any place ma0 is equal to 2, out1 will be set to the
missing value for a.

This could have been accomplished with the "where" function:

    out1 = where(ma0.ne.2,a,a@_FillValue)

With this code:

> aveX_u = mask(aveX_u,( alpha_u.le.95.and.alpha_v.le.95),True)
> aveX_v = mask(aveX_v, (alpha_u.le.95.and.alpha_v.le.95),True)

Any place that both alpha_u and alpha_v are <= 95 in the same
locations, aveX_u and aveX_v will be "protected", that is, their
original values will be kept.
Everywhere else, aveX_u and aveX_v will be set to their respective
missing values.

The "where" equivalent would be:

aveX_u = where(alpha_u.le.95.and.alpha_v.le.95,aveX_u,aveX_u@_FillValue)
aveX_v = where(alpha_u.le.95.and.alpha_v.le.95,aveX_v,aveX_v@_FillValue)

Does this help clear up why this code is not behaving as expected?

--Mary

On Apr 21, 2010, at 11:03 PM, Sabeerali(sebi) wrote:

> What is mean by True or False in mask function...When I read the
> document it make me confused...
> The following example given in document confused me...
> The following line mask a at locations where ma0 is not-equal-to 2
>
> out1 = mask( a, (ma0.ne.2), True)
>
> In my case I want to mask aveX_u and aveX_v at locations where both
> alpha_u and alpha_v less than or equal to 95..So as per the above
> example I used the following line.
>
> aveX_u = mask(aveX_u,( alpha_u.le.95.and.alpha_v.le.95),True)
> aveX_v = mask(aveX_v, (alpha_u.le.95.and.alpha_v.le.95),True)
>
>
> But I am not getting the desired result..If I set True to False (as
> given below) I think I am getting the correct values...
>
> aveX_u = mask(aveX_u,( alpha_u.le.95.and.alpha_v.le.95),False)
> aveX_v = mask(aveX_v, (alpha_u.le.95.and.alpha_v.le.95),False)
>
> So anyone can give more information on True/False
> Also which one is correct in my case..
>
>
> Thanks in advance...
>
>
>
> --
> **********************************
> Sabeerali
> Climate and Global Modeling Division
> Indian Institute of Tropical Meteorology
> Pashan, Pune, 411 008
> ****************************************
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Apr 22 09:26:57 2010

This archive was generated by hypermail 2.1.8 : Fri Apr 23 2010 - 14:40:07 MDT