Changeset f1ec901 in sasview for src/sas/qtgui/Perspectives/Inversion/InversionPerspective.py
- Timestamp:
- Nov 21, 2017 5:21:57 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:
- 0580c77
- Parents:
- 0261bc1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Inversion/InversionPerspective.py
r6a3e1fe rf1ec901 38 38 39 39 name = "Inversion" 40 estimateSignal = QtCore.pyqtSignal(tuple) 41 estimateNTSignal = QtCore.pyqtSignal(tuple) 42 calculateSignal = QtCore.pyqtSignal(tuple) 40 43 41 44 def __init__(self, parent=None, data=None): … … 76 79 for datum in data_list: 77 80 self._data_list[datum] = self._calculator.clone() 81 82 # dict of models for quick update after calculation 83 # {item:model} 84 self._models = {} 78 85 79 86 # plots for current data … … 132 139 """Connect the use controls to their appropriate methods""" 133 140 self.dataList.currentIndexChanged.connect(self.displayChange) 134 #self.calculateAllButton.clicked.connect(self.startThreadAll)135 #self.calculateThisButton.clicked.connect(self.startThread)141 self.calculateAllButton.clicked.connect(self.startThreadAll) 142 self.calculateThisButton.clicked.connect(self.startThread) 136 143 self.removeButton.clicked.connect(self.removeData) 137 144 self.helpButton.clicked.connect(self.help) … … 141 148 self.noOfTermsSuggestionButton.clicked.connect(self.acceptNoTerms) 142 149 self.explorerButton.clicked.connect(self.openExplorerWindow) 143 self.backgroundInput.textChanged.connect( 150 151 self.backgroundInput.editingFinished.connect( 144 152 lambda: self._calculator.set_est_bck(int(is_float( 145 s tr(self.backgroundInput.text())))))146 self.minQInput. textChanged.connect(153 self.backgroundInput.text())))) 154 self.minQInput.editingFinished.connect( 147 155 lambda: self._calculator.set_qmin(is_float( 148 s tr(self.minQInput.text()))))149 self.regularizationConstantInput. textChanged.connect(156 self.minQInput.text()))) 157 self.regularizationConstantInput.editingFinished.connect( 150 158 lambda: self._calculator.set_alpha(is_float( 151 s tr(self.regularizationConstantInput.text()))))152 self.maxDistanceInput. textChanged.connect(159 self.regularizationConstantInput.text()))) 160 self.maxDistanceInput.editingFinished.connect( 153 161 lambda: self._calculator.set_dmax(is_float( 154 s tr(self.maxDistanceInput.text()))))155 self.maxQInput. textChanged.connect(162 self.maxDistanceInput.text()))) 163 self.maxQInput.editingFinished.connect( 156 164 lambda: self._calculator.set_qmax(is_float( 157 s tr(self.maxQInput.text()))))158 self.slitHeightInput. textChanged.connect(165 self.maxQInput.text()))) 166 self.slitHeightInput.editingFinished.connect( 159 167 lambda: self._calculator.set_slit_height(is_float( 160 s tr(self.slitHeightInput.text()))))161 self.slitWidthInput. textChanged.connect(168 self.slitHeightInput.text()))) 169 self.slitWidthInput.editingFinished.connect( 162 170 lambda: self._calculator.set_slit_width(is_float( 163 str(self.slitHeightInput.text())))) 171 self.slitHeightInput.text()))) 172 164 173 self.model.itemChanged.connect(self.model_changed) 174 self.estimateNTSignal.connect(self._estimateNTUpdate) 175 self.estimateSignal.connect(self._estimateUpdate) 176 self.calculateSignal.connect(self._calculateUpdate) 165 177 166 178 def setupMapper(self): … … 208 220 # Main Buttons 209 221 self.mapper.addMapping(self.removeButton, WIDGETS.W_REMOVE) 210 #self.mapper.addMapping(self.calculateAllButton, WIDGETS.W_CALCULATE_ALL)211 #self.mapper.addMapping(self.calculateThisButton,212 #WIDGETS.W_CALCULATE_VISIBLE)222 self.mapper.addMapping(self.calculateAllButton, WIDGETS.W_CALCULATE_ALL) 223 self.mapper.addMapping(self.calculateThisButton, 224 WIDGETS.W_CALCULATE_VISIBLE) 213 225 self.mapper.addMapping(self.helpButton, WIDGETS.W_HELP) 214 226 … … 269 281 self.removeButton.setEnabled(self.logic.data_is_loaded) 270 282 self.explorerButton.setEnabled(self.logic.data_is_loaded) 271 #self.calculateAllButton.setEnabled(self.logic.data_is_loaded)272 #self.calculateThisButton.setEnabled(self.logic.data_is_loaded)273 283 274 284 def populateDataComboBox(self, filename, data_ref): … … 291 301 292 302 def displayChange(self): 293 variant_ref = self.dataList.itemData(self.dataList.currentIndex()) 294 self.setCurrentData(variant_ref) 303 ref_item = self.dataList.itemData(self.dataList.currentIndex()) 304 self._model_item = ref_item 305 self.setCurrentData(ref_item) 306 self.setCurrentModel(ref_item) 295 307 296 308 def removeData(self): … … 304 316 ###################################################################### 305 317 # GUI Interaction Events 318 319 def setCurrentModel(self, ref_item): 320 '''update the current model with stored values''' 321 if ref_item in self._models: 322 self.model = self._models[ref_item] 306 323 307 324 def update_calculator(self): … … 394 411 self.model.setItem(WIDGETS.W_QMIN, QtGui.QStandardItem("{:.4g}".format(qmin))) 395 412 self.model.setItem(WIDGETS.W_QMAX, QtGui.QStandardItem("{:.4g}".format(qmax))) 413 self._models[data] = self.model 414 self.model_item = data 396 415 397 416 self.enableButtons() … … 417 436 self.pr_plot = self.pr_plot_list[data_ref] 418 437 self.data_plot = self.data_plot_list[data_ref] 419 # Rerun the calculations for the current set420 self.startThread()421 self.model_changed()422 438 423 439 ###################################################################### … … 448 464 self.calc_thread = CalcPr(pr, nfunc, 449 465 error_func=self._threadError, 450 completefn=self._completed, updatefn=None) 466 completefn=self._calculateCompleted, 467 updatefn=None) 451 468 self.calc_thread.queue() 452 469 self.calc_thread.ready(2.5) … … 454 471 def performEstimateNT(self): 455 472 """ 456 473 Perform parameter estimation 457 474 """ 458 475 from .Thread import EstimateNT … … 468 485 pr.slit_width = 0.0 469 486 nfunc = self.getNFunc() 487 470 488 self.estimation_thread = EstimateNT(pr, nfunc, 471 489 error_func=self._threadError, … … 500 518 501 519 def _estimateCompleted(self, alpha, message, elapsed): 520 ''' Send a signal to the main thread for model update''' 521 self.estimateSignal.emit((alpha, message, elapsed)) 522 523 def _estimateUpdate(self, output_tuple): 502 524 """ 503 525 Parameter estimation completed, … … 507 529 :param elapsed: computation time 508 530 """ 531 alpha, message, elapsed = output_tuple 509 532 # Save useful info 510 533 self.model.setItem(WIDGETS.W_COMP_TIME, QtGui.QStandardItem(str(elapsed))) … … 516 539 517 540 def _estimateNTCompleted(self, nterms, alpha, message, elapsed): 541 ''' Send a signal to the main thread for model update''' 542 self.estimateNTSignal.emit((nterms, alpha, message, elapsed)) 543 544 def _estimateNTUpdate(self, output_tuple): 518 545 """ 519 546 Parameter estimation completed, … … 523 550 :param nterms: estimated number of terms 524 551 :param elapsed: computation time 525 526 """552 """ 553 nterms, alpha, message, elapsed = output_tuple 527 554 # Save useful info 528 555 self.noOfTermsSuggestionButton.setText("{:n}".format(nterms)) … … 531 558 self.regConstantSuggestionButton.setEnabled(True) 532 559 self.model.setItem(WIDGETS.W_COMP_TIME, QtGui.QStandardItem(str(elapsed))) 533 #self.PrTabWidget.setCurrentIndex(0)534 560 if message: 535 561 logging.info(message) 536 562 537 def _completed(self, out, cov, pr, elapsed): 563 def _calculateCompleted(self, out, cov, pr, elapsed): 564 ''' Send a signal to the main thread for model update''' 565 self.calculateSignal.emit((out, cov, pr, elapsed)) 566 567 def _calculateUpdate(self, output_tuple): 538 568 """ 539 569 Method called with the results when the inversion is done … … 543 573 :param pr: Invertor instance 544 574 :param elapsed: time spent computing 545 546 """575 """ 576 out, cov, pr, elapsed = output_tuple 547 577 # Save useful info 548 578 cov = np.ascontiguousarray(cov) … … 572 602 # Append data to data list 573 603 self._data_list[self._data] = self._calculator.clone() 604 605 # Update model dict 606 self._models[self.model_item] = self.model 574 607 575 608 # Create new P(r) and fit plots
Note: See TracChangeset
for help on using the changeset viewer.