mask one array using another array

questions anon questions.anon at gmail.com
Mon Nov 21 20:37:57 EST 2011


thank you, that makes sense.
 I should have posted this on another list (which I have now). and the
change required is:

If your new array is x, you can use:

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

On Tue, Nov 22, 2011 at 11:48 AM, MRAB <python at mrabarnett.plus.com> wrote:

> On 21/11/2011 21:42, questions anon wrote:
>
>> 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<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.
>>
>>  The article is using the Numeric module, but your error says that you're
> using
> the numpy module. They're not the same.
> --
> http://mail.python.org/**mailman/listinfo/python-list<http://mail.python.org/mailman/listinfo/python-list>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20111122/6f6fe64c/attachment-0001.html>


More information about the Python-list mailing list