[Numpy-discussion] the axis parameter in the np.ma.concatenate is not working?

josef.pktd@gmai... josef.pktd@gmai...
Thu Oct 13 13:15:01 CDT 2011


On Thu, Oct 13, 2011 at 1:17 PM, Chao YUE <chaoyuejoy@gmail.com> wrote:
> Dear all,
>
> I use numpy version 1.5.1 which is installed by default when I do sudo
> apt-get install numpy on ubuntu 11.04.
> but it seems that for np.ma.concatenate(arrays, axis), the axis parameter is
> not working?
>
> In [460]: a=np.arange(10)
>
> In [461]: a=np.ma.masked_array(a,a<3)
>
> In [462]: a
> Out[462]:
> masked_array(data = [-- -- -- 3 4 5 6 7 8 9],
>              mask = [ True  True  True False False False False False False
> False],
>        fill_value = 999999)
>
>
> In [463]: b=np.arange(10)
>
> In [464]: b=np.ma.masked_array(a,b>7)
>
> In [465]: b
> Out[465]:
> masked_array(data = [-- -- -- 3 4 5 6 7 -- --],
>              mask = [ True  True  True False False False False False  True
> True],
>        fill_value = 999999)
>
>
> In [466]: c=np.ma.concatenate((a,b),axis=0)
>
> In [467]: c
> Out[467]:
> masked_array(data = [-- -- -- 3 4 5 6 7 8 9 -- -- -- 3 4 5 6 7 -- --],
>              mask = [ True  True  True False False False False False False
> False  True  True
>   True False False False False False  True  True],
>        fill_value = 999999)
>
>
> In [468]: c.shape
> Out[468]: (20,)
>
> In [469]: c=np.ma.concatenate((a,b),axis=1)

maybe you want numpy.ma.column_stack

for concatenate you need to add extra axis first

something like
c=np.ma.concatenate((a[:,None], b[:,None]),axis=1)  (not tested)

Josef

>
> In [470]: c.shape
> Out[470]: (20,)
>
> cheers,
>
> Chao
>
> --
> ***********************************************************************************
> Chao YUE
> Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
> UMR 1572 CEA-CNRS-UVSQ
> Batiment 712 - Pe 119
> 91191 GIF Sur YVETTE Cedex
> Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
> ************************************************************************************
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>


More information about the NumPy-Discussion mailing list