-
Notifications
You must be signed in to change notification settings - Fork 0
/
import_widget.py
63 lines (54 loc) · 2.07 KB
/
import_widget.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
from PySide6.QtCore import QDir
from PySide6.QtWidgets import (QFrame, QFileDialog, QMessageBox)
from PySide6.QtCore import (Slot, Signal)
from auc_data_io import AucRawData
import gui_import
import data_models as dms
class ImportWidget(QFrame, gui_import.Ui_Frame):
sig_new_file = Signal(object)
def __init__(self, parent=None):
super().__init__(parent=parent)
self.setupUi(self)
self.temperature = None
self.rpm = None
self.wavelength = None
self.pb_open.clicked.connect(self.slt_open)
@Slot(object)
def slt_open(self):
home_dir = QDir.homePath()
dialog_output = QFileDialog.getOpenFileName(self, "Open AUC File", home_dir, "(*.auc)")
file_name = dialog_output[0]
if len(file_name) == 0:
return
auc_data = AucRawData()
state = auc_data.read(file_name)
if not state:
msg = f"The following file is not readable by this program:\n{file_name}"
QMessageBox.warning(self, "Warning!", msg)
return
self.le_desc.setText(auc_data.description)
self.le_type.setText(auc_data.type)
self.le_cell.setText(str(auc_data.cell))
self.le_chan.setText(auc_data.channel)
self.temperature = auc_data.temperature
self.rpm = auc_data.rpm
self.wavelength = auc_data.wavelength
x_values = auc_data.xvalues
y_values = auc_data.rvalues
n_scans = len(y_values)
all_data_models = []
for i in range(n_scans):
data = dms.Data()
data.set_raw(x_values, y_values[i])
data.set_trim(x_values, y_values[i])
data_models = dms.DataModel()
data_models.data = data
all_data_models.append(data_models)
self.sig_new_file.emit(all_data_models)
def update_info(self, n: int):
rpm = self.rpm[n] / 1000
self.le_rpm.setText(f"{rpm: g}k")
wave = self.wavelength[n]
self.le_wavl.setText(f"{wave: g}")
temp = self.temperature[n]
self.le_temp.setText(f"{temp: g}")