-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspatcc.py
94 lines (73 loc) · 2.96 KB
/
spatcc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
__author__ = 'Toni'
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from main_w import Ui_MainWindow
from trasmission import Trasmission
from cromatogram import Cromatogram
from model import Model
import numpy as np
import numpy.random as rnd
# Some experiments constants
DEFAULT_CONCENTRATION = 10
try:
_fromUtf8 = QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QApplication.translate(context, text, disambig)
class Main(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
# Load the process image of the main window
proc_img = QPixmap("./images/process_img.png").scaledToWidth(300)
self.ui.lb_proc_img.setPixmap(proc_img)
self.adjustTable()
# Connect the events to keep the configuration settings
# updated
self.ui.sb_num_analites.valueChanged.connect(self.adjustTable)
self.ui.pb_trasmission.clicked.connect(self.go_to_transmission)
self.ui.pb_crom.clicked.connect(self.go_to_cromatogram)
# self.ui.tbw_analites_info.itemPressed.connect(self.initKs)
def adjustTable(self):
n = self.ui.sb_num_analites.value()
self.ui.tbw_analites_info.setRowCount(n)
for i in np.arange(n):
self.ui.tbw_analites_info.setItem(i, 0, QTableWidgetItem(str(chr(65 + i))))
self.ui.tbw_analites_info.setItem(i, 1, QTableWidgetItem(str(round(rnd.rand(), 3) * DEFAULT_CONCENTRATION)))
self.ui.tbw_analites_info.setItem(i, 2, QTableWidgetItem(str(75 + round(rnd.rand(), 3) * 50)))
def collect_model(self):
# Collect the configuration of the model to simulate
ideal = self.ui.rb_eluc_isoc.isChecked()
num_analites = self.ui.sb_num_analites.value()
num_teo_plates = self.ui.sb_teo_plates.value()
max_iters = self.ui.sb_num_iter.value()
conc_init = np.zeros(num_analites)
ks_analites = np.zeros(num_analites)
for i in np.arange(num_analites):
ks_analites[i] = float(self.ui.tbw_analites_info.item(i, 1).text())
conc_init[i] = float(self.ui.tbw_analites_info.item(i, 2).text())
return Model(num_analites, num_teo_plates, max_iters, conc_init, ks_analites, ideal)
def go_to_transmission(self):
tras_model = self.collect_model()
tw = Trasmission(self, tras_model)
tw.show()
def go_to_cromatogram(self):
crom_model = self.collect_model()
cw = Cromatogram(self, crom_model)
cw.show()
if __name__ == '__main__':
import sys
from PyQt4 import QtGui
app = QtGui.QApplication(sys.argv)
main = Main()
main.show()
sys.exit(app.exec_())