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...
Looks like what I was looking for is in
scipy.stats.binned_statistic