#ex 3
# Df = ang(H(Zc)) = Vc(t)/Vs(t) = I Zc / I Zs = 1/iwC / 1/iwC +R = 1 / 1+ jRCw = atan(-wRC)
R=var("R")
C = 10**(-6)
w = 1000*pi
Dfc(R) = atan(w*R*C )
Dfr(R) = atan(1/(w*R*C))
#ex 4
f = open(DATA+"dataC","r")
b1 = [float(x) for x in f.readline().split()]
a1 = [float(x) for x in f.readline().split()]
Dt1 = [float(x) for x in f.readline().split()]
f.close()
f = open(DATA+"dataR","r")
b2 = [float(x) for x in f.readline().split()]
a2 = [float(x) for x in f.readline().split()]
Dt2 = [float(x) for x in f.readline().split()]
f.close()
Df1_atan = [( (x+1)*100,atan(a1[x]/b1[x]) ) for x in range(10)]
Df2_atan = [( (x+1)*100,atan(a2[x]/b2[x])) for x in range(10)]
Df1_t = [ ( (x+1)*100, w*Dt1[x]*10**(-3)) for x in range(10)]
Df2_t = [ ( (x+1)*100, w*Dt2[x]*10**(-3)) for x in range(10)]
Plot1 = plot(Dfc(R) , (0, 1200), color = 'black', legend_label = "$theoretical$") + line(Df1_atan, color = 'red', legend_label = "$\\arctan (\\frac{\\alpha}{\\beta})$") + line(Df1_t, color = 'blue', legend_label = "$\\omega \\, \\Delta t$")
Plot1.axes_labels(["$\\Omega$","$rad$"])
Plot1.show()
Plot2 = plot(Dfr(R) , (0, 1200), color = 'black', legend_label = "$theoretical$") + line(Df2_atan, color = 'red', legend_label = "$\\arctan (\\frac{\\alpha}{\\beta})$") + line(Df2_t, color = 'blue', legend_label = "$\\omega \\, \\Delta t$")
Plot1.axes_labels(["$\\Omega$","$rad$"])
Plot2.show()