I have two arrays:
a=np.array([[ 41.0,  0.71],
       [ 41.21,  0.87],
       [ 41.14,  0.96],
       [41.5,  0.86])
b=np.array([[ 41.41, 1.51],
       [ 41.3,  0.95],
       [ 41.0,  0.96],
       [42.1,  0.76]),
       [ 40.3,  0.85],
       [ 41.1,  0.76],
       [40.9,  0.96])...]
And for each point in a, I need to find the nearest points in b which are closest to that point within a ratio r.
I already try to do something similar to the example: "Finding index of nearest point in numpy arrays of x and y coordinates" but with no exit, somebody can show me an easy way to use spatial.KDTree or spatial.cKDTree?