|
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__() |
@@ -130,13 +130,11 @@ def onClose(self): |
130 | 130 | self.cbData2.addItems(['No Data Available']) |
131 | 131 | self.close() |
132 | 132 |
|
133 | | - |
134 | 133 | def onCompute(self): |
135 | 134 | """ perform calculation - don't send to data explorer""" |
136 | 135 | # set operator to be applied |
137 | 136 | operator = self.cbOperator.currentText() |
138 | 137 | # calculate and send data to DataExplorer |
139 | | - output = None |
140 | 138 | if self.data1 is None or self.data2 is None: |
141 | 139 | logging.warning("Please set both Data1 and Data2 to complete operation.") |
142 | 140 | try: |
@@ -182,8 +180,7 @@ def onPrepareOutputData(self): |
182 | 180 | self.output, |
183 | 181 | name=name) |
184 | 182 |
|
185 | | - new_datalist_item = {name + str(time.time()): |
186 | | - self.output} |
| 183 | + new_datalist_item = {name + str(time.time()): self.output} |
187 | 184 | self.communicator. \ |
188 | 185 | updateModelFromDataOperationPanelSignal.emit(new_item, new_datalist_item) |
189 | 186 |
|
@@ -228,7 +225,7 @@ def onSelectData1(self): |
228 | 225 | self.newPlot(self.graphData1, self.layoutData1) |
229 | 226 | self.data1 = None |
230 | 227 | self.data1OK = False |
231 | | - self.cmdCompute.setEnabled(False) # self.onCheckChosenData()) |
| 228 | + self.cmdCompute.setEnabled(False) # self.onCheckChosenData()) |
232 | 229 | return |
233 | 230 |
|
234 | 231 | else: |
@@ -286,7 +283,6 @@ def onSelectData2(self): |
286 | 283 | else: |
287 | 284 | self.cautionStatement.setText("") |
288 | 285 |
|
289 | | - |
290 | 286 | def onInputCoefficient(self): |
291 | 287 | """ Check input of number when a coefficient is required |
292 | 288 | for operation """ |
@@ -330,12 +326,12 @@ def onCheckChosenData(self): |
330 | 326 |
|
331 | 327 | elif self.data1.__class__.__name__ == 'Data2D' \ |
332 | 328 | and (len(self.data2.qx_data) != len(self.data1.qx_data) \ |
333 | | - or len(self.data2.qy_data) != len(self.data1.qy_data) |
334 | | - or not all(i == j for i, j in |
335 | | - zip(self.data1.qx_data, self.data2.qx_data)) |
336 | | - or not all(i == j for i, j in |
337 | | - zip(self.data1.qy_data, self.data2.qy_data)) |
338 | | - ): |
| 329 | + or len(self.data2.qy_data) != len(self.data1.qy_data) |
| 330 | + or not all(i == j for i, j in |
| 331 | + zip(self.data1.qx_data, self.data2.qx_data)) |
| 332 | + or not all(i == j for i, j in |
| 333 | + zip(self.data1.qy_data, self.data2.qy_data)) |
| 334 | + ): |
339 | 335 | self.cbData1.setStyleSheet(BG_RED) |
340 | 336 | self.cbData2.setStyleSheet(BG_RED) |
341 | 337 | logging.error('Cannot compute 2D data of different lengths') |
@@ -441,28 +437,10 @@ def operationData1D(self, operation_data, reference_data=None): |
441 | 437 | new_operation_data.dy = np.zeros(2) |
442 | 438 | new_operation_data.dx = np.zeros(2) |
443 | 439 | else: |
444 | | - try: |
445 | | - new_operation_data = Data1D(x=operation_data.x, y=operation_data.y, dy=operation_data.dy, dx=None) |
446 | | - new_operation_data.copy_from_datainfo(data1d=operation_data) |
447 | | - except: |
448 | | - new_operation_data = None |
449 | | - |
| 440 | + new_operation_data = Data1D(x=operation_data.x, y=operation_data.y, dy=operation_data.dy, dx=None) |
| 441 | + new_operation_data.copy_from_datainfo(data1d=operation_data) |
450 | 442 | return new_operation_data |
451 | 443 |
|
452 | | - # for d_op, c_op in zip(data_op, color_op): |
453 | | - # if isinstance(d_op, Data1D): |
454 | | - # op_data = Data1D(x=d_op._operation.x, y=d_op._operation.y, dy=d_op._operation.dy, dx=None) |
455 | | - # op_data.copy_from_datainfo(data1d=d_op._operation) |
456 | | - # plotter.plot(data=op_data, hide_error=True, marker='.', color=c_op) |
457 | | - # else: |
458 | | - # op_data = Data1D(2) |
459 | | - # op_data.copy_from_datainfo(data1d=data) |
460 | | - # op_data.x = np.array([data.x.min(), data.x.max()]) |
461 | | - # op_data.y = np.array([d_op, d_op]) |
462 | | - # op_data.dy = np.zeros(2) |
463 | | - # op_data.dx = np.zeros(2) |
464 | | - # plotter.plot(data=op_data, hide_error=True, marker='-', color=c_op) |
465 | | - |
466 | 444 | def updatePlot(self, graph, layout, data, color=None, operation_data=False): |
467 | 445 | """ plot data in graph after clearing its layout """ |
468 | 446 |
|
@@ -540,7 +518,7 @@ def updatePlot(self, graph, layout, data, color=None, operation_data=False): |
540 | 518 | hide_error=True, marker='o', color=DATA2_COLOR, |
541 | 519 | markerfacecolor=None, markeredgecolor=None) |
542 | 520 | plotter.plot(data=data, hide_error=True, marker='o', color=color, markerfacecolor=markerfacecolor, |
543 | | - markeredgecolor=markeredgecolor) |
| 521 | + markeredgecolor=markeredgecolor) |
544 | 522 | else: |
545 | 523 | plotter.plot(data=data, hide_error=True, marker='o', color=color, markerfacecolor=markerfacecolor, |
546 | 524 | markeredgecolor=markeredgecolor, alpha=alpha) |
|
0 commit comments