title: Linear interpolation of 3D data in python
body: <p>I am trying to do linear interpolation of automatically generated data from software, which should be the function of x,y,z but I am getting following error: </p>
  
  <pre><code>Traceback (most recent call last):
    File "trajectory_cartesian.py", line 67, in &lt;module&gt;
      interpolating_function_Ex = RegularGridInterpolator((x, y, z), Ex1)
    File "/anaconda2/lib/python2.7/site-packages/scipy/interpolate/interpolate.py", line 2418, in __init__
      "dimensions" % (len(points), values.ndim))
  ValueError: There are 3 point arrays, but values has 1 dimensions
  </code></pre>
  
  <p>I have following code:</p>
  
  <pre><code>import numpy as np
  from scipy.interpolate import RegularGridInterpolator
  
  
  #sample array for field components
  Ex1 = [8.84138516e+01 8.84138516e+01 7.77498363e+01 5.77080432e+01]
  Ey1 = [1.54844696e+02  1.54844696e+02  1.36168141e+02  1.01067698e+02]
  Ez1 = [-2.45922135e+03 -2.45922135e+03 -2.45922135e+03 -2.45922135e+03]
  
  
  
  
  
  #sample array for position
  x = [1.94871844   5.61111111   8.59672097  10.54543941]
  y = [8.84138516e+01 8.84138516e+01 7.77498363e+01 5.77080432e+01]
  z = [30.55555556  30.55555556  30.55555556  30.55555556]
  
  
  
  #linear interpolation for Ex, Ey and Ez
  
  interpolating_function_Ex = RegularGridInterpolator((x, y, z), Ex1)
  interpolating_function_Ey = RegularGridInterpolator((x, y, z), Ey1)
  interpolating_function_Ez = RegularGridInterpolator((x, y, z), Ez1)
  
  #array for new points
  x1 = np.linspace(0, 31, 1000)
  y1 = np.linspace(0, 10, 1000)
  z1 = np.linspace(0, 10, 1000)
  
  X = np.dstack((x1,y1,z1))
  points = np.array(X)
  
  fEx = interpolating_function_Ex(points)
  fEy = interpolating_function_Ey(points)
  fEz = interpolating_function_Ez(points)
  print fEx, fEy, fEz
  </code></pre>
  
  <p>The data are automatically generated so , I don't know how to define the function w.r.t. x, y, z. Is there any mistake in my method? Can I do linear interpolation of data without defining the function? Thanks in advance!</p>