Changeset ee18d33 in sasview for src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 \
Note: See TracChangeset
for help on using the changeset viewer.