I have a series of small images, stored as 2d numpy arrays. After applying a threshold, I turn the input image into a masked array (mask out values below threshold). Based on this, as shown in the plot below I end up with a number of different objects (2 sometimes more). How can I identify ..

I was trying to understand numpy masks better and decided to try a simple fizzbuzz exercise (since np arrays are homogenous, 9993 is "fizz", 9995 = "buzz", 9998 = "fizzbuzz"). However, I noticed behavior I cannot understand and was hoping that someone could explain. In the first case, I created my masks like that: In: ..

For a one dimensional numpy array of 1’s and 0’s, how can I effectively "mask" the array such that after the occurrence of a 1, the next n elements of the array are converted to zero. After the n elements have passed, the pattern repeats such that the first next occurrence of a 1 is ..

I would like to know if you could give me a way to calculate rolling means on a numpy masked array, without using the masked values. I currently am using the convolve numpy method, but it does not work: import numpy as np a=np.array([1,2,5,4,9,6,1000,3,6,2,9,0]) a=np.ma.masked_where(a>990,a) print(a) a=np.convolve(a, np.ones(5), "valid")/5 print(a) >>>[1 2 5 4 9 ..

I have a numpy masked nd-array. I need to find the median along a specific axis. For some cases, I end up having even number of elements, in which case numpy.ma.median gives average of the middle two elements. However, I don’t want the average. I want one of the median elements. Any one of the ..

I have masked array from which I extracted and converted Datetime from a time series presented in terms of seconds from start date into an ‘Array of an object’. Using the following in python. date=num2date(time, units = data.variables[‘time’].units) when I print date I get Out[41]: masked_array(data=[cftime.DatetimeGregorian(2002, 8, 23, 9, 0, 0, 0, has_year_zero=False), cftime.DatetimeGregorian(2003, 9, ..

The source of this post is from an earlier post. I have X,Y,Z 2D arrays. I only want to see the plot in the first-quadrant where all x, y and z are positive. I use masking on all negative z entries. However it was noticed that scatter plots indeed respect the masking and do not ..