[Numpy-discussion] Getting masked array boundary indices
Hi, I have a numpy array which is masked ( bathymetry), as seen below [ True] [ True] [ True] [ True]], fill_value = -.0) In [10]: depth[:,1130:1131] I need to find the indices where land(mask) is there along the boundaries and where water(value) is there along the boundaries, the above listing is along eastern boundary. Please help if there is a way to get starting and ending index of mask. I tried np.where but it gives another array as there are several mask points are there, I need to use some thing like if neighbouring points are True and False then index =i, but I am not getting the pythonic way to get this done. with best regards, Sudheer *** Sudheer Joseph Indian National Centre for Ocean Information Services Ministry of Earth Sciences, Govt. of India POST BOX NO: 21, IDA Jeedeemetla P.O. Via Pragathi Nagar,Kukatpally, Hyderabad; Pin:5000 55 Tel:+91-40-23886047(O),Fax:+91-40-23895011(O), Tel:+91-40-23044600(R),Tel:+91-40-9440832534(Mobile) E-mail:sjo.in...@gmail.com;sudheer.jos...@yahoo.com Web- http://oppamthadathil.tripod.com *** ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Getting masked array boundary indices
On Wed, Nov 27, 2013 at 7:01 AM, Sudheer Joseph sudheer.jos...@yahoo.com wrote: Hi, I have a numpy array which is masked ( bathymetry), as seen below [ True] [ True] [ True] [ True]], fill_value = -.0) In [10]: depth[:,1130:1131] I need to find the indices where land(mask) is there along the boundaries and where water(value) is there along the boundaries, the above listing is along eastern boundary. Please help if there is a way to get starting and ending index of mask. I tried np.where but it gives another array as there are several mask points are there, I need to use some thing like if neighbouring points are True and False then index =i, but I am not getting the pythonic way to get this done. if I understand correctly np.nonzero(np.diff(depth.mask))[0] Josef with best regards, Sudheer *** Sudheer Joseph Indian National Centre for Ocean Information Services Ministry of Earth Sciences, Govt. of India POST BOX NO: 21, IDA Jeedeemetla P.O. Via Pragathi Nagar,Kukatpally, Hyderabad; Pin:5000 55 Tel:+91-40-23886047(O),Fax:+91-40-23895011(O), Tel:+91-40-23044600(R),Tel:+91-40-9440832534(Mobile) E-mail:sjo.in...@gmail.com;sudheer.jos...@yahoo.com Web- http://oppamthadathil.tripod.com *** ___ 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] Getting masked array boundary indices
Thank you, Though it did not get what I expected it is a strong clue, let me explore it, With. Best regards Sudheer___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion