title: Python: Calculate the Gradient of a 3D grid
body: <p>I have a cube of particles which I've projected onto a 2D grid, Projecting the particles onto the grid by a clouds in cells and weighting them by a scalar.</p>
  
  <p>I would then like the gradient of the scalar at every grid point. In 2D I am doing this using <code>np.gradient</code> and I get two arrays with the gradient in the x and y directions:</p>
  
  <pre><code>gradx, grady = np.gradient(grid)
  </code></pre>
  
  <p>Does anyone have any idea how I can generalize this to 3 Dimensions? The Clouds in Cells in 3D is fine but I am then left with a grid with the shape (700, 700, 700).</p>
  
  <p>As far as I can see <code>np.gradient</code> can't deal with this?</p>
  
  <p>Thanks,
  Daniel</p>