test for part 2 added, minor ui changes
This commit is contained in:
parent
d6f8f6f13f
commit
46b5845387
@ -1,6 +1,8 @@
|
||||
import matplotlib.pyplot as plt
|
||||
import random
|
||||
|
||||
from numpy import tanh
|
||||
|
||||
|
||||
def get_point(part, num):
|
||||
if part == 1:
|
||||
@ -38,8 +40,13 @@ def get_point(part, num):
|
||||
vol[2][num].append(random.random() * 100)
|
||||
cur[2][num].append(random.random() * 100)
|
||||
elif part == 4:
|
||||
vol[3][num].append(random.random() * 100)
|
||||
cur[3][num].append(random.random() * 100)
|
||||
vol[3][num].append(random.random() * 50 - 25)
|
||||
if experiment % 3 == 0:
|
||||
cur[3][num].append((83 * tanh(15.5 / 83 * vol[3][num][-1]) + 1.7 * vol[3][num][-1]) * (0.98 + random.random() / 25))
|
||||
elif experiment % 3 == 1:
|
||||
cur[3][num].append((44 * tanh(8.7 / 44 * vol[3][num][-1]) + 0.9 * vol[3][num][-1]) * (0.98 + random.random() / 25))
|
||||
else:
|
||||
cur[3][num].append((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):
|
||||
@ -48,8 +55,10 @@ def update_plot(part, num):
|
||||
def saveplot(part):
|
||||
plt.figure(figsize=(8, 6))
|
||||
for i in range(len(vol[part - 1])):
|
||||
plt.scatter(cur[part - 1][i], vol[part - 1][i], marker='o')
|
||||
plt.scatter(vol[part - 1][i], cur[part - 1][i], marker='o')
|
||||
plt.grid()
|
||||
plt.xlabel('Напряжение, В')
|
||||
plt.ylabel('Ток, мкА')
|
||||
plt.savefig('tmpplots/tmpplot' + str(part) + '.jpg', dpi=200)
|
||||
plt.close()
|
||||
|
||||
@ -63,12 +72,18 @@ def empty_plot(part):
|
||||
plt.close()
|
||||
|
||||
def plus_plot(part):
|
||||
global experiment
|
||||
vol[part - 1].append([])
|
||||
cur[part - 1].append([])
|
||||
experiment += 1
|
||||
|
||||
def minus_plot(part):
|
||||
vol[part - 1].pop()
|
||||
cur[part - 1].pop()
|
||||
if len(vol[part - 1]) == 0:
|
||||
vol[part - 1].append([])
|
||||
cur[part - 1].append([])
|
||||
|
||||
vol = [[], [], [[]], [[]]]
|
||||
cur = [[], [], [[]], [[]]]
|
||||
cur = [[], [], [[]], [[]]]
|
||||
experiment = 0
|
@ -216,6 +216,7 @@ class Part2(QtWidgets.QWidget):
|
||||
super().__init__()
|
||||
self.n = 0
|
||||
self.num = 0
|
||||
self.i = 0
|
||||
self.hint_open = False
|
||||
self.started = False
|
||||
self.q = QtGui.QScreen.availableGeometry(QtWidgets.QApplication.primaryScreen())
|
||||
@ -230,6 +231,11 @@ class Part2(QtWidgets.QWidget):
|
||||
self.points.setGeometry(QtCore.QRect(7.5 * h - 150, 3 * h - 80, 300, 20))
|
||||
self.points.setText('Измеренных точек в текущей серии: ' + str(self.n))
|
||||
|
||||
self.current = QtWidgets.QLabel(self)
|
||||
self.current.setGeometry(QtCore.QRect(7.5 * h - 150, 3 * h - 120, 300, 20))
|
||||
self.current.setText('Текущий ток разряда: ' + str(self.i))
|
||||
self.current.setStyleSheet('color: green;')
|
||||
|
||||
self.disclaimer = QtWidgets.QLabel(self)
|
||||
self.disclaimer.setText('<html><p align=\"left\"><span style=\" font-size:10pt; font-weight:600;\">Не '
|
||||
'забудьте прочитать методику<\p><p align=\"left\"><span style=\" font-size:10pt; '
|
||||
@ -298,14 +304,27 @@ class Part2(QtWidgets.QWidget):
|
||||
self.start_btn.clicked.connect(self.start_stop)
|
||||
self.delete_btn.clicked.connect(self.delete)
|
||||
self.hint_btn.clicked.connect(self.hint)
|
||||
self.save_btn.clicked.connect(self.savefile)
|
||||
self.save_btn.clicked.connect(self.save_file)
|
||||
|
||||
timer = QtCore.QTimer(self)
|
||||
timer.timeout.connect(self.upd_plot)
|
||||
timer.start(500)
|
||||
|
||||
timer2 = QtCore.QTimer(self)
|
||||
timer2.timeout.connect(self.cur_check)
|
||||
timer2.start(1000)
|
||||
|
||||
@QtCore.Slot()
|
||||
def savefile(self):
|
||||
def cur_check(self):
|
||||
if plots.experiment % 3 == 0:
|
||||
self.i = 5
|
||||
elif plots.experiment % 3 == 1:
|
||||
self.i = 3
|
||||
else:
|
||||
self.i = 1.5
|
||||
self.current.setText('Текущий ток разряда: ' + str(self.i) + 'мА')
|
||||
|
||||
def save_file(self):
|
||||
file, check = QtWidgets.QFileDialog.getSaveFileName(None, "Сохранить график 2",
|
||||
r"C:\Users\Vadim\Desktop\plot2.jpg", "Images (*.png *.jpg)")
|
||||
if check:
|
||||
|
Loading…
Reference in New Issue
Block a user