title: Function to compute 3D gradient with unevenly spaced sample locations
body: <p>I have experimental observations in a volume:</p>
  
  <pre><code>import numpy as np
  
  # observations are not uniformly spaced 
  x = np.random.normal(0, 1, 10)
  y = np.random.normal(5, 2, 10)
  z = np.random.normal(10, 3, 10)
  xx, yy, zz = np.meshgrid(x, y, z, indexing='ij')
  
  # fake temperatures at those coords
  tt = xx*2 + yy*2 + zz*2
  
  # sample distances
  dx = np.diff(x)
  dy = np.diff(y)
  dz = np.diff(z)
  
  grad = np.gradient(tt, [dx, dy, dz])  # returns error
  </code></pre>
  
  <p>This gives me the error:</p>
  
  <blockquote>
    <p><code>ValueError: operands could not be broadcast together with shapes (10,10,10) (3,9) (10,10,10)</code>.</p>
  </blockquote>
  
  <p>EDIT: according to @jay-kominek in the comments below:</p>
  
  <blockquote>
    <p>np.gradient won't work for you, it simply doesn't handle unevenly sampled data.</p>
  </blockquote>
  
  <p>I've updated the question. Is there any function which can can do my computation?</p>