[Numpy-discussion] Using matplotlib's prctile on masked arrays

josef.pktd@gmai... josef.pktd@gmai...
Wed Oct 28 09:03:23 CDT 2009


On Wed, Oct 28, 2009 at 9:52 AM, Gökhan Sever <gokhansever@gmail.com> wrote:
>
>
> On Tue, Oct 27, 2009 at 12:23 PM, Pierre GM <pgmdevlist@gmail.com> wrote:
>>
>> On Oct 27, 2009, at 7:56 AM, Gökhan Sever wrote:
>> >
>> >
>> > Unfortunately, matplotlib.mlab's prctile cannot handle this division:
>>
>> Actually, the division's OK, it's mlab.prctile which is borked. It
>> uses the length of the input array instead of its count to compute the
>> nb of valid data. The easiest workaround in your case is probably to
>> use:
>>  >>> prctile((am/bm).compressed(), p=[5,25,50,75,95])
>> HIH
>> P.
>
> Great. Exact solution. I should have asked this last week :)
>
> One simple method solves all the riddle. I had manually masked the MVCs
> using NaN's.
>
> My guess is using compressed() masked arrays could be used with any of
> regularly defined numpy and scipy functions, right?

Yes, however it only works for 1d or with ravel().

You cannot compress a 2d array, and preserve a rectangular shape (with
unequal numbers of missing numbers.)

I some cases removing rows or columns with missing values might be
more appropriate, or finding a "neutral" fill value.

Josef



>
> Thanks for the tip.
>
>>
>> _______________________________________________
>> NumPy-Discussion mailing list
>> NumPy-Discussion@scipy.org
>> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
>
> --
> Gökhan
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>


More information about the NumPy-Discussion mailing list