Re: How does the mask function work?

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Mon Mar 14 2011 - 12:19:04 MDT

The "mask" function 'Description' section states:

"Missing values are placed in the output array in locations where marray
is *not* equal to the mask value"

I also had trouble with the action of mask.
It is wired differently than the way my brain works!

The "where" function could be used also
   http://www.ncl.ucar.edu/Document/Functions/Built-in/where.shtml

On 3/14/11 12:10 PM, John Kerfoot wrote:
> Hi Gibies,
>
> Thanks for your response, but I'm still confused by the behavior.
>
> My understanding is that since I set the 3rd argument in the function
> call to True:
>
> z = mask(x, (f.lt.3), True);
>
> That x should be masked at the points where the expression is true
> (ie: everywhere that f is less than 3). So this should result in the
> first 6 values of x:
>
> Variable: x
> Type: integer
> Total Size: 36 bytes
> 9 values
> Number of Dimensions: 1
> Dimensions and sizes: [9]
> Coordinates:
> (0) 0
> (1) 1
> (2) 2
> (3) 3
> (4) 4
> (5) 5
> (6) 6
> (7) 7
> (8) 8
>
> getting masked because this is where the values in f are less than 3:
>
> Variable: f
> Type: integer
> Total Size: 36 bytes
> 9 values
> Number of Dimensions: 1
> Dimensions and sizes: [9]
> Coordinates:
> (0) 1
> (1) 1
> (2) 1
> (3) 2
> (4) 2
> (5) 2
> (6) 3
> (7) 3
> (8) 3
>
> Your explanation (and the result from executing the code) seems to be
> the opposite. Can you provide me with a little clarification?
>
> thanks again for your time and help.
>
> John
>
> On Mon, Mar 14, 2011 at 12:01 AM, gibies george<gibies@tropmet.res.in> wrote:
>>
>>
>> On 14 March 2011 02:01, John Kerfoot<johnkerfoot@gmail.com> wrote:
>>>
>>> I've got a large AVHRR sea-surface temperature dataset for which I'm
>>> trying to mask out some bad values; however I'm seeing some strange
>>> (and contradictory) behavior when using the mask function and I'm
>>> looking for some clarification.
>>>
>>> Before getting to the AVHRR dataset, I tried the following to make
>>> sure that I understood how mask worked:
>>>
>>> ; Array to mask
>>> x = ispan(0,8,1);
>>> print(x);
>>>
>>> ; Mask values
>>> f = (/1, 1, 1, 2, 2, 2, 3, 3, 3/);
>>> print(f)
>>>
>>> : Mask all corresponding values in x where f is less than 3
>>> z = mask(x, (f.lt.3), True);
>>
>>
>> Here the function have Masked all corresponding values in x except where f
>> is less than 3
>>>
>>> print(z);
>>>
>>> I expected the first 6 values of x to be set to the fill value, but
>>> the opposite happened:
>>>
>>> Variable: x
>>> Type: integer
>>> Total Size: 36 bytes
>>> 9 values
>>> Number of Dimensions: 1
>>> Dimensions and sizes: [9]
>>> Coordinates:
>>> (0) 0
>>> (1) 1
>>> (2) 2
>>> (3) 3
>>> (4) 4
>>> (5) 5
>>> (6) 6
>>> (7) 7
>>> (8) 8
>>>
>>>
>>> Variable: f
>>> Type: integer
>>> Total Size: 36 bytes
>>> 9 values
>>> Number of Dimensions: 1
>>> Dimensions and sizes: [9]
>>> Coordinates:
>>> (0) 1
>>> (1) 1
>>> (2) 1
>>> (3) 2
>>> (4) 2
>>> (5) 2
>>> (6) 3
>>> (7) 3
>>> (8) 3
>>>
>>
>> Here the function have Masked all corresponding values in x except where f
>> is less than 3
>>
>>>
>>> Variable: z
>>> Type: integer
>>> Total Size: 36 bytes
>>> 9 values
>>> Number of Dimensions: 1
>>> Dimensions and sizes: [9]
>>> Coordinates:
>>> Number Of Attributes: 1
>>> _FillValue : -999
>>> (0) 0
>>> (1) 1
>>> (2) 2
>>> (3) 3
>>> (4) 4
>>> (5) 5
>>> (6) -999
>>> (7) -999
>>> (8) -999
>>>
>>>
>>>
>>> So I'm clearly not understanding how to use this function. Can
>>> someone explain this result? How can I get all values of x to be
>>> masked where f is less than 3?
>>>
>>> Once I understand this, I'll have a follow up question using the AVHRR
>>> datset.
>>>
>>> thanks in advance,
>>> John
>>> _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>>
>> --
>> Gibies George, CSIR-RF,
>> Seasonal Scale Prediction Group,
>> Climate and Global Modelling Division,
>> Indian Institute of Tropical Meteorology,
>> Dr. Homi Bhabha Road,
>> NCL (P. O.), Pashan,
>> Pune 411008, India.
>>
>> http://sites.google.com/site/gibiesge/
>>
>> Please Think about the environment. Save paper; Save Trees; and don't print
>> this e-mail unless it is necessary.
>>
> _______________________________________________
> 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 Mon Mar 14 12:19:09 2011

This archive was generated by hypermail 2.1.8 : Wed Mar 16 2011 - 09:22:37 MDT