I have a data set of 363 x 190 y-points with the corresponding functional value, which I would like to integrate into several different subregions. I tried to create a SciPy function interp2dfor integration; however, the creation of this function even with linear interpolation took more than 2 hours (and not yet done) .
What is better for this task?
Some snippets below ...
In the function convert_RT_to_XYimb / jmb below , these are the borders of r, theta grids, which I convert to Cartesian borders.
Later, in my code, I convert the grid borders (imb / jmb) to the grid center values (imm, jmm), convert to vectors (iX, iY), convert my function to vector (iZ), and then try to make my interpolation function .
def convert_RT_to_XY(imb, jmb):
R, T = np.meshgrid(imb,jmb)
X = R * np.cos(np.radians(T*360))
Y = R * np.sin(np.radians(T*360))
return(X, Y)
...
imm = imb[:-1]+np.divide(np.diff(imb),2)
jmm = jmb[:-1]+np.divide(np.diff(jmb),2)
iX, iY = convert_RT_to_XY(imm, jmm)
iX = np.ndarray.flatten(iX)
iY = np.ndarray.flatten(iY)
iZ = np.ndarray.flatten(plot_function)
f = interpolate.interp2d(iX, iY, iZ, kind='linear')
Ultimately, I want to do:
result = dblquad(f, 10, 30,
lambda x: 10,
lambda x: 30))