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.
I would then like the gradient of the scalar at every grid point. In 2D I am doing this using np.gradient and I get two arrays with the gradient in the x and y directions:
gradx, grady = np.gradient(grid)
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).
As far as I can see np.gradient can’t deal with this?
Thanks,
Daniel
The Numpy documentation indicates that
gradientworks for any dimensions:Seems like you should be able to extend your 2-dimensional code to 3D like you would expect.