Thanks Josef, you're right. Could you explain me what's the difference between
In [4]: a=np.arange(10) In [5]: a.shape Out[5]: (10,) and In [6]: a=np.arange(10).reshape(10,1) In [7]: a.shape Out[7]: (10, 1) (10) means the first a is only a one-dimensional ndarray, but the (10,1) means the second a is a two-dimensional ndarray? another question, if I have In [70]: f Out[70]: masked_array(data = [[0 0] [1 1] [2 2] [3 3] [-- 4] [5 5] [6 6] [7 --] [8 8] [9 9]], mask = [[False False] [False False] [False False] [False False] [ True False] [False False] [False False] [False True] [False False] [False False]], fill_value = 999999) but when I do In [71]: f.data Out[71]: array([[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) it still shows the original value, so what 's the usage of fill_value in masked array? can I set a fill_value as np.nan? Thanks, Chao 2011/10/13 <josef.p...@gmail.com> > On Thu, Oct 13, 2011 at 1:17 PM, Chao YUE <chaoyue...@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 > > > > > _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > http://mail.scipy.org/mailman/listinfo/numpy-discussion > -- *********************************************************************************** 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