0

I'm making the following call to interp2d

f = interpolate.interp2d(im_xs, im_ys, I)

Here are the dimensions of each of the arguments

im_xs: (120, )

im_ys: (120, )

I: (120, 160)

I would like to pass f a vector of x values and a vector of y values and I expect to get a single dimension output vector containing len(x) == len(y) interpolated values.

values = f(rr, cc)

where

rr: (1332, )

cc: (1332, )

However...

values: (1332, 1332)

I expected to just get a vector of 1332 values because I want to interpolate exactly 1332 coordinates on a 2D grid I.

Carpetfizz
  • 8,707
  • 22
  • 85
  • 146
  • 1
    Possible duplicate of [Evaluate the output from scipy 2D interpolation along a curve](https://stackoverflow.com/questions/47087109/evaluate-the-output-from-scipy-2d-interpolation-along-a-curve) –  Oct 18 '18 at 02:31
  • Thanks, but I get the following error when I run the correct answer. `ValueError: failed to create intent(cache|hide)|optional array-- must have defined dimensions but got (0,)` – Carpetfizz Oct 18 '18 at 06:16
  • I tested it again, in SciPy 1.1.0 and 0.19.1. Worked fine. A complete example: `import scipy.interpolate as si; import numpy as np; x = np.arange(120)/2; y = np.arange(120)/3; z = np.add.outer(np.sin(x), np.cos(y)); f = si.interp2d(x, y, z); xx = np.random.uniform(60, size=100); yy = np.random.uniform(40, size=100); si.dfitpack.bispeu(f.tck[0], f.tck[1], f.tck[2], f.tck[3], f.tck[4], xx, yy)[0]` –  Oct 18 '18 at 13:38

0 Answers0