'**SUMMARY**
Fit the data to the provided model. This can be any arbitrary
2D signal. Return the data of the model scaled to the data.
**PARAMETERS**
* *f* - a function of the form f(x_values, p0,p1, ... pn) where
p is parameter for the model.
* *p0* - a list of the initial guess for the model parameters.
**RETURNS**
A LineScan object where the fitted model data replaces the
actual data.
**EXAMPLE**
>>>> def aLine(x,m,b):
>>>>     return m*x+b
>>>> import matplotlib.pyplot as plt
>>>> img = Image(\'lenna\')
>>>> sl = img.getLineScan(y=128)
>>>> fit = sl.fitToModel(aLine)
>>>> plt.plot(sl)
>>>> plt.plot(fit)
>>>> plt.show()'

def fitToModel(self, f, p0=None):

    yvals = np.array(self, dtype='float32')
    xvals = range(0, len(yvals), 1)
    (popt, pcov) = spo.curve_fit(f, xvals, yvals, p0=p0)
    yvals = f(xvals, *popt)
    retVal = LineScan(list(yvals), image=self.image, pointLoc=self.pointLoc, pt1=self.pt1, pt2=self.pt2)
    retVal._update(self)
    return retVal
