I am looking for a way to average the data that I have in an array based on how far it is from a certain pixel. To achieve this I have made an array r
which contains the distances to the center. There is a second array data
that contains the counts that can be found in the pixel at that distance.
Now I have split the entire dataset (that goes from 0-1150) into 60 bins and then digitized the data to get an array that tells me which value belongs into which bin.
bins = np.linspace(0,60*20, 60)
digitized = np.digitize(rr, bins)
Is there a smart way to apply digitized to the data so that all points with the same bin value get averaged?
Array r
has a shape of 380, data
is the same. So the end result should be an array of 60 elements that has the average of all the binned values in data
based on which bin was assigned to digitized
.