Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. import matplotlib.pylab as mp
  2. import pandas as pd
  3. from lmfit import minimize, Parameters, report_fit
  4.  
  5. #path = "/Users/paulgauthier/Documents/Postdoc/Princeton/Results/Vo_Calculations/For LmFit MichMenten.csv"
  6. # x=np.linspace(-100,300,500)
  7. data = pd.read_csv( path )
  8. y = data[0.037849903,0.033348401,0.025744915,0.018811544,0.015011589,0.011411627,0.008685033 -0.000378251,0]
  9. x = data[1,0.5,0.25,0.125,0.0625,0.03125,0.015625,0.0078125,0]
  10.  
  11.  
  12. def res(params, x, y):
  13. Vmax = params['Vmax'].value
  14. Km = params['Km'].value
  15. model = Vmax * x / (Km + x)
  16. return model - y
  17.  
  18.  
  19. params = Parameters( )
  20. params.add( 'Vmax', value=15 )
  21. params.add( 'Km', value=200 )
  22.  
  23. result = minimize( res, params, args=(x, y) )
  24. final = y + result.residual
  25. report_fit( params )
  26.  
  27. Vmax = params['Vmax'].value
  28. Km = params['Km'].value
  29. data['fitted'] = Vmax * x / (Km + x)
  30. data.to_csv( path )
  31. fitted = data['fitted']
  32.  
  33. mp.plot( x, y, 'k', label='Raw' )
  34. mp.plot( x, final, 'r', label='final' )
  35. mp.plot( x, fitted, 'r', label='fitted' )
  36. mp.legend( loc=4 )
  37. mp.xlabel( 'Light intensity', fontsize=16 )
  38. mp.ylabel( 'Net Oxygen Prodcution (umol m-2 s-1)', fontsize=16 )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement