Should work with: b = numpy.ma.masked_array(b, mask=a.mask) -=- Olivier
Le 4 mars 2012 13:01, Chao YUE <chaoyue...@gmail.com> a écrit : > Dear all, > > I have a matrix with dimension of (360,720) but with all global data. > I have another land-sea mask matrix with only 2 unique values in it > (land=1, sea=-1). > So I can easily create transform the second array to a masked array. > the problem is, how can I quickly transform the first one to a masked > array using the same mask as the land-sea mask array? > > I hope my question is clear. If not, here is an example: > > In [93]: a=np.arange(10).reshape(2,5) > In [95]: a=np.ma.masked_equal(a,2 > In [96]: a=np.ma.masked_equal(a,8) > > In [97]: a > Out[97]: > masked_array(data = > [[0 1 -- 3 4] > [5 6 7 -- 9]], > mask = > [[False False True False False] > [False False False True False]], > fill_value = 8) > > In [100]: b=np.random.normal(0,2,size=(2,5)) > > I want to convert b to a masked array using exactly the same mask as a. > > thanks to all, > 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