I am looking for a way to do double integration over sampled data using numpy trapz or a similar function from scipy stack.
In particular, I would like to compute a function:

where f(x',y')is a discretized array, and F(x, y)is an array of the same size.
This is my attempt which gives incorrect results:
def integrate_2D(f, x, y):
def integral(f, x, y, x0, y0):
F_i = np.trapz(np.trapz(np.arcsinh(1/np.sqrt((x-x0+0.01)**2+(y-y0+0.01)**2)) * f, x), y)
return F_i
sigma = 1.0
F = [[integral(f, x, y, x0, y0) for x0 in x] for y0 in y]
return F
xlin = np.linspace(0, 10, 100)
ylin = np.linspace(0, 10, 100)
X,Y = np.meshgrid(xlin, ylin)
f = 1.0 * np.exp(-((X - 8.)**2 + (Y - 8)**2)/(8.0))
f += 0.5 * np.exp(-((X - 1)**2 + (Y - 9)**2)/(10.0))
F = integrate_2D(f, xlin, ylin)
The output array is apparently oriented towards the diagonal of the resulting grid, while it should rather return an array that looks like a blurry input array.
source
share