Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data = np.loadtxt("precession_GR.dat")
- convert = 3600*180/np.pi
- alength = len(data[:,0])
- x = data[:,0]
- y = data[:,1]
- t = np.linspace(0, 100, alength)
- arcsecs = np.zeros(alength)
- for i in range(alength):
- arcsecs[i] = np.arctan(y[i]/x[i])*convert
- p = np.polyfit(t, arcsecs, 1)
- b = p[0]
- m = p[1]
- yline = np.polyval(p, t)
- print yline[-1] - yline[0]
- plt.plot(t, arcsecs)
- plt.plot(t, yline)
- plt.xlabel("Time [years]")
- plt.ylabel("Seconds of arc")
- plt.legend(["Data points", "Fitted line"])
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement