- Timestamp:
- Aug 9, 2017 9:52:07 AM (7 years ago)
- Branches:
- ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- 38eb433
- Parents:
- 985ad94
- Location:
- src/sas/qtgui
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/MainWindow/DataExplorer.py
rb0c5e8c ree18d33 352 352 353 353 # Notify the GuiManager about the send request 354 self._perspective().setData(data_item=selected_items )354 self._perspective().setData(data_item=selected_items, is_batch=self.chkBatch.isChecked()) 355 355 356 356 def freezeTheory(self, event): -
src/sas/qtgui/Perspectives/Fitting/FitThread.py
r7adc2a8 ree18d33 70 70 list_fit_function = ['fit']*fitter_size 71 71 list_q = [None]*fitter_size 72 72 73 inputs = zip(list_map_get_attr, self.fitter, list_fit_function, 73 74 list_q, list_q, list_handler, list_curr_thread, 74 75 list_reset_flag) 75 76 result = map(map_apply, inputs) 76 results = (result [0], time.time()-self.starttime)77 results = (result, time.time()-self.starttime) 77 78 if self.handler: 78 79 self.completefn(results) -
src/sas/qtgui/Perspectives/Fitting/FittingLogic.py
rdc5ef15 ree18d33 178 178 def computeDataRange(self): 179 179 """ 180 Wrapper for calculating the data range based on local dataset 181 """ 182 return self.computeRangeFromData(self.data) 183 184 def computeRangeFromData(self, data): 185 """ 180 186 Compute the minimum and the maximum range of the data 181 187 return the npts contains in data 182 188 """ 183 189 qmin, qmax, npts = None, None, None 184 if isinstance( self.data, Data1D):190 if isinstance(data, Data1D): 185 191 try: 186 qmin = min( self.data.x)187 qmax = max( self.data.x)188 npts = len( self.data.x)192 qmin = min(data.x) 193 qmax = max(data.x) 194 npts = len(data.x) 189 195 except (ValueError, TypeError): 190 196 msg = "Unable to find min/max/length of \n data named %s" % \ … … 195 201 qmin = 0 196 202 try: 197 x = max(np.fabs( self.data.xmin), np.fabs(self.data.xmax))198 y = max(np.fabs( self.data.ymin), np.fabs(self.data.ymax))203 x = max(np.fabs(data.xmin), np.fabs(data.xmax)) 204 y = max(np.fabs(data.ymin), np.fabs(data.ymax)) 199 205 except (ValueError, TypeError): 200 206 msg = "Unable to find min/max of \n data named %s" % \ … … 202 208 raise ValueError, msg 203 209 qmax = np.sqrt(x * x + y * y) 204 npts = len( self.data.data)210 npts = len(data.data) 205 211 return qmin, qmax, npts -
src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py
rb0c5e8c ree18d33 97 97 event.ignore() 98 98 99 def addFit(self, data ):99 def addFit(self, data, is_batch=False): 100 100 """ 101 101 Add a new tab for passed data 102 102 """ 103 103 tab = FittingWidget(parent=self.parent, data=data, tab_id=self.maxIndex+1) 104 tab.is_batch_fitting = is_batch 104 105 # Add this tab to the object library so it can be retrieved by scripting/jupyter 105 106 ObjectLibrary.addObject(self.tabName(), tab) … … 133 134 return True 134 135 135 def setData(self, data_item=None ):136 def setData(self, data_item=None, is_batch=False): 136 137 """ 137 138 Assign new dataset to the fitting instance … … 149 150 raise AttributeError, msg 150 151 151 for data in data_item: 152 items = [data_item] if is_batch else data_item 153 154 for data in items: 152 155 # Find the first unassigned tab. 153 156 # If none, open a new tab. … … 157 160 self.tabs[available_tabs.index(True)].data = data 158 161 else: 159 self.addFit(data )162 self.addFit(data, is_batch=is_batch) 160 163 161 164 def onFittingOptionsChange(self, fit_engine): -
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
r7adc2a8 ree18d33 48 48 DEFAULT_POLYDISP_FUNCTION = 'gaussian' 49 49 50 USING_TWISTED = True50 USING_TWISTED = False 51 51 52 52 class FittingWidget(QtGui.QWidget, Ui_FittingWidgetUI): … … 65 65 66 66 # Main Data[12]D holder 67 self.logic = FittingLogic( data=data)67 self.logic = FittingLogic() 68 68 69 69 # Globals … … 117 117 def data(self, value): 118 118 """ data setter """ 119 assert isinstance(value, QtGui.QStandardItem) 119 if isinstance(value, list): 120 self.is_batch_fitting = True 121 else: 122 value = [value] 123 124 assert isinstance(value[0], QtGui.QStandardItem) 120 125 # _index contains the QIndex with data 121 self._index = value 126 self._index = value[0] 127 128 # Keep reference to all datasets for batch 129 self.all_data = value 122 130 123 131 # Update logics with data items 124 self.logic.data = GuiUtils.dataFromItem(value )132 self.logic.data = GuiUtils.dataFromItem(value[0]) 125 133 126 134 # Overwrite data type descriptor … … 140 148 # Data[12]D passed and set 141 149 self.data_is_loaded = False 150 # Batch/single fitting 151 self.is_batch_fitting = False 142 152 # Current SasModel in view 143 153 self.kernel_module = None … … 294 304 self.chk2DView.setVisible(False) 295 305 self.chkMagnetism.setEnabled(self.is2D) 306 # Combo box or label for file name" 307 if self.is_batch_fitting: 308 self.lblFilename.setVisible(False) 309 for dataitem in self.all_data: 310 filename = GuiUtils.dataFromItem(dataitem).filename 311 self.cbFileNames.addItem(filename) 312 self.cbFileNames.setVisible(True) 296 313 # Similarly on other tabs 297 314 self.options_widget.setEnablementOnDataLoad() … … 344 361 Set initial control enablement 345 362 """ 363 self.cbFileNames.setVisible(False) 346 364 self.cmdFit.setEnabled(False) 347 365 self.cmdPlot.setEnabled(False) … … 370 388 self.cbCategory.currentIndexChanged.connect(self.onSelectCategory) 371 389 self.cbModel.currentIndexChanged.connect(self.onSelectModel) 390 self.cbFileNames.currentIndexChanged.connect(self.onSelectBatchFilename) 372 391 # Checkboxes 373 392 self.chk2DView.toggled.connect(self.toggle2D) … … 423 442 424 443 self.respondToModelStructure(model=model, structure_factor=None) 444 445 def onSelectBatchFilename(self, data_index): 446 """ 447 Update the logic based on the selected file in batch fitting 448 """ 449 self._index = self.all_data[data_index] 450 self.logic.data = GuiUtils.dataFromItem(self.all_data[data_index]) 451 self.updateQRange() 425 452 426 453 def onSelectStructureFactor(self): … … 613 640 Perform fitting on the current data 614 641 """ 615 fitter = Fit()616 642 617 643 # Data going in … … 650 676 651 677 # Parameterize the fitter 652 fitter.set_model(model, fit_id, params_to_fit, data=data, 653 constraints=constraints) 654 655 fitter.set_data(data=data, id=fit_id, smearer=smearer, qmin=qmin, 656 qmax=qmax) 657 fitter.select_problem_for_fit(id=fit_id, value=1) 658 659 fitter.fitter_id = page_id 678 fitters = [] 679 for fit_index in self.all_data: 680 fitter = Fit() 681 data = GuiUtils.dataFromItem(fit_index) 682 fitter.set_model(model, fit_id, params_to_fit, data=data, 683 constraints=constraints) 684 qmin, qmax, _ = self.logic.computeRangeFromData(data) 685 fitter.set_data(data=data, id=fit_id, smearer=smearer, qmin=qmin, 686 qmax=qmax) 687 fitter.select_problem_for_fit(id=fit_id, value=1) 688 fitter.fitter_id = page_id 689 fit_id += 1 690 fitters.append(fitter) 660 691 661 692 # Create the fitting thread, based on the fitter 693 completefn = self.batchFitComplete if self.is_batch_fitting else self.fitComplete 694 662 695 calc_fit = FitThread(handler=handler, 663 fn=[fitter],664 batch_inputs=batch_inputs,665 batch_outputs=batch_outputs,666 page_id=list_page_id,667 updatefn=updater,668 completefn=self.fitComplete)696 fn=fitters, 697 batch_inputs=batch_inputs, 698 batch_outputs=batch_outputs, 699 page_id=list_page_id, 700 updatefn=updater, 701 completefn=completefn) 669 702 670 703 if USING_TWISTED: … … 696 729 pass 697 730 698 def fitComplete(self, result): 699 """ 700 Receive and display fitting results 701 "result" is a tuple of actual result list and the fit time in seconds 731 def batchFitComplete(self, result): 732 """ 733 Receive and display batch fitting results 702 734 """ 703 735 #re-enable the Fit button … … 705 737 self.cmdFit.setEnabled(True) 706 738 739 print ("BATCH FITTING FINISHED") 740 # Add the Qt version of wx.aui.AuiNotebook and populate it 741 pass 742 743 def fitComplete(self, result): 744 """ 745 Receive and display fitting results 746 "result" is a tuple of actual result list and the fit time in seconds 747 """ 748 #re-enable the Fit button 749 self.cmdFit.setText("Fit") 750 self.cmdFit.setEnabled(True) 751 707 752 assert result is not None 708 753 709 res_list = result[0] 754 res_list = result[0][0] 710 755 res = res_list[0] 711 756 if res.fitness is None or \ -
src/sas/qtgui/Perspectives/Fitting/UI/FittingWidgetUI.ui
raca8418 ree18d33 20 20 <string>FittingWidget</string> 21 21 </property> 22 <layout class="QGridLayout" name="gridLayout_15"> 23 <item row="0" column="0"> 24 <widget class="QLabel" name="label"> 25 <property name="text"> 26 <string>File name:</string> 27 </property> 28 </widget> 29 </item> 30 <item row="0" column="1"> 31 <widget class="QLabel" name="lblFilename"> 32 <property name="text"> 33 <string>None</string> 34 </property> 35 </widget> 36 </item> 37 <item row="0" column="2" colspan="4"> 38 <spacer name="horizontalSpacer_4"> 39 <property name="orientation"> 40 <enum>Qt::Horizontal</enum> 41 </property> 42 <property name="sizeHint" stdset="0"> 43 <size> 44 <width>459</width> 45 <height>20</height> 46 </size> 47 </property> 48 </spacer> 49 </item> 50 <item row="2" column="3"> 51 <widget class="QPushButton" name="cmdPlot"> 52 <property name="sizePolicy"> 53 <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> 54 <horstretch>0</horstretch> 55 <verstretch>0</verstretch> 56 </sizepolicy> 57 </property> 58 <property name="minimumSize"> 59 <size> 60 <width>75</width> 61 <height>23</height> 62 </size> 63 </property> 64 <property name="text"> 65 <string>Show Plot</string> 66 </property> 67 </widget> 68 </item> 69 <item row="2" column="4"> 70 <widget class="QPushButton" name="cmdFit"> 71 <property name="sizePolicy"> 72 <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> 73 <horstretch>0</horstretch> 74 <verstretch>0</verstretch> 75 </sizepolicy> 76 </property> 77 <property name="minimumSize"> 78 <size> 79 <width>75</width> 80 <height>23</height> 81 </size> 82 </property> 83 <property name="text"> 84 <string>Fit</string> 85 </property> 86 </widget> 87 </item> 88 <item row="2" column="5"> 89 <widget class="QPushButton" name="cmdHelp"> 90 <property name="sizePolicy"> 91 <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> 92 <horstretch>0</horstretch> 93 <verstretch>0</verstretch> 94 </sizepolicy> 95 </property> 96 <property name="minimumSize"> 97 <size> 98 <width>75</width> 99 <height>23</height> 100 </size> 101 </property> 102 <property name="text"> 103 <string>Help</string> 104 </property> 105 </widget> 106 </item> 107 <item row="2" column="0" colspan="3"> 108 <spacer name="horizontalSpacer"> 109 <property name="orientation"> 110 <enum>Qt::Horizontal</enum> 111 </property> 112 <property name="sizeHint" stdset="0"> 113 <size> 114 <width>273</width> 115 <height>20</height> 116 </size> 117 </property> 118 </spacer> 119 </item> 120 <item row="1" column="0" colspan="6"> 22 <layout class="QGridLayout" name="gridLayout_4"> 23 <item row="0" column="0" colspan="4"> 24 <layout class="QHBoxLayout" name="horizontalLayout"> 25 <item> 26 <widget class="QLabel" name="label"> 27 <property name="text"> 28 <string>File name:</string> 29 </property> 30 </widget> 31 </item> 32 <item> 33 <layout class="QGridLayout" name="gridLayout_3"> 34 <item row="0" column="0"> 35 <widget class="QComboBox" name="cbFileNames"> 36 <property name="sizeAdjustPolicy"> 37 <enum>QComboBox::AdjustToContents</enum> 38 </property> 39 </widget> 40 </item> 41 <item row="0" column="1"> 42 <widget class="QLabel" name="lblFilename"> 43 <property name="text"> 44 <string>None</string> 45 </property> 46 </widget> 47 </item> 48 </layout> 49 </item> 50 <item> 51 <spacer name="horizontalSpacer_4"> 52 <property name="orientation"> 53 <enum>Qt::Horizontal</enum> 54 </property> 55 <property name="sizeHint" stdset="0"> 56 <size> 57 <width>459</width> 58 <height>20</height> 59 </size> 60 </property> 61 </spacer> 62 </item> 63 </layout> 64 </item> 65 <item row="1" column="0" colspan="4"> 121 66 <widget class="QTabWidget" name="tabFitting"> 122 67 <property name="currentIndex"> … … 457 402 </widget> 458 403 </item> 404 <item row="2" column="0"> 405 <spacer name="horizontalSpacer"> 406 <property name="orientation"> 407 <enum>Qt::Horizontal</enum> 408 </property> 409 <property name="sizeHint" stdset="0"> 410 <size> 411 <width>273</width> 412 <height>20</height> 413 </size> 414 </property> 415 </spacer> 416 </item> 417 <item row="2" column="1"> 418 <widget class="QPushButton" name="cmdPlot"> 419 <property name="sizePolicy"> 420 <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> 421 <horstretch>0</horstretch> 422 <verstretch>0</verstretch> 423 </sizepolicy> 424 </property> 425 <property name="minimumSize"> 426 <size> 427 <width>75</width> 428 <height>23</height> 429 </size> 430 </property> 431 <property name="text"> 432 <string>Show Plot</string> 433 </property> 434 </widget> 435 </item> 436 <item row="2" column="2"> 437 <widget class="QPushButton" name="cmdFit"> 438 <property name="sizePolicy"> 439 <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> 440 <horstretch>0</horstretch> 441 <verstretch>0</verstretch> 442 </sizepolicy> 443 </property> 444 <property name="minimumSize"> 445 <size> 446 <width>75</width> 447 <height>23</height> 448 </size> 449 </property> 450 <property name="text"> 451 <string>Fit</string> 452 </property> 453 </widget> 454 </item> 455 <item row="2" column="3"> 456 <widget class="QPushButton" name="cmdHelp"> 457 <property name="sizePolicy"> 458 <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> 459 <horstretch>0</horstretch> 460 <verstretch>0</verstretch> 461 </sizepolicy> 462 </property> 463 <property name="minimumSize"> 464 <size> 465 <width>75</width> 466 <height>23</height> 467 </size> 468 </property> 469 <property name="text"> 470 <string>Help</string> 471 </property> 472 </widget> 473 </item> 459 474 </layout> 460 475 </widget> -
src/sas/qtgui/Perspectives/Invariant/InvariantPerspective.py
rb0c5e8c ree18d33 539 539 self.mapper.toFirst() 540 540 541 def setData(self, data_item ):541 def setData(self, data_item, is_batch=False): 542 542 """ 543 543 Obtain a QStandardItem object and dissect it to get Data1D/2D
Note: See TracChangeset
for help on using the changeset viewer.