title: Best way to interpolate a numpy.ndarray along an axis
body: <p>I have 4-dimensional data, say for the temperature, in an <code>numpy.ndarray</code>. 
  The shape of the array is <code>(ntime, nheight_in, nlat, nlon)</code>.</p>
  
  <p>I have corresponding 1D arrays for each of the dimensions that tell me which time, height, latitude, and longitude a certain value corresponds to, for this example I need <code>height_in</code> giving the height in metres.</p>
  
  <p>Now I need to bring it onto a different height dimension, <code>height_out</code>, with a different length.</p>
  
  <p>The following seems to do what I want:</p>
  
  <pre><code>ntime, nheight_in, nlat, nlon = t_in.shape
  
  nheight_out = len(height_out)
  t_out = np.empty((ntime, nheight_out, nlat, nlon))
  
  for time in range(ntime):
      for lat in range(nlat):
          for lon in range(nlon):
              t_out[time, :, lat, lon] = np.interp(
                  height_out, height_in, t[time, :, lat, lon]
              )
  </code></pre>
  
  <p>But with 3 nested loops, and lots of switching between python and numpy, I don't think this is the best way to do it.</p>
  
  <p>Any suggestions on how to improve this? Thanks</p>