Relative Content

Tag Archive for pythonnumpygradient

How to calculate gradient of data on non-orthogonal ordered grid?

I have a grid of xy-coordinates that I generate using np.meshgrid. The spacing in x-direction is constant, the y-coordinates are scaled, as a function of x. In this specific case, this results in a cloud of points that lie on a trapezoid, with a side length of 2 on the left and 1 on the right side. I have a function f(x, y), and I want to get the gradient of that function in y-direction and in the direction of each row of points. How can I use np.gradient with xy-arguments to do this? I find the documentation somewhat confusing.

How to calculate gradient of data on non-orthogonal ordered grid?

I have a grid of xy-coordinates that I generate using np.meshgrid. The spacing in x-direction is constant, the y-coordinates are scaled, as a function of x. In this specific case, this results in a cloud of points that lie on a trapezoid, with a side length of 2 on the left and 1 on the right side. I have a function f(x, y), and I want to get the gradient of that function in y-direction and in the direction of each row of points. How can I use np.gradient with xy-arguments to do this? I find the documentation somewhat confusing.