code: def _extrap1d(interpolator):
      
      xs, ys = interpolator.x, interpolator.y
  
      def pointwise(x):
          if x < xs[0]:
              return ys[0] + (x - xs[0]) * (ys[1] - ys[0]) / (xs[1] - xs[0])
          elif x > xs[-1]:
              return ys[-1] + (x - xs[-1]) * (ys[-1] - ys[-2]) / (
                  xs[-1] - xs[-2]
              )
          else:
              return interpolator(x)
  
      def ufunclike(xs):
          return np.array(list(map(pointwise, np.array(xs))))
  
      return ufunclike
docs: http://stackoverflow.com/questions/2745329/
      How to make scipy.interpolate return an extrapolated result beyond the
      input range.