title: How to make scipy.interpolate give an extrapolated result beyond the input range?
body: <p>I'm trying to port a program which uses a hand-rolled interpolator (developed by a mathematician colleage) over to use the interpolators provided by scipy. I'd like to use or wrap the scipy interpolator so that it has as close as possible behavior to the old interpolator.</p>
  
  <p>A key difference between the two functions is that in our original interpolator - if the input value is above or below the input range, our original interpolator will extrapolate the result. If you try this with the scipy interpolator it raises a <code>ValueError</code>. Consider this program as an example:</p>
  
  <pre><code>import numpy as np
  from scipy import interpolate
  
  x = np.arange(0,10)
  y = np.exp(-x/3.0)
  f = interpolate.interp1d(x, y)
  
  print f(9)
  print f(11) # Causes ValueError, because it's greater than max(x)
  </code></pre>
  
  <p>Is there a sensible way to make it so that instead of crashing, the final line will simply do a linear extrapolate, continuing the gradients defined by the first and last two points to infinity. </p>
  
  <p>Note, that in the real software I'm not actually using the exp function - that's here for illustration only!</p>