I have a 4 dimensional array of data of shape A = (X, Y, Z, Q) and I'd like to interpolate to position (x, y, z) for each value of Q, i.e. end up with an array of length Q.
I've been using scipy.interpolate.RegularGridInterpolator to do this on a q-by-q basis like so:
Q = np.zeros(A.shape[-1])
for q in range(len(Q)):
interp_f = RegularGridInterpolator([X,Y,Z], A[:,:,:,q])
v, = interp_f(np.array([x,y,z]))
Q[q] = v
And this works fine but it takes about 2 minutes to run since my typical dimensions of A are (10, 10, 3, 25000).
Is there a (much) faster way of doing this?
I'd REALLY like to do a cubic spline interpolation in 3D instead of linear interpolation but can't find any resource for 3+ dimensional data.
Thanks!