Re: [Numpy-discussion] change the mask state of one element in a masked array
thanks. 2012/2/18 Eric Firing > On 02/18/2012 05:52 AM, Chao YUE wrote: > > Dear all, > > > > I built a new empty masked array: > > > > In [91]: a=np.ma.empty((2,5)) > > Of course this only makes sense if you are going to immediately populate > the array. > > > > > In [92]: a > > Out[92]: > > masked_array(data = > > [[ 1.20569155e-312 3.34730819e-316 1.13580079e-316 > 1.11459945e-316 > > 9.69610549e-317] > > [ 6.94900258e-310 8.48292532e-317 6.94900258e-310 > 9.76397825e-317 > > 6.94900258e-310]], > > mask = > > False, > > fill_value = 1e+20) > > > > > > as you see, the mask for all the elements are false. so how can I set > > for some elements to masked elements (mask state as true)? > > let's say, I want a[0,0] to be masked. > > a[0,0] = np.ma.masked > > Eric > > > > > thanks & 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
Re: [Numpy-discussion] change the mask state of one element in a masked array
On 02/18/2012 05:52 AM, Chao YUE wrote: > Dear all, > > I built a new empty masked array: > > In [91]: a=np.ma.empty((2,5)) Of course this only makes sense if you are going to immediately populate the array. > > In [92]: a > Out[92]: > masked_array(data = > [[ 1.20569155e-312 3.34730819e-316 1.13580079e-316 1.11459945e-316 > 9.69610549e-317] > [ 6.94900258e-310 8.48292532e-317 6.94900258e-310 9.76397825e-317 > 6.94900258e-310]], > mask = > False, > fill_value = 1e+20) > > > as you see, the mask for all the elements are false. so how can I set > for some elements to masked elements (mask state as true)? > let's say, I want a[0,0] to be masked. a[0,0] = np.ma.masked Eric > > thanks & 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
Re: [Numpy-discussion] change the mask state of one element in a masked array
There may be a better way to do it, but you can first do: a.mask = np.zeros_like(a) then afterwards e.g. a.mask[0, 0] = True will work. -=- Olivier Le 18 février 2012 10:52, Chao YUE a écrit : > Dear all, > > I built a new empty masked array: > > In [91]: a=np.ma.empty((2,5)) > > In [92]: a > Out[92]: > masked_array(data = > [[ 1.20569155e-312 3.34730819e-316 1.13580079e-316 1.11459945e-316 > 9.69610549e-317] > [ 6.94900258e-310 8.48292532e-317 6.94900258e-310 9.76397825e-317 > 6.94900258e-310]], > mask = > False, >fill_value = 1e+20) > > > as you see, the mask for all the elements are false. so how can I set for > some elements to masked elements (mask state as true)? > let's say, I want a[0,0] to be masked. > > thanks & 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
[Numpy-discussion] change the mask state of one element in a masked array
Dear all, I built a new empty masked array: In [91]: a=np.ma.empty((2,5)) In [92]: a Out[92]: masked_array(data = [[ 1.20569155e-312 3.34730819e-316 1.13580079e-316 1.11459945e-316 9.69610549e-317] [ 6.94900258e-310 8.48292532e-317 6.94900258e-310 9.76397825e-317 6.94900258e-310]], mask = False, fill_value = 1e+20) as you see, the mask for all the elements are false. so how can I set for some elements to masked elements (mask state as true)? let's say, I want a[0,0] to be masked. thanks & 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