part 1 measurements available
This commit is contained in:
+46
-43
@@ -1,46 +1,50 @@
|
||||
import matplotlib.pyplot as plt
|
||||
import random
|
||||
import voltmeter
|
||||
import amperemeter
|
||||
|
||||
from numpy import tanh
|
||||
|
||||
|
||||
# Значения part = 1, 2 соответствуют режимам считывания с первой и второй пары приборов соответственно
|
||||
# (currently not available), режимы 3 и 4 являются тестовыми и генерируют значения самостоятельно
|
||||
def get_point(part, num):
|
||||
# Значения part = 1, 2 соответствуют режимам считывания с первой и второй пары приборов соответственно,
|
||||
# режимы 3 и 4 являются тестовыми и генерируют значения самостоятельно
|
||||
|
||||
def start_measure(part):
|
||||
if part == 1:
|
||||
v1 = open('voltmeter1.txt')
|
||||
i1 = open('ampere-meter1.txt')
|
||||
vol[0].append(float(v1.readline()))
|
||||
cur[0].append(float(i1.readline()))
|
||||
newv1 = v1.read().replace(str(vol[0][-1]) + '\n', '')
|
||||
newi1 = i1.read().replace(str(cur[0][-1]) + '\n', '')
|
||||
v1.close()
|
||||
i1.close()
|
||||
v1 = open('voltmeter1.txt', 'w')
|
||||
v1.write(newv1)
|
||||
i1 = open('ampere-meter1.txt', 'w')
|
||||
i1.write(newi1)
|
||||
v1.close()
|
||||
i1.close()
|
||||
global v1, i1
|
||||
v1 = voltmeter.AKIP('/dev/usbtmc0')
|
||||
i1 = amperemeter.B7_78('/dev/ttyUSB0')
|
||||
i1.getCurrentDC()
|
||||
|
||||
elif part == 2:
|
||||
v2 = open('voltmeter2.txt')
|
||||
i2 = open('ampere-meter2.txt')
|
||||
vol[1].append(float(v2.readline()))
|
||||
cur[1].append(float(i2.readline()))
|
||||
newv2 = v2.read().replace(str(vol[1][-1]) + '\n', '')
|
||||
newi2 = i2.read().replace(str(cur[1][-1]) + '\n', '')
|
||||
v2.close()
|
||||
i2.close()
|
||||
v2 = open('voltmeter2.txt', 'w')
|
||||
v2.write(newv2)
|
||||
i2 = open('ampere-meter2.txt', 'w')
|
||||
i2.write(newi2)
|
||||
v2.close()
|
||||
i2.close()
|
||||
global v2, i2
|
||||
v2 = voltmeter.AKIP('/dev/usbtmc0')
|
||||
i2 = amperemeter.B7_78('/dev/ttyUSB1')
|
||||
i2.getCurrentDC()
|
||||
|
||||
elif part == 0:
|
||||
global i
|
||||
ir = amperemeter.B7_78('/dev/ttyUSB0')
|
||||
i = float(ir.getCurrentDC()) * 10 ** 3
|
||||
i = float(ir.getCurrentDC()) * 10 ** 3
|
||||
|
||||
|
||||
def get_point(part, num):
|
||||
if part == 1:
|
||||
vol[0][num].append(v1.getVoltageDC())
|
||||
cur[0][num].append(i1.getCurrentDC() * 10 ** 3)
|
||||
|
||||
elif part == 2:
|
||||
# global i
|
||||
vol[1][num].append(v2.getVoltageDC())
|
||||
cur[1][num].append(i2.getCurrentDC() * 10 ** 6)
|
||||
# i = amperemeter.B7_78('/dev/ttyUSB0').getCurrentDC() * 10 ** 3
|
||||
# print(vol[1], cur[1])
|
||||
|
||||
elif part == 3:
|
||||
vol[2][num].append(random.random() * 100)
|
||||
cur[2][num].append(random.random() * 100)
|
||||
|
||||
elif part == 4:
|
||||
vol[3][num].append(random.random() * 50 - 25)
|
||||
if experiment % 3 == 0:
|
||||
@@ -54,18 +58,17 @@ def get_point(part, num):
|
||||
(22 * tanh(4.4 / 22 * vol[3][num][-1]) + 0.5 * vol[3][num][-1]) * (0.98 + random.random() / 25))
|
||||
|
||||
|
||||
def update_plot(part, num):
|
||||
for i in range(10):
|
||||
get_point(part, num)
|
||||
|
||||
|
||||
def saveplot(part):
|
||||
plt.figure(figsize=(8, 6))
|
||||
for i in range(len(vol[part - 1])):
|
||||
plt.scatter(vol[part - 1][i], cur[part - 1][i], marker='o')
|
||||
for j in range(len(vol[part - 1])):
|
||||
# print(vol[part - 1][j], cur[part - 1][j])
|
||||
plt.scatter(vol[part - 1][j], cur[part - 1][j], marker='o')
|
||||
plt.grid()
|
||||
plt.xlabel('Напряжение, В')
|
||||
plt.ylabel('Ток, мкА')
|
||||
if part == 1:
|
||||
plt.ylabel('Ток, мА')
|
||||
else:
|
||||
plt.ylabel('Ток, мкА')
|
||||
plt.savefig('tmpplots/tmpplot' + str(part) + '.jpg', dpi=200)
|
||||
plt.close()
|
||||
|
||||
@@ -74,7 +77,7 @@ def empty_plot(part):
|
||||
vol[part - 1] = [[]]
|
||||
cur[part - 1] = [[]]
|
||||
plt.figure(figsize=(8, 6))
|
||||
plt.scatter(cur[part - 1], vol[part - 1], marker='o')
|
||||
plt.scatter(cur[part - 1][0], vol[part - 1][0], marker='o')
|
||||
plt.grid()
|
||||
plt.savefig('tmpplots/tmpplot' + str(part) + '.jpg', dpi=200)
|
||||
plt.close()
|
||||
@@ -94,7 +97,7 @@ def minus_plot(part):
|
||||
vol[part - 1].append([])
|
||||
cur[part - 1].append([])
|
||||
|
||||
|
||||
vol = [[], [], [[]], [[]]]
|
||||
cur = [[], [], [[]], [[]]]
|
||||
i = 0
|
||||
vol = [[[]], [[]], [[]], [[]]]
|
||||
cur = [[[]], [[]], [[]], [[]]]
|
||||
experiment = 0
|
||||
|
||||