Advertisement
Guest User

Untitled

a guest
Oct 20th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. data = np.loadtxt("precession_GR.dat")
  2. convert = 3600*180/np.pi
  3.  
  4. alength = len(data[:,0])
  5. x = data[:,0]
  6. y = data[:,1]
  7. t = np.linspace(0, 100, alength)
  8.  
  9. arcsecs = np.zeros(alength)
  10. for i in range(alength):
  11. arcsecs[i] = np.arctan(y[i]/x[i])*convert
  12.  
  13.  
  14. p = np.polyfit(t, arcsecs, 1)
  15.  
  16. b = p[0]
  17. m = p[1]
  18. yline = np.polyval(p, t)
  19. print yline[-1] - yline[0]
  20.  
  21.  
  22. plt.plot(t, arcsecs)
  23. plt.plot(t, yline)
  24. plt.xlabel("Time [years]")
  25. plt.ylabel("Seconds of arc")
  26. plt.legend(["Data points", "Fitted line"])
  27. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement