I have three 1D arrays representing some spatial data (u) over a rectangular region of space: the first array contains the x coordinates, the second contains the y coordinates, and the third contains u. The x and y arrays are ordered weirdly and there are many repeated elements because lots of points sampled in the region share x and y coordinates (each point is still at a different location though). I want to calculate the derivatives of u at each point with respect to x and y.
I first tried the numpy.gradient
function. The numpy.gradient
documentation says something about how you can enter the coordinate arrays in the *varargs
field of the function, but I don't know if that is for the purpose I think it is, and I am confident it doesn't work the way I thought it would. If anyone could help me figure out how to get the derivatives of u with respect to x and y, I would be grateful. It doesn't have to be through the numpy.gradient
method. I just need something where I can input the 1D arrays and it will spit out the two spatial derivatives.
Thanks in advance!