Changeset 6fd4e36 in sasview for src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
- Timestamp:
- Mar 28, 2017 6:53:29 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:
- 0268aed
- Parents:
- a9b568c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
ra9b568c r6fd4e36 147 147 assert isinstance(value[0], QtGui.QStandardItem) 148 148 # _index contains the QIndex with data 149 self._index = value 149 self._index = value[0] 150 150 151 151 # Update logics with data items … … 314 314 self.SASModelToQModel(model) 315 315 316 if self._index is None: 316 if self.data_is_loaded: 317 self.calculateQGridForModel() 318 else: 317 319 # Create default datasets if no data passed 318 320 self.createDefaultDataset() 319 else:320 self.calculateQGridForModel()321 321 322 322 def onSelectStructureFactor(self): … … 503 503 # multishell params in self.kernel_module.details[??] = value 504 504 505 506 def createTheoryIndex(self): 507 """ 508 Create a QStandardModelIndex containing default model data 509 """ 510 name = self.kernel_module.name 505 def nameForFittedData(self, name): 506 """ 507 Generate name for the current fit 508 """ 511 509 if self.is2D: 512 510 name += "2d" 513 511 name = "M%i [%s]" % (self.tab_id, name) 514 new_item = GuiUtils.createModelItemWithPlot(QtCore.QVariant(self.data), name=name) 515 # Notify the GUI manager so it can update the theory model in DataExplorer 512 return name 513 514 def createNewIndex(self, fitted_data): 515 """ 516 Create a model or theory index with passed Data1D/Data2D 517 """ 518 if self.data_is_loaded: 519 self.updateModelIndex(fitted_data) 520 else: 521 self.createTheoryIndex(fitted_data) 522 523 def updateModelIndex(self, fitted_data): 524 """ 525 Update a QStandardModelIndex containing model data 526 """ 527 name = self.nameForFittedData(self.logic.data.filename) 528 fitted_data.title = name 529 fitted_data.name = name 530 # Make this a line 531 fitted_data.symbol = 'Line' 532 # Notify the GUI manager so it can update the main model in DataExplorer 533 GuiUtils.updateModelItemWithPlot(self._index, QtCore.QVariant(fitted_data), name) 534 535 def createTheoryIndex(self, fitted_data): 536 """ 537 Create a QStandardModelIndex containing model data 538 """ 539 name = self.nameForFittedData(self.kernel_module.name) 540 fitted_data.title = name 541 fitted_data.name = name 542 fitted_data.filename = name 543 # Notify the GUI manager so it can create the theory model in DataExplorer 544 new_item = GuiUtils.createModelItemWithPlot(QtCore.QVariant(fitted_data), name=name) 516 545 self.communicate.updateTheoryFromPerspectiveSignal.emit(new_item) 517 546 … … 520 549 Perform fitting on the current data 521 550 """ 551 # TODO: everything here 522 552 #self.calculate1DForModel() 523 553 pass … … 527 557 Plot the current set of data 528 558 """ 529 # TODO: reimplement basepage.py/_update_paramv_on_fit 530 if self.data is None or not self.data.is_data: 559 if self.data is None :#or not self.data.is_data: 531 560 self.createDefaultDataset() 532 561 self.calculateQGridForModel() … … 607 636 Plot the current 1D data 608 637 """ 609 self.logic.new1DPlot(return_data) 610 self.createTheoryIndex() 611 612 #output=self._cal_chisqr(data=data, 638 fitted_data = self.logic.new1DPlot(return_data) 639 self.calculateResiduals(self.logic.new1DPlot(return_data)) 640 641 def complete2D(self, return_data): 642 """ 643 Plot the current 2D data 644 """ 645 fitted_data = self.logic.new2DPlot(return_data) 646 self.calculateResiduals(fitted_data) 647 648 def calculateResiduals(self, fitted_data): 649 """ 650 Calculate and print Chi2 and display chart of residuals 651 """ 652 # Create a new index for holding data 653 self.createNewIndex(fitted_data) 654 # Calculate difference between return_data and logic.data 655 chi2 = FittingUtilities.calculateChi2(fitted_data, self.logic.data) 656 # Update the control 657 self.lblChi2Value.setText(GuiUtils.formatNumber(chi2, high=True)) 658 659 # TODO: plot residuals 660 #self._plot_residuals(page_id=page_id, data=current_data, 613 661 # fid=fid, 614 # weight=weight, 615 # page_id=page_id, 616 # index=index) 617 618 def complete2D(self, return_data): 619 """ 620 Plot the current 2D data 621 """ 622 self.logic.new2DPlot(return_data) 623 self.createTheoryIndex() 624 625 #output=self._cal_chisqr(data=data, 626 # weight=weight, 627 # fid=fid, 628 # page_id=page_id, 629 # index=index) 630 # self._plot_residuals(page_id=page_id, data=data, fid=fid, 631 # index=index, weight=weight) 662 # weight=weight, index=index) 632 663 633 664 def calcException(self, etype, value, tb):
Note: See TracChangeset
for help on using the changeset viewer.