Added plot
This commit is contained in:
parent
d01c15da27
commit
6c9e2656a9
BIN
3.2.5/U(mu).png
Normal file
BIN
3.2.5/U(mu).png
Normal file
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
49
3.2.5/laba.py
Normal file
49
3.2.5/laba.py
Normal file
@ -0,0 +1,49 @@
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
import csv
|
||||
|
||||
|
||||
def main():
|
||||
plot2(open_CSV('R=0.csv'), open_CSV('R=100.csv'))
|
||||
|
||||
|
||||
def open_CSV(filename):
|
||||
with open('/home/dmitrii/Physics Labs/3.2.5/' + filename, newline="") as csvfile:
|
||||
datareader = csv.reader(csvfile, delimiter=",", quotechar="|")
|
||||
data = []
|
||||
for row in datareader:
|
||||
res = [float(i) for i in row]
|
||||
data.append(res)
|
||||
data = np.array(data)
|
||||
return data
|
||||
|
||||
|
||||
def plot2(data1, data2):
|
||||
U_1 = max(data1[:, 0])
|
||||
U_2 = max(data2[:, 0])
|
||||
print(U_1, U_2)
|
||||
fig, ax = plt.subplots()
|
||||
y1 = data1[:, 0]/U_1
|
||||
x1 = data1[:, 1]/1550
|
||||
y2 = data2[:, 0]/U_2
|
||||
x2 = data2[:, 1]/1558
|
||||
ax.scatter(x1, y1, color='green', label='0 Ом', marker='+', s=150)
|
||||
ax.scatter(x2, y2, color='orange', label='100 Oм', marker='+', s=150)
|
||||
ax.legend(fontsize=16)
|
||||
ax.grid()
|
||||
plt.ylabel(r'$U/U_{m}$', fontsize=18)
|
||||
plt.xlabel(r'$\nu/\nu_{m}$', fontsize=18)
|
||||
ar1 = sorted(data1[:, 1])
|
||||
ar2 = sorted(data2[:, 1])
|
||||
plt.show()
|
||||
delta1 = ar1[len(data1)-1] - ar1[0]
|
||||
delta2 = ar2[len(data2)-1]-ar2[0]
|
||||
Q1 = 1550/63
|
||||
Q2 = 1550/220
|
||||
print(Q1, Q2)
|
||||
|
||||
|
||||
# def plot(data):
|
||||
# x1=
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in New Issue
Block a user