Commit 7d28e5e2 authored by Ivo Peterek's avatar Ivo Peterek

ENH: changed desing of power samples window + shuffled colors in legend #8

parent fde4e66c
......@@ -62,9 +62,9 @@ class Window(QtWidgets.QDialog):
self.plotType = 0
self.typeButton.clicked.connect(self.changeType)
self.addButton = QtWidgets.QPushButton('Add')
self.addButton = QtWidgets.QPushButton('Add to plot')
self.addButton.clicked.connect(self.addToPlot)
self.clearButton = QtWidgets.QPushButton('Clear')
self.clearButton = QtWidgets.QPushButton('Clear plot')
self.clearButton.clicked.connect(self.clearCanvas)
self.smoothWindowSizeLabel = QtWidgets.QLabel("Window size:")
......@@ -75,7 +75,7 @@ class Window(QtWidgets.QDialog):
self.smoothWindowSizeSpinBox.setSingleStep(2)
self.smoothWindowSizeSpinBox.setMaximum(2147483647)#TMP
self.smoothpolyOrderLabel = QtWidgets.QLabel("Polynomial order:")
self.smoothpolyOrderLabel.setFixedWidth(120)
self.smoothpolyOrderLabel.setFixedWidth(130)
self.smoothpolyOrderSpinBox = QtWidgets.QSpinBox()
self.smoothpolyOrderSpinBox.setMinimum(2)
self.smoothpolyOrderSpinBox.setMaximum(2147483647)
......@@ -141,10 +141,10 @@ class Window(QtWidgets.QDialog):
# create labels for region and each parameter combo box
self.label_sensor = QtWidgets.QLabel('Power Sensor')
self.label_reg = QtWidgets.QLabel('Region')
self.lables_param_list = []
self.labels_param_list = []
param_names = self.d['file_name_args'].get_lst_of_params()
for i, combo_param in enumerate(self.combo_param_list):
self.lables_param_list.append(QtWidgets.QLabel(param_names[i]))
self.labels_param_list.append(QtWidgets.QLabel(param_names[i]))
# gather power sensors names from first csv
possible_samples_names = []
......@@ -168,33 +168,42 @@ class Window(QtWidgets.QDialog):
self.plot_data = self.data[0]
labels_lay = QtWidgets.QHBoxLayout()
self.label_sensor.setFixedHeight(30)
labels_lay.addWidget(self.label_sensor)
self.label_reg.setFixedHeight(30)
labels_lay.addWidget(self.label_reg)
for label in self.lables_param_list:
for label in self.labels_param_list:
label.setFixedHeight(30)
labels_lay.addWidget(label)
layout.addLayout(labels_lay)
hl_reg = QtWidgets.QHBoxLayout()
hl_reg.addWidget(self.combo_sample)
hl_reg.addWidget(self.combo_reg)
for combo_param in self.combo_param_list:
hl_reg.addWidget(combo_param)
vl_sensor = QtWidgets.QVBoxLayout()
vl_sensor.addWidget(self.label_sensor)
vl_sensor.addWidget(self.combo_sample)
hl_reg.addLayout(vl_sensor)
vl_reg = QtWidgets.QVBoxLayout()
vl_reg.addWidget(self.label_reg)
vl_reg.addWidget(self.combo_reg)
hl_reg.addLayout(vl_reg)
for i, combo_param in enumerate(self.combo_param_list):
vl_param = QtWidgets.QVBoxLayout()
vl_param.addWidget(self.labels_param_list[i])
vl_param.addWidget(combo_param)
hl_reg.addLayout(vl_param)
layout.addLayout(hl_reg)
self.cluster_btn = QtWidgets.QPushButton('Cluster analysis')
self.cluster_btn.clicked.connect(self.clustering)
hlayout2 = QtWidgets.QHBoxLayout()
self.cluster_btn.setFixedWidth(130)
self.addButton.setFixedWidth(130)
hlayout2.addWidget(self.cluster_btn)
hlayout2.addWidget(self.addButton)
hlayout2.addWidget(self.clearButton)
hlayout2.setAlignment(QtCore.Qt.AlignRight)
layout.addLayout(hlayout2)
hlayout3 = QtWidgets.QHBoxLayout()
hlayout3.setAlignment(QtCore.Qt.AlignRight)
self.smoothButton.setFixedWidth(130)
hlayout3.addWidget(self.smoothpolyOrderLabel)
hlayout3.addWidget(self.smoothpolyOrderSpinBox)
hlayout3.addWidget(self.smoothWindowSizeLabel)
......@@ -202,6 +211,12 @@ class Window(QtWidgets.QDialog):
hlayout3.addWidget(self.smoothButton)
layout.addLayout(hlayout3)
hlayout4 = QtWidgets.QHBoxLayout()
self.clearButton.setFixedWidth(130)
hlayout4.addWidget(self.clearButton)
hlayout4.setAlignment(QtCore.Qt.AlignRight)
layout.addLayout(hlayout4)
layout.addWidget(self.toolbar)
layout.addWidget(self.canvas)
......@@ -278,7 +293,7 @@ class Window(QtWidgets.QDialog):
sample_vals = []
zero_numbers = []
for sample in line:
# Take out zeroes
# Take out zeros
if sample[1] == 0:
zero_numbers.append((sample[0]))
else:
......@@ -291,12 +306,12 @@ class Window(QtWidgets.QDialog):
if smoothed_sample_vals[i] > self.max_sample_val:
self.max_sample_val = smoothed_sample_vals[i]
if number - 1 in zero_numbers: # Put zeroes back
if number - 1 in zero_numbers: # Put zeros back
tmp_line.append((number - 1, 0))
tmp_line.append((number, smoothed_sample_vals[i]))
if number+1 in zero_numbers: # Put zeroes back
if number+1 in zero_numbers: # Put zeros back
tmp_line.append((number+1, 0))
smooth_samples_data.append(tmp_line)
......@@ -330,8 +345,8 @@ class Window(QtWidgets.QDialog):
increasing = True
# Smooth samples
smooth_window_size = self.round_up_to_odd(int(len(samples)))
smooth_window_size_small = self.round_up_to_odd(int(0.1*len(samples)))
smooth_window_size = self.round_up_to_odd(int(len(samples)))-2
smooth_window_size_small = self.round_up_to_odd(int(0.1*len(samples)))-2
poly_order = 3
smooth_samples = signal.savgol_filter(engs, smooth_window_size_small, poly_order)
smooth_samples = signal.savgol_filter(smooth_samples, smooth_window_size, poly_order)
......@@ -517,6 +532,7 @@ class Window(QtWidgets.QDialog):
self.funcmax = 0
colors = pl.cm.jet(np.linspace(0, 1, self.n))
np.random.shuffle(colors)
for m in range(0,self.n):
X = [x[0] for x in self.K[m]]
Y = [x[1] for x in self.K[m]]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment