def evaluate(self,       x, derivative=<NUM_LIT:0>, smooth=<NUM_LIT:0>, simple='<STR_LIT>'):
if simple=='<STR_LIT>': simple = self.simple<EOL>is_array = True<EOL>if not type(x) == type(_pylab.array([])):<EOL><INDENT>x = _pylab.array([x])              <EOL>is_array = False<EOL><DEDENT>if simple:<EOL><INDENT>y = []<EOL>for n in range(<NUM_LIT:0>, len(x)):<EOL><INDENT>if smooth:<EOL><INDENT>[xtemp, ytemp, etemp] = _fun.trim_data(self.xdata, self.ydata, None, [x[n]-smooth, x[n]+smooth])<EOL><DEDENT>else:<EOL><INDENT>i1 = _fun.index_nearest(x[n], self.xdata)<EOL>if self.xdata[i1] <= x[n] or i1 <= <NUM_LIT:0>: i2 = i1+<NUM_LIT:1><EOL>else:                                 i2 = i1-<NUM_LIT:1><EOL>if i2 >= len(self.xdata):<EOL><INDENT>print(x[n], "<STR_LIT>")<EOL>i2 = i1-<NUM_LIT:1><EOL><DEDENT>x1 = self.xdata[i1]<EOL>y1 = self.ydata[i1]<EOL>x2 = self.xdata[i2]<EOL>y2 = self.ydata[i2]<EOL>slope = (y2-y1)/(x2-x1)<EOL>xtemp = _numpy.array([x[n]])<EOL>ytemp = _numpy.array([y1 + (x[n]-x1)*slope])<EOL><DEDENT>if derivative == <NUM_LIT:1>:<EOL><INDENT>if smooth:<EOL><INDENT>y.append((_numpy.average(xtemp*ytemp)-_numpy.average(xtemp)*_numpy.average(ytemp)) /<EOL>(_numpy.average(xtemp*xtemp)-_numpy.average(xtemp)**<NUM_LIT:2>))<EOL><DEDENT>else:<EOL><INDENT>y.append(slope)<EOL><DEDENT><DEDENT>elif derivative==<NUM_LIT:0>:<EOL><INDENT>y.append(_numpy.average(ytemp))<EOL><DEDENT><DEDENT>if is_array: return _numpy.array(y)<EOL>else:        return y[<NUM_LIT:0>]<EOL><DEDENT>if smooth:<EOL><INDENT>y = []<EOL>for n in range(<NUM_LIT:0>, len(x)):<EOL><INDENT>xlow = max(self.xmin,x[n]-smooth)<EOL>xhi  = min(self.xmax,x[n]+smooth)<EOL>xdata = _pylab.linspace(xlow, xhi, <NUM_LIT:20>)<EOL>ydata = _interpolate.splev(xdata, self.pfit, derivative)<EOL>y.append(_numpy.average(ydata))<EOL><DEDENT>if is_array: return _numpy.array(y)<EOL>else:        return y[<NUM_LIT:0>]<EOL><DEDENT>else:       <EOL><INDENT>return _interpolate.splev(x, self.pfit, derivative)<EOL><DEDENT>
smooth=0      is how much to smooth the spline data
simple='auto' is whether we should just use straight interpolation
              you may want smooth > 0 for this, when derivative=1