Changeset 8f83719f in sasview for src/sas/qtgui/Perspectives/Inversion/InversionPerspective.py
- Timestamp:
- Nov 24, 2017 9:57:08 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:
- f4480f0
- Parents:
- cb4d219
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Inversion/InversionPerspective.py
r0580c77 r8f83719f 26 26 27 27 28 # TODO: Remove data29 28 # TODO: Modify plot references, don't just send new 30 29 # TODO: Update help with batch capabilities 31 # TODO: Easy way to scroll through results - no tabs in window(?) - 'spreadsheet'32 30 # TODO: Method to export results in some meaningful way 33 #class InversionWindow(QtWidgets.QTabWidget, Ui_PrInversion):34 31 class InversionWindow(QtWidgets.QDialog, Ui_PrInversion): 35 32 """ … … 55 52 56 53 self.logic = InversionLogic() 54 55 # Reference to Dmax window 56 self.dmaxWindow = None 57 57 58 58 # The window should not close … … 84 84 self._models = {} 85 85 86 self.calculateAllButton.setEnabled(False) 87 self.calculateThisButton.setEnabled(False) 88 86 89 # plots for current data 87 90 self.pr_plot = None … … 93 96 self.model = QtGui.QStandardItemModel(self) 94 97 self.mapper = QtWidgets.QDataWidgetMapper(self) 98 99 # Add validators 100 self.setupValidators() 95 101 # Link user interactions with methods 96 102 self.setupLinks() … … 150 156 151 157 self.backgroundInput.editingFinished.connect( 152 lambda: self._calculator.set_est_bck(int(is_float( 153 self.backgroundInput.text())))) 158 lambda: self._calculator.set_est_bck(int(is_float(self.backgroundInput.text())))) 154 159 self.minQInput.editingFinished.connect( 155 lambda: self._calculator.set_qmin(is_float( 156 self.minQInput.text()))) 160 lambda: self._calculator.set_qmin(is_float(self.minQInput.text()))) 157 161 self.regularizationConstantInput.editingFinished.connect( 158 lambda: self._calculator.set_alpha(is_float( 159 self.regularizationConstantInput.text()))) 162 lambda: self._calculator.set_alpha(is_float(self.regularizationConstantInput.text()))) 160 163 self.maxDistanceInput.editingFinished.connect( 161 lambda: self._calculator.set_dmax(is_float( 162 self.maxDistanceInput.text()))) 164 lambda: self._calculator.set_dmax(is_float(self.maxDistanceInput.text()))) 163 165 self.maxQInput.editingFinished.connect( 164 lambda: self._calculator.set_qmax(is_float( 165 self.maxQInput.text()))) 166 lambda: self._calculator.set_qmax(is_float(self.maxQInput.text()))) 166 167 self.slitHeightInput.editingFinished.connect( 167 lambda: self._calculator.set_slit_height(is_float( 168 self.slitHeightInput.text()))) 168 lambda: self._calculator.set_slit_height(is_float(self.slitHeightInput.text()))) 169 169 self.slitWidthInput.editingFinished.connect( 170 lambda: self._calculator.set_slit_width(is_float( 171 self.slitHeightInput.text()))) 170 lambda: self._calculator.set_slit_width(is_float(self.slitHeightInput.text()))) 172 171 173 172 self.model.itemChanged.connect(self.model_changed) … … 197 196 198 197 # Parameter Items 199 self.mapper.addMapping(self.regularizationConstantInput, 200 WIDGETS.W_REGULARIZATION) 201 self.mapper.addMapping(self.regConstantSuggestionButton, 202 WIDGETS.W_REGULARIZATION_SUGGEST) 198 self.mapper.addMapping(self.regularizationConstantInput, WIDGETS.W_REGULARIZATION) 199 self.mapper.addMapping(self.regConstantSuggestionButton, WIDGETS.W_REGULARIZATION_SUGGEST) 203 200 self.mapper.addMapping(self.explorerButton, WIDGETS.W_EXPLORE) 204 201 self.mapper.addMapping(self.maxDistanceInput, WIDGETS.W_MAX_DIST) 205 202 self.mapper.addMapping(self.noOfTermsInput, WIDGETS.W_NO_TERMS) 206 self.mapper.addMapping(self.noOfTermsSuggestionButton, 207 WIDGETS.W_NO_TERMS_SUGGEST) 203 self.mapper.addMapping(self.noOfTermsSuggestionButton, WIDGETS.W_NO_TERMS_SUGGEST) 208 204 209 205 # Output … … 215 211 self.mapper.addMapping(self.oscillationValue, WIDGETS.W_OSCILLATION) 216 212 self.mapper.addMapping(self.posFractionValue, WIDGETS.W_POS_FRACTION) 217 self.mapper.addMapping(self.sigmaPosFractionValue, 218 WIDGETS.W_SIGMA_POS_FRACTION) 213 self.mapper.addMapping(self.sigmaPosFractionValue, WIDGETS.W_SIGMA_POS_FRACTION) 219 214 220 215 # Main Buttons 221 216 self.mapper.addMapping(self.removeButton, WIDGETS.W_REMOVE) 222 217 self.mapper.addMapping(self.calculateAllButton, WIDGETS.W_CALCULATE_ALL) 223 self.mapper.addMapping(self.calculateThisButton, 224 WIDGETS.W_CALCULATE_VISIBLE) 218 self.mapper.addMapping(self.calculateThisButton, WIDGETS.W_CALCULATE_VISIBLE) 225 219 self.mapper.addMapping(self.helpButton, WIDGETS.W_HELP) 226 220 … … 268 262 def setupWindow(self): 269 263 """Initialize base window state on init""" 270 #self.setTabPosition(0)271 264 self.enableButtons() 272 265 self.estimateBgd.setChecked(True) 273 266 267 def setupValidators(self): 268 """Apply validators to editable line edits""" 269 self.noOfTermsInput.setValidator(QtGui.QIntValidator()) 270 self.regularizationConstantInput.setValidator(GuiUtils.DoubleValidator()) 271 self.maxDistanceInput.setValidator(GuiUtils.DoubleValidator()) 272 self.minQInput.setValidator(GuiUtils.DoubleValidator()) 273 self.maxQInput.setValidator(GuiUtils.DoubleValidator()) 274 self.slitHeightInput.setValidator(GuiUtils.DoubleValidator()) 275 self.slitWidthInput.setValidator(GuiUtils.DoubleValidator()) 276 274 277 ###################################################################### 275 278 # Methods for updating GUI … … 279 282 Enable buttons when data is present, else disable them 280 283 """ 284 self.calculateAllButton.setEnabled(self.logic.data_is_loaded) 285 self.calculateThisButton.setEnabled(self.logic.data_is_loaded) 281 286 self.removeButton.setEnabled(self.logic.data_is_loaded) 282 287 self.explorerButton.setEnabled(self.logic.data_is_loaded) … … 311 316 self.pr_plot_list.pop(self._data) 312 317 self.data_plot_list.pop(self._data) 318 if self.dmaxWindow is not None: 319 self.dmaxWindow = None 313 320 self.dataList.removeItem(self.dataList.currentIndex()) 314 321 self.dataList.setCurrentIndex(0) 322 # Last file removed 323 if not self._data_list: 324 self._data = None 325 self.pr_plot = None 326 self._data_set = None 327 self.calculateThisButton.setEnabled(False) 328 self.calculateAllButton.setEnabled(False) 329 self.explorerButton.setEnabled(False) 315 330 316 331 ###################################################################### … … 345 360 title = self.data_plot.name 346 361 GuiUtils.updateModelItemWithPlot(self._data, self.data_plot, title) 362 if self.dmaxWindow is not None: 363 self.dmaxWindow.pr_state = self._calculator 364 self.dmaxWindow.nfunc = self.getNFunc() 365 347 366 self.mapper.toFirst() 348 367 … … 374 393 Open the Explorer window to see correlations between params and results 375 394 """ 376 # TODO: Link Invertor() and DmaxWindow so window updates when recalculated377 395 from .DMaxExplorerWidget import DmaxWindow 378 396 self.dmaxWindow = DmaxWindow(self._calculator, self.getNFunc(), self) … … 395 413 396 414 for data in data_item: 415 if data in self._data_list.keys(): 416 # Don't add data if it's already in 417 return 397 418 # Create initial internal mappings 398 419 self._data_list[data] = self._calculator.clone() … … 439 460 ###################################################################### 440 461 # Thread Creators 441 442 # TODO: Move to individual class(?)443 444 462 def startThreadAll(self): 445 463 for data_ref, pr in list(self._data_list.items()): … … 531 549 alpha, message, elapsed = output_tuple 532 550 # Save useful info 533 self.model.setItem(WIDGETS.W_COMP_TIME, QtGui.QStandardItem( str(elapsed)))551 self.model.setItem(WIDGETS.W_COMP_TIME, QtGui.QStandardItem("{:.4g}".format(elapsed))) 534 552 self.regConstantSuggestionButton.setText("{:-3.2g}".format(alpha)) 535 553 self.regConstantSuggestionButton.setEnabled(True) … … 582 600 583 601 # Show result on control panel 584 585 # TODO: Connect self._calculator to GUI - two-to-one connection possible? 586 self.model.setItem(WIDGETS.W_RG, QtGui.QStandardItem(str(pr.rg(out)))) 587 self.model.setItem(WIDGETS.W_I_ZERO, QtGui.QStandardItem(str(pr.iq0(out)))) 602 self.model.setItem(WIDGETS.W_RG, QtGui.QStandardItem("{:.3g}".format(pr.rg(out)))) 603 self.model.setItem(WIDGETS.W_I_ZERO, QtGui.QStandardItem("{:.3g}".format(pr.iq0(out)))) 588 604 self.model.setItem(WIDGETS.W_BACKGROUND_INPUT, 589 605 QtGui.QStandardItem("{:.3f}".format(pr.est_bck))) 590 self.model.setItem(WIDGETS.W_BACKGROUND_OUTPUT, QtGui.QStandardItem( str(pr.background)))591 self.model.setItem(WIDGETS.W_CHI_SQUARED, QtGui.QStandardItem( str(pr.chi2[0])))592 self.model.setItem(WIDGETS.W_COMP_TIME, QtGui.QStandardItem( str(elapsed)))593 self.model.setItem(WIDGETS.W_OSCILLATION, QtGui.QStandardItem( str(pr.oscillations(out))))594 self.model.setItem(WIDGETS.W_POS_FRACTION, QtGui.QStandardItem( str(pr.get_positive(out))))606 self.model.setItem(WIDGETS.W_BACKGROUND_OUTPUT, QtGui.QStandardItem("{:.3g}".format(pr.background))) 607 self.model.setItem(WIDGETS.W_CHI_SQUARED, QtGui.QStandardItem("{:.3g}".format(pr.chi2[0]))) 608 self.model.setItem(WIDGETS.W_COMP_TIME, QtGui.QStandardItem("{:.2g}".format(elapsed))) 609 self.model.setItem(WIDGETS.W_OSCILLATION, QtGui.QStandardItem("{:.3g}".format(pr.oscillations(out)))) 610 self.model.setItem(WIDGETS.W_POS_FRACTION, QtGui.QStandardItem("{:.3g}".format(pr.get_positive(out)))) 595 611 self.model.setItem(WIDGETS.W_SIGMA_POS_FRACTION, 596 QtGui.QStandardItem( str(pr.get_pos_err(out, cov))))612 QtGui.QStandardItem("{:.3g}".format(pr.get_pos_err(out, cov)))) 597 613 598 614 # Save Pr invertor
Note: See TracChangeset
for help on using the changeset viewer.