2

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!

Joe Flip
  • 1,076
  • 4
  • 21
  • 37
  • This post has a pretty good answer to your question: http://stackoverflow.com/questions/32753449/what-to-do-if-i-want-3d-spline-smooth-interpolation-of-random-unstructured-data – jakevdp Apr 11 '17 at 05:22
  • Yes, I looked at Rbf() but it requires that all axes be the same length. I am dealing with regular gridded data but the shape is not symmetric. Or did I misunderstand how to use Rbf? Thanks @jakevdp ! – Joe Flip Apr 12 '17 at 13:34

0 Answers0