- Timestamp:
- Apr 8, 2018 7:33:14 PM (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:
- bb6b037
- Parents:
- 441a03f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Inversion/InversionPerspective.py
r441a03f redd6720 28 28 BACKGROUND_INPUT = 0.0 29 29 MAX_DIST = 140.0 30 DICT_KEYS = ["Calculator", "PrPlot", "DataPlot", "DMaxWindow", "NFuncEst"] 31 32 33 # TODO: Explore window not working 30 DICT_KEYS = ["Calculator", "PrPlot", "DataPlot"] 31 32 34 33 # TODO: Update help with batch capabilities 35 34 # TODO: Method to export results in some meaningful way … … 61 60 # current QStandardItem showing on the panel 62 61 self._data = None 63 # current Data1D as referenced by self._data64 self._data_set = None65 62 # Reference to Dmax window for self._data 66 63 self.dmaxWindow = None … … 78 75 self.calc_thread = None 79 76 self.estimation_thread = None 77 self.estimation_thread_nt = None 80 78 81 79 # Mapping for all data items … … 303 301 self.regConstantSuggestionButton.text())) 304 302 305 def displayChange(self ):303 def displayChange(self, data_index=0): 306 304 """Switch to another item in the data list""" 307 ref_item = self.dataList.itemData(self.dataList.currentIndex()) 308 self.updateDataList(ref_item) 309 self.setCurrentData(ref_item) 305 self.updateDataList(self._data) 306 self.setCurrentData(self.dataList.itemData(data_index)) 310 307 311 308 ###################################################################### … … 314 311 def update_calculator(self): 315 312 """Update all p(r) params""" 316 self._calculator.set_x(self. _data_set.x)317 self._calculator.set_y(self. _data_set.y)318 self._calculator.set_err(self. _data_set.dy)313 self._calculator.set_x(self.logic.data.x) 314 self._calculator.set_y(self.logic.data.y) 315 self._calculator.set_err(self.logic.data.dy) 319 316 self.set_background(self.backgroundInput.text()) 320 317 … … 342 339 self.dmaxWindow.nfunc = self.getNFunc() 343 340 self.dmaxWindow.modelChanged() 344 self.mapper.to First()341 self.mapper.toLast() 345 342 346 343 def help(self): … … 359 356 Toggle the background between manual and estimated 360 357 """ 361 sender = self.sender()362 if sender is self.estimateBgd:358 if self.estimateBgd.isChecked(): 359 self.manualBgd.setChecked(False) 363 360 self.backgroundInput.setEnabled(False) 364 361 self._calculator.set_est_bck = True 365 elif sender is self.manualBgd: 362 elif self.manualBgd.isChecked(): 363 self.estimateBgd.setChecked(False) 366 364 self.backgroundInput.setEnabled(True) 367 365 self._calculator.set_est_bck = False … … 395 393 if data in self._data_list.keys(): 396 394 # Don't add data if it's already in 397 return395 continue 398 396 # Create initial internal mappings 399 self._data_set = GuiUtils.dataFromItem(data) 400 self.logic = InversionLogic(self._data_set) 401 self.populateDataComboBox(self._data_set.filename, data) 397 self.logic.data = GuiUtils.dataFromItem(data) 402 398 # Estimate q range 403 399 qmin, qmax = self.logic.computeDataRange() … … 405 401 self._calculator.set_qmax(qmax) 406 402 self.updateDataList(data) 407 self.setCurrentData(data) 408 # Estimate initial values from data 409 self.performEstimate() 410 self.updateGuiValues() 403 self.populateDataComboBox(self.logic.data.filename, data) 404 self.dataList.setCurrentIndex(len(self.dataList) - 1) 405 self.setCurrentData(data) 411 406 412 407 def updateDataList(self, dataRef): … … 417 412 DICT_KEYS[0]: self._calculator, 418 413 DICT_KEYS[1]: self.pr_plot, 419 DICT_KEYS[2]: self.data_plot, 420 DICT_KEYS[3]: self.dmaxWindow, 421 DICT_KEYS[4]: self.nTermsSuggested 414 DICT_KEYS[2]: self.data_plot 422 415 } 423 416 … … 427 420 nfunc = int(self.noOfTermsInput.text()) 428 421 except ValueError: 429 logging.error("Incorrect number of terms specified: %s" %self.noOfTermsInput.text()) 422 logging.error("Incorrect number of terms specified: %s" 423 %self.noOfTermsInput.text()) 430 424 self.noOfTermsInput.setText(str(NUMBER_OF_TERMS)) 431 425 nfunc = NUMBER_OF_TERMS … … 441 435 # Data references 442 436 self._data = data_ref 443 self. _data_set= GuiUtils.dataFromItem(data_ref)437 self.logic.data = GuiUtils.dataFromItem(data_ref) 444 438 self._calculator = self._data_list[data_ref].get(DICT_KEYS[0]) 445 439 self.pr_plot = self._data_list[data_ref].get(DICT_KEYS[1]) 446 440 self.data_plot = self._data_list[data_ref].get(DICT_KEYS[2]) 447 self.dmaxWindow = self._data_list[data_ref].get(DICT_KEYS[3]) 448 self.nTermsSuggested = self._data_list[data_ref].get(DICT_KEYS[4]) 449 self.logic.set_data = self._data_set 450 self.updateGuiValues() 441 self.performEstimate() 451 442 452 443 def updateGuiValues(self): … … 456 447 elapsed = self._calculator.elapsed 457 448 alpha = self._calculator.suggested_alpha 458 nterms = self._calculator.nfunc459 449 self.model.setItem(WIDGETS.W_QMIN, 460 450 QtGui.QStandardItem("{:.4g}".format(pr.get_qmin()))) … … 496 486 """Remove the existing data reference from the P(r) Persepective""" 497 487 if self.dmaxWindow is not None: 498 self.dmaxWindow. done()488 self.dmaxWindow.close() 499 489 self.dmaxWindow = None 500 490 self.dataList.removeItem(self.dataList.currentIndex()) … … 502 492 # Last file removed 503 493 if len(self._data_list) == 0: 504 self._data = None505 self._data_set = None506 494 self.pr_plot = None 507 495 self.data_plot = None 508 496 self._calculator = Invertor() 509 self.logic.data = self._data_set497 self.logic.data = None 510 498 self.nTermsSuggested = NUMBER_OF_TERMS 511 499 self.noOfTermsSuggestionButton.setText("{:n}".format( … … 513 501 self.regConstantSuggestionButton.setText("{:-3.2g}".format( 514 502 REGULARIZATION)) 515 self. enableButtons()503 self.updateGuiValues() 516 504 self.setupModel() 517 505 else: … … 553 541 from .Thread import EstimateNT 554 542 543 self.update_calculator() 544 555 545 # If a thread is already started, stop it 556 if (self.estimation_thread is not None and557 self.estimation_thread .isrunning()):558 self.estimation_thread .stop()546 if (self.estimation_thread_nt is not None and 547 self.estimation_thread_nt.isrunning()): 548 self.estimation_thread_nt.stop() 559 549 pr = self._calculator.clone() 560 550 # Skip the slit settings for the estimation … … 564 554 nfunc = self.getNFunc() 565 555 566 self.estimation_thread = EstimateNT(pr, nfunc,556 self.estimation_thread_nt = EstimateNT(pr, nfunc, 567 557 error_func=self._threadError, 568 558 completefn=self._estimateNTCompleted, 569 559 updatefn=None) 570 self.estimation_thread .queue()571 self.estimation_thread .ready(2.5)560 self.estimation_thread_nt.queue() 561 self.estimation_thread_nt.ready(2.5) 572 562 573 563 def performEstimate(self): … … 576 566 """ 577 567 from .Thread import EstimatePr 578 579 self.startThread()580 568 581 569 # If a thread is already started, stop it … … 583 571 self.estimation_thread.isrunning()): 584 572 self.estimation_thread.stop() 585 pr = self._calculator.clone() 586 nfunc = self.getNFunc() 587 self.estimation_thread = EstimatePr(pr, nfunc, 573 self.estimation_thread = EstimatePr(self._calculator.clone(), 574 self.getNFunc(), 588 575 error_func=self._threadError, 589 576 completefn=self._estimateCompleted,
Note: See TracChangeset
for help on using the changeset viewer.