title: Calculating a 3D gradient with unevenly spaced points
body: <p>I currently have a volume spanned by a few million every unevenly spaced particles and each particle has an attribute (potential, for those who are curious) that I want to calculate the local force (acceleration) for. </p>
  
  <p>np.gradient only works with evenly spaced data and I looked here: <a href="https://stackoverflow.com/questions/23419193/second-order-gradient-in-numpy">Second order gradient in numpy</a> where interpolation is necessary but I could not find a 3D spline implementation in Numpy. </p>
  
  <p>Some code that will produce representative data:</p>
  
  <pre><code>import numpy as np    
  from scipy.spatial import cKDTree
  
  x = np.random.uniform(-10, 10, 10000)
  y = np.random.uniform(-10, 10, 10000)
  z = np.random.uniform(-10, 10, 10000)
  phi = np.random.uniform(-10**9, 0, 10000)
  
  kdtree = cKDTree(np.c_[x,y,z])
  _, index = kdtree.query([0,0,0], 32) #find 32 nearest particles to the origin
  #find the gradient at (0,0,0) by considering the 32 nearest particles?  
  </code></pre>
  
  <p>(My problem is very similar to <a href="https://stackoverflow.com/questions/36781698/compute-3d-gradient-with-unevenly-spaced-sample-locations">Function to compute 3D gradient with unevenly spaced sample locations</a> but there seemed to have been no solution there, so I thought I'd ask again.) </p>
  
  <p>Any help would be appreciated. </p>