I'm trying to fit some data to a nernst curve, but the fitted line has odd angles that don't fit either the data or the equation. Do you know why this is?
csv_file='031109twohemesplit.csv'
data = pd.read_csv(csv_file)
Eh=data['Eh']
Fracred=data['frac red']
tmp_Fracred=Fracred-Fracred.min()
normFracred = tmp_Fracred / tmp_Fracred.max()
plt.scatter(Eh,normFracred)
def twopot(Eh, Em1, Em2, z):
return 0.5/(10**((Eh-Em1)/(8.14*275.15/(1*96.485)))+z)+0.5/(10**((Eh-Em2)/(8.14*275.15/(1*96.485)))+z)
guess=[-250,-325, 1]
popt, pcov=curve_fit(twopot,Eh,normFracred,guess,method='dogbox')
print(popt)
plt.plot(Eh,twopot(Eh,*popt), label='fitted')
It yields this: