Recreate NCL bin_avg function in python

69 views Asked by At

I am trying to recreate NCL's bin_avg function in python. The function takes in a list of latitudes, longitudes, and observation values at those points, and calculates the average value of the observations contained within each box in some grid.

The closest I could come up with is using scipy.spatial.cKDTree.query_ball_point, but this finds all points within a radisu rather than within a grid box...

1

There are 1 answers

0
hm8 On BEST ANSWER

Looks like what I was looking for is in scipy.stats.binned_statistic