|
7 | 7 | from PySide6 import QtGui |
8 | 8 | from PySide6 import QtWidgets |
9 | 9 | import numpy as np |
10 | | -from typing import Optional |
11 | 10 |
|
12 | 11 | from sas.qtgui.Plotting.PlotterData import Data1D |
13 | 12 | from sas.qtgui.Plotting.Plotter import PlotterWidget |
|
27 | 26 | TRIMMED_COLOR = '#FFFFFF' # white |
28 | 27 | TRIMMED_ALPHA = 0.3 # semi-transparent points trimmed for operation |
29 | 28 |
|
| 29 | + |
30 | 30 | class DataOperationUtilityPanel(QtWidgets.QDialog, Ui_DataOperationUtility): |
31 | 31 | def __init__(self, parent=None): |
32 | 32 | super(DataOperationUtilityPanel, self).__init__() |
@@ -132,13 +132,11 @@ def onClose(self): |
132 | 132 | self.cbData2.addItems(['No Data Available']) |
133 | 133 | self.close() |
134 | 134 |
|
135 | | - |
136 | 135 | def onCompute(self): |
137 | 136 | """ perform calculation - don't send to data explorer""" |
138 | 137 | # set operator to be applied |
139 | 138 | operator = self.cbOperator.currentText() |
140 | 139 | # calculate and send data to DataExplorer |
141 | | - output = None |
142 | 140 | if self.data1 is None or self.data2 is None: |
143 | 141 | logging.warning("Please set both Data1 and Data2 to complete operation.") |
144 | 142 | try: |
@@ -184,8 +182,7 @@ def onPrepareOutputData(self): |
184 | 182 | self.output, |
185 | 183 | name=name) |
186 | 184 |
|
187 | | - new_datalist_item = {name + str(time.time()): |
188 | | - self.output} |
| 185 | + new_datalist_item = {name + str(time.time()): self.output} |
189 | 186 | self.communicator. \ |
190 | 187 | updateModelFromDataOperationPanelSignal.emit(new_item, new_datalist_item) |
191 | 188 |
|
@@ -230,7 +227,7 @@ def onSelectData1(self): |
230 | 227 | self.newPlot(self.graphData1, self.layoutData1) |
231 | 228 | self.data1 = None |
232 | 229 | self.data1OK = False |
233 | | - self.cmdCompute.setEnabled(False) # self.onCheckChosenData()) |
| 230 | + self.cmdCompute.setEnabled(False) # self.onCheckChosenData()) |
234 | 231 | return |
235 | 232 |
|
236 | 233 | else: |
@@ -288,7 +285,6 @@ def onSelectData2(self): |
288 | 285 | else: |
289 | 286 | self.cautionStatement.setText("") |
290 | 287 |
|
291 | | - |
292 | 288 | def onInputCoefficient(self): |
293 | 289 | """ Check input of number when a coefficient is required |
294 | 290 | for operation """ |
@@ -332,12 +328,12 @@ def onCheckChosenData(self): |
332 | 328 |
|
333 | 329 | elif self.data1.__class__.__name__ == 'Data2D' \ |
334 | 330 | and (len(self.data2.qx_data) != len(self.data1.qx_data) \ |
335 | | - or len(self.data2.qy_data) != len(self.data1.qy_data) |
336 | | - or not all(i == j for i, j in |
337 | | - zip(self.data1.qx_data, self.data2.qx_data)) |
338 | | - or not all(i == j for i, j in |
339 | | - zip(self.data1.qy_data, self.data2.qy_data)) |
340 | | - ): |
| 331 | + or len(self.data2.qy_data) != len(self.data1.qy_data) |
| 332 | + or not all(i == j for i, j in |
| 333 | + zip(self.data1.qx_data, self.data2.qx_data)) |
| 334 | + or not all(i == j for i, j in |
| 335 | + zip(self.data1.qy_data, self.data2.qy_data)) |
| 336 | + ): |
341 | 337 | self.cbData1.setStyleSheet(BG_RED) |
342 | 338 | self.cbData2.setStyleSheet(BG_RED) |
343 | 339 | logging.error('Cannot compute 2D data of different lengths') |
@@ -443,28 +439,10 @@ def operationData1D(self, operation_data, reference_data=None): |
443 | 439 | new_operation_data.dy = np.zeros(2) |
444 | 440 | new_operation_data.dx = np.zeros(2) |
445 | 441 | else: |
446 | | - try: |
447 | | - new_operation_data = Data1D(x=operation_data.x, y=operation_data.y, dy=operation_data.dy, dx=None) |
448 | | - new_operation_data.copy_from_datainfo(data1d=operation_data) |
449 | | - except: |
450 | | - new_operation_data = None |
451 | | - |
| 442 | + new_operation_data = Data1D(x=operation_data.x, y=operation_data.y, dy=operation_data.dy, dx=None) |
| 443 | + new_operation_data.copy_from_datainfo(data1d=operation_data) |
452 | 444 | return new_operation_data |
453 | 445 |
|
454 | | - # for d_op, c_op in zip(data_op, color_op): |
455 | | - # if isinstance(d_op, Data1D): |
456 | | - # op_data = Data1D(x=d_op._operation.x, y=d_op._operation.y, dy=d_op._operation.dy, dx=None) |
457 | | - # op_data.copy_from_datainfo(data1d=d_op._operation) |
458 | | - # plotter.plot(data=op_data, hide_error=True, marker='.', color=c_op) |
459 | | - # else: |
460 | | - # op_data = Data1D(2) |
461 | | - # op_data.copy_from_datainfo(data1d=data) |
462 | | - # op_data.x = np.array([data.x.min(), data.x.max()]) |
463 | | - # op_data.y = np.array([d_op, d_op]) |
464 | | - # op_data.dy = np.zeros(2) |
465 | | - # op_data.dx = np.zeros(2) |
466 | | - # plotter.plot(data=op_data, hide_error=True, marker='-', color=c_op) |
467 | | - |
468 | 446 | def updatePlot(self, graph, layout, data, color=None, operation_data=False): |
469 | 447 | """ plot data in graph after clearing its layout """ |
470 | 448 |
|
@@ -542,7 +520,7 @@ def updatePlot(self, graph, layout, data, color=None, operation_data=False): |
542 | 520 | hide_error=True, marker='o', color=DATA2_COLOR, |
543 | 521 | markerfacecolor=None, markeredgecolor=None) |
544 | 522 | plotter.plot(data=data, hide_error=True, marker='o', color=color, markerfacecolor=markerfacecolor, |
545 | | - markeredgecolor=markeredgecolor) |
| 523 | + markeredgecolor=markeredgecolor) |
546 | 524 | else: |
547 | 525 | plotter.plot(data=data, hide_error=True, marker='o', color=color, markerfacecolor=markerfacecolor, |
548 | 526 | markeredgecolor=markeredgecolor, alpha=alpha) |
|
0 commit comments