[Numpy-discussion] Appending/combining masked arrays

josef.pktd@gmai... josef.pktd@gmai...
Wed Sep 29 16:46:03 CDT 2010


On Wed, Sep 29, 2010 at 5:37 PM, Pierre GM <pgmdevlist@gmail.com> wrote:
>
> On Sep 29, 2010, at 11:01 PM, Gökhan Sever wrote:
>
>> Hello,
>>
>> Consider these two simple masked arrays:
>>
>> I[188]: a = np.ma.masked_equal([1,2,3], value=2)
>>
>> I[189]: b = np.ma.masked_equal([4,3,2], value=2)
>>
>> An operation like this voids the mask:
>>
>> I[190]: np.append(a,b)
>> O[190]:
>> masked_array(data = [1 2 3 4 3 2],
>>             mask = False,
>>       fill_value = 999999)
>
> You're using a standard numpy function on a masked array. It's hardly surprising that you run into some issues. You should use the np.ma equivalent. Except of course that the equivalent doesn't exist yet... Please open a ticket.
>
> In the mean time, do it manually:
> * combining the .data of each item (masked array) of your list is straightforward
> * repeat for the masks. I advise you to use the getmaskarray function to get the mask of each item, otherwise you may get a `nomask` in the middle which will complicate things
> * combine the the two results in a new masked array.

any of the ma stack array function might also work, or not?

Josef


>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>


More information about the NumPy-Discussion mailing list