code: def extrap1d(interpolator):
      
      
      xs = interpolator.x
      ys = 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 N.array(map(pointwise, N.array(xs)))
  
      return ufunclike
docs: Function to extend an interpolation function to an
      extrapolation function.
  
      :param interpolator: scipy interp1d object
  
      :returns ufunclike: extension of function to extrapolation