I've been trying for hours to fit a sine wave to this data with no success. The bit I'm finding difficult is that there isn't a full wavelength and so only a portion of the sine wave is shown. Here is the data I have:
ydata = vel-mean_vel
xdata = np.linspace(min(phase), max(phase), 9)
def func(x, a, b):
return a*np.sin((x*2*np.pi)*b)
popt, pcov = curve_fit(func, xdata, ydata,p0=(-154.52782708, 126.52963958))
print(popt)
#plotting
plt.figure(figsize=[7,7])
plt.plot(phase, ydata, '.')
plt.plot(xdata, func(xdata, popt[0], popt[1]), color = 'red')
I'd appreciate any help at all :)