Changeset 57ad773 in sasview for src/sas/qtgui/Perspectives/Inversion/InversionPerspective.py
- Timestamp:
- Oct 28, 2017 10:02:15 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:
- d132f33
- Parents:
- e7651ff
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Inversion/InversionPerspective.py
re7651ff r57ad773 12 12 # pr inversion GUI elements 13 13 from InversionUtils import WIDGETS 14 import UI.Tabbed PrInversionUI15 from UI.Tabbed PrInversionUI import Ui_PrInversion14 import UI.TabbedInversionUI 15 from UI.TabbedInversionUI import Ui_PrInversion 16 16 from InversionLogic import InversionLogic 17 17 … … 118 118 """Connect the use controls to their appropriate methods""" 119 119 self.enableButtons() 120 self.checkBgdClicked(False)121 120 # TODO: enable the drop down box once batch is working 122 121 self.dataList.setEnabled(False) … … 130 129 self.noOfTermsSuggestionButton.clicked.connect(self.acceptNoTerms) 131 130 self.explorerButton.clicked.connect(self.openExplorerWindow) 131 self.backgroundInput.textChanged.connect( 132 lambda: self._calculator.set_est_bck(int(is_float( 133 str(self.backgroundInput.text()))))) 134 self.minQInput.textChanged.connect( 135 lambda: self._calculator.set_qmin(is_float( 136 str(self.minQInput.text())))) 137 self.regularizationConstantInput.textChanged.connect( 138 lambda: self._calculator.set_alpha(is_float( 139 str(self.regularizationConstantInput.text())))) 140 self.maxDistanceInput.textChanged.connect( 141 lambda: self._calculator.set_dmax(is_float( 142 str(self.maxDistanceInput.text())))) 143 self.maxQInput.textChanged.connect( 144 lambda: self._calculator.set_qmax(is_float( 145 str(self.maxQInput.text())))) 146 self.slitHeightInput.textChanged.connect( 147 lambda: self._calculator.set_slit_height(is_float( 148 str(self.slitHeightInput.text())))) 149 self.slitWidthInput.textChanged.connect( 150 lambda: self._calculator.set_slit_width(is_float( 151 str(self.slitHeightInput.text())))) 132 152 self.model.itemChanged.connect(self.model_changed) 153 self.estimateBgd.setChecked(True) 133 154 134 155 def setupMapper(self): … … 255 276 256 277 def update_calculator(self): 257 """Update all p(r) params . Take all GUI values as an override"""278 """Update all p(r) params""" 258 279 self._calculator.set_x(self._data_set.x) 259 280 self._calculator.set_y(self._data_set.y) 260 281 self._calculator.set_err(self._data_set.dy) 261 self._calculator.set_qmin(is_float(UI.TabbedPrInversionUI._fromUtf8(262 self.minQInput.text())))263 self._calculator.set_qmax(is_float(UI.TabbedPrInversionUI._fromUtf8(264 self.maxQInput.text())))265 self._calculator.set_alpha(is_float(UI.TabbedPrInversionUI._fromUtf8(266 self.regularizationConstantInput.text())))267 self._calculator.set_dmax(is_float(UI.TabbedPrInversionUI._fromUtf8(268 self.maxDistanceInput.text())))269 self._calculator.set_est_bck(int(is_float(270 UI.TabbedPrInversionUI._fromUtf8(self.backgroundInput.text()))))271 self._calculator.set_slit_height(is_float(272 UI.TabbedPrInversionUI._fromUtf8(self.slitHeightInput.text())))273 self._calculator.set_slit_width(is_float(274 UI.TabbedPrInversionUI._fromUtf8(self.slitWidthInput.text())))275 282 276 283 def _calculation(self): … … 278 285 Calculate the P(r) for every data set in the data list 279 286 """ 280 # Pull in any GUI changesbefore running the calculations287 # Set data before running the calculations 281 288 self.update_calculator() 282 289 # Run … … 287 294 if not self.mapper: 288 295 return 289 # TODO: Update plots 296 if self.pr_plot is not None: 297 title = self.pr_plot.name 298 GuiUtils.updateModelItemWithPlot( 299 self._data, QtCore.QVariant(self.pr_plot), title) 300 if self.data_plot is not None: 301 title = self.data_plot.name 302 GuiUtils.updateModelItemWithPlot( 303 self._data, QtCore.QVariant(self.data_plot), title) 290 304 self.mapper.toFirst() 291 305 … … 303 317 self._helpView.show() 304 318 305 def checkBgdClicked(self, boolean=None): 306 if boolean or self.manualBgd.isChecked(): 307 self.manualBgd.setChecked(True) 308 self.toggleBgd(self.manualBgd) 309 else: 310 self.estimateBgd.setChecked(True) 311 self.toggleBgd(self.estimateBgd) 312 313 def toggleBgd(self, item=None): 319 def toggleBgd(self): 314 320 """ 315 321 Toggle the background between manual and estimated 316 322 :param item: gui item that was triggered 317 323 """ 318 if not item: 319 self.checkBgdClicked() 320 elif isinstance(item, QtGui.QRadioButton): 321 if item is self.estimateBgd: 322 self.backgroundInput.setEnabled(False) 323 else: 324 self.backgroundInput.setEnabled(True) 324 sender = self.sender() 325 if sender is self.estimateBgd: 326 self.backgroundInput.setEnabled(False) 327 else: 328 self.backgroundInput.setEnabled(True) 325 329 326 330 def openExplorerWindow(self): … … 353 357 self._data = data 354 358 self._data_set = GuiUtils.dataFromItem(data) 355 self.enableButtons()356 359 self.populateDataComboBox(self._data_set.filename) 357 360 358 361 # Estimate initial values from data 359 362 self.performEstimate() 360 self.logic.data(self._calculator) 361 362 self._manager.createGuiData(None) 363 364 # TODO: Finish plotting 365 if self.pr_plot is None: 366 self.pr_plot = None 367 #self.pr_plot = self.logic.new1DPlot(self._calculator) 368 if self.data_plot is None: 369 self.data_plot = None 370 371 qmin, qmax, _ = self.logic.computeDataRange() 372 title = self._data.filename 363 self.logic = InversionLogic(self._data_set) 364 365 qmin, qmax = self.logic.computeDataRange() 373 366 374 367 self.model.setItem(WIDGETS.W_QMIN, QtGui.QStandardItem( … … 376 369 self.model.setItem(WIDGETS.W_QMAX, QtGui.QStandardItem( 377 370 "{:.4g}".format(qmax))) 378 #reactor.callFromThread(GuiUtils.updateModelItemWithPlot, 379 # self._model_item, self._communicator, title)371 372 self.enableButtons() 380 373 381 374 # TODO: Only load 1st data until batch mode working. Thus, break … … 395 388 self.calc_thread.stop() 396 389 pr = self._calculator.clone() 397 nfunc = int(UI.Tabbed PrInversionUI._fromUtf8(390 nfunc = int(UI.TabbedInversionUI._fromUtf8( 398 391 self.noOfTermsInput.text())) 399 392 self.calc_thread = CalcPr(pr, nfunc, … … 418 411 pr.slit_height = 0.0 419 412 pr.slit_width = 0.0 420 nfunc = int(UI.Tabbed PrInversionUI._fromUtf8(413 nfunc = int(UI.TabbedInversionUI._fromUtf8( 421 414 self.noOfTermsInput.text())) 422 415 self.estimation_thread = EstimateNT(pr, nfunc, … … 440 433 self.estimation_thread.stop() 441 434 pr = self._calculator.clone() 442 nfunc = int(UI.Tabbed PrInversionUI._fromUtf8(435 nfunc = int(UI.TabbedInversionUI._fromUtf8( 443 436 self.noOfTermsInput.text())) 444 437 self.estimation_thread = EstimatePr(pr, nfunc, … … 503 496 """ 504 497 # Save useful info 505 # Keep a copy of the last result506 self._last_calculator = pr.clone()507 508 # Save Pr invertor509 self._calculator = pr510 498 cov = np.ascontiguousarray(cov) 499 pr.cov = cov 500 pr.out = out 501 pr.elapsed = elapsed 511 502 512 503 # Show result on control panel … … 533 524 # Display results tab 534 525 self.PrTabWidget.setCurrentIndex(1) 526 # Save Pr invertor 527 self._calculator = pr 528 # Append data to data list 535 529 self._data_list.append({self._data: pr}) 536 530 537 # TODO: Show plots - Really, this should be linked to the inputs, etc, 538 # TODO: so it should happen automagically 539 # Show I(q) fit 540 # self.show_iq(out, self._calculator) 541 # Show P(r) fit 542 # self.show_pr(out, self._calculator, cov) 531 if self.pr_plot is None: 532 self.pr_plot = self.logic.newPRPlot(out, self._calculator, cov) 533 if self.data_plot is None: 534 self.data_plot = self.logic.new1DPlot(out, self._calculator) 543 535 544 536 def _threadError(self, error):
Note: See TracChangeset
for help on using the changeset viewer.