[Numpy-discussion] mask one array using another array

Olivier Delalleau shish@keba...
Mon Nov 21 18:21:24 CST 2011


If your new array is x, you can use:

numpy.ma.masked_array(x, mask=mask.mask)

-=- Olivier

2011/11/21 questions anon <questions.anon@gmail.com>

> I am trying to mask one array using another array.
>
> I have created a masked array using
> mask=MA.masked_equal(myarray,
> 0),
> that looks something like:
> [1  -  -  1,
>  1  1  -  1,
>  1  1  1  1,
>  -   1  -  1]
>
> I have an array of values that I want to mask whereever my mask has a a
> '-'.
> how do I do this?
> I have looked at
> http://www.cawcr.gov.au/bmrc/climdyn/staff/lih/pubs/docs/masks.pdf but
> the command:
>
> d = array(a, mask=c.mask()
>
> results in this error:
> TypeError: 'numpy.ndarray' object is not callable
>
> I basically want to do exactly what that article does in that equation.
>
> Any feedback will be greatly appreciated.
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20111121/8f7e8bd9/attachment.html 


More information about the NumPy-Discussion mailing list