Gradient vector of a matrix of geographical extent

ManuelFossa
Thu, 15 Sep 2022 15:39:26 +0000
General Usage

I have a geographical matrix M of dimensions nLat=181 and nLon=221 , with lats = 30:0.25:90 and lons=-30:0.25:25.
I want to compute the gradient vector of M w.r.t to lats , lons.
I have tried ForwardDiff , Iterations , ScatteredIterations , Flux and my problem is that they all accept continuous functions as input.
I have tried the method interpolating , or this one, but to no avail.

Here is my current code

x = lats
y = lons
points = (x,y)
samples = M
itp = Interpolations.interpolate(points, samples, Gridded(Linear()))
itpGradient = Interpolations.gradient.(itp,x,y)

I get the following error

DimensionMismatch("arrays could not be broadcast to a common size; got a dimension with lengths 181 and 221")

4 posts - 3 participants