[Numpy-discussion] Getting masked array boundary indices

josef.pktd at gmail.com josef.pktd at gmail.com
Wed Nov 27 07:14:38 EST 2013


On Wed, Nov 27, 2013 at 7:01 AM, Sudheer Joseph
<sudheer.joseph at yahoo.com> wrote:
> Hi,
>                I have a numpy array which is masked ( bathymetry), as seen below
>
>  [ True]
>  [ True]
>  [ True]
>  [ True]],
>        fill_value = -9999.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.India at gmail.com;sudheer.joseph at yahoo.com
> Web- http://oppamthadathil.tripod.com
> ***************************************************************
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion



More information about the NumPy-Discussion mailing list