Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Perspectives/Inversion/InversionPerspective.py

    r28965e9 r2b8286c  
    4343    estimateSignal = QtCore.pyqtSignal(tuple) 
    4444    estimateNTSignal = QtCore.pyqtSignal(tuple) 
    45     estimateDynamicNTSignal = QtCore.pyqtSignal(tuple) 
    46     estimateDynamicSignal = QtCore.pyqtSignal(tuple) 
    4745    calculateSignal = QtCore.pyqtSignal(tuple) 
    4846 
     
    196194        self.model.itemChanged.connect(self.model_changed) 
    197195        self.estimateNTSignal.connect(self._estimateNTUpdate) 
    198         self.estimateDynamicNTSignal.connect(self._estimateDynamicNTUpdate) 
    199         self.estimateDynamicSignal.connect(self._estimateDynamicUpdate) 
    200196        self.estimateSignal.connect(self._estimateUpdate) 
    201197        self.calculateSignal.connect(self._calculateUpdate) 
    202  
    203         self.maxDistanceInput.textEdited.connect(self.performEstimateDynamic) 
    204198 
    205199    def setupMapper(self): 
     
    315309                                            and not self.isCalculating) 
    316310        self.removeButton.setEnabled(self.logic.data_is_loaded) 
    317         self.explorerButton.setEnabled(self.logic.data_is_loaded) 
     311        self.explorerButton.setEnabled(self.logic.data_is_loaded 
     312                                       and np.all(self.logic.data.dy != 0)) 
    318313        self.stopButton.setVisible(self.isCalculating) 
    319314        self.regConstantSuggestionButton.setEnabled( 
     
    506501        self.dataPlot = self._dataList[data_ref].get(DICT_KEYS[2]) 
    507502        self.performEstimate() 
    508  
    509     def updateDynamicGuiValues(self): 
    510         pr = self._calculator 
    511         alpha = self._calculator.suggested_alpha 
    512         self.model.setItem(WIDGETS.W_MAX_DIST, 
    513                             QtGui.QStandardItem("{:.4g}".format(pr.get_dmax()))) 
    514         self.regConstantSuggestionButton.setText("{:-3.2g}".format(alpha)) 
    515         self.noOfTermsSuggestionButton.setText( 
    516              "{:n}".format(self.nTermsSuggested)) 
    517  
    518         self.enableButtons() 
    519503 
    520504    def updateGuiValues(self): 
     
    536520        self.model.setItem(WIDGETS.W_MAX_DIST, 
    537521                           QtGui.QStandardItem("{:.4g}".format(pr.get_dmax()))) 
     522        self.regConstantSuggestionButton.setText("{:-3.2g}".format(alpha)) 
     523        self.noOfTermsSuggestionButton.setText( 
     524            "{:n}".format(self.nTermsSuggested)) 
    538525 
    539526        if isinstance(pr.chi2, np.ndarray): 
     
    684671        self.estimationThreadNT.ready(2.5) 
    685672 
    686     def performEstimateDynamicNT(self): 
    687         """ 
    688         Perform parameter estimation 
    689         """ 
    690         from .Thread import EstimateNT 
    691  
    692         self.updateCalculator() 
    693  
    694         # If a thread is already started, stop it 
    695         self.stopEstimateNTThread() 
    696  
    697         pr = self._calculator.clone() 
    698         # Skip the slit settings for the estimation 
    699         # It slows down the application and it doesn't change the estimates 
    700         pr.slit_height = 0.0 
    701         pr.slit_width = 0.0 
    702         nfunc = self.getNFunc() 
    703  
    704         self.estimationThreadNT = EstimateNT(pr, nfunc, 
    705                                              error_func=self._threadError, 
    706                                              completefn=self._estimateDynamicNTCompleted, 
    707                                              updatefn=None) 
    708         self.estimationThreadNT.queue() 
    709         self.estimationThreadNT.ready(2.5) 
    710  
    711673    def stopEstimateNTThread(self): 
    712674        if (self.estimationThreadNT is not None and 
     
    731693        self.estimationThread.ready(2.5) 
    732694 
    733     def performEstimateDynamic(self): 
    734         """ 
    735             Perform parameter estimation 
    736         """ 
    737         from .Thread import EstimatePr 
    738  
    739         # If a thread is already started, stop it 
    740         self.stopEstimationThread() 
    741  
    742         self.estimationThread = EstimatePr(self._calculator.clone(), 
    743                                            self.getNFunc(), 
    744                                            error_func=self._threadError, 
    745                                            completefn=self._estimateDynamicCompleted, 
    746                                            updatefn=None) 
    747         self.estimationThread.queue() 
    748         self.estimationThread.ready(2.5) 
    749  
    750695    def stopEstimationThread(self): 
    751696        """ Stop the estimation thread if it exists and is running """ 
     
    760705        ''' Send a signal to the main thread for model update''' 
    761706        self.estimateSignal.emit((alpha, message, elapsed)) 
    762  
    763     def _estimateDynamicCompleted(self, alpha, message, elapsed): 
    764         ''' Send a signal to the main thread for model update''' 
    765         self.estimateDynamicSignal.emit((alpha, message, elapsed)) 
    766707 
    767708    def _estimateUpdate(self, output_tuple): 
     
    779720            logger.info(message) 
    780721        self.performEstimateNT() 
    781         self.performEstimateDynamicNT() 
    782  
    783     def _estimateDynamicUpdate(self, output_tuple): 
    784         """ 
    785         Parameter estimation completed, 
    786         display the results to the user 
    787  
    788         :param alpha: estimated best alpha 
    789         :param elapsed: computation time 
    790         """ 
    791         alpha, message, elapsed = output_tuple 
    792         self._calculator.alpha = alpha 
    793         self._calculator.elapsed += self._calculator.elapsed 
    794         if message: 
    795             logger.info(message) 
    796         self.performEstimateDynamicNT() 
    797722 
    798723    def _estimateNTCompleted(self, nterms, alpha, message, elapsed): 
    799724        ''' Send a signal to the main thread for model update''' 
    800725        self.estimateNTSignal.emit((nterms, alpha, message, elapsed)) 
    801  
    802     def _estimateDynamicNTCompleted(self, nterms, alpha, message, elapsed): 
    803         ''' Send a signal to the main thread for model update''' 
    804         self.estimateDynamicNTSignal.emit((nterms, alpha, message, elapsed)) 
    805726 
    806727    def _estimateNTUpdate(self, output_tuple): 
     
    826747            self.startThread() 
    827748 
    828     def _estimateDynamicNTUpdate(self, output_tuple): 
    829         """ 
    830         Parameter estimation completed, 
    831         display the results to the user 
    832  
    833         :param alpha: estimated best alpha 
    834         :param nterms: estimated number of terms 
    835         :param elapsed: computation time 
    836         """ 
    837         nterms, alpha, message, elapsed = output_tuple 
    838         self._calculator.elapsed += elapsed 
    839         self._calculator.suggested_alpha = alpha 
    840         self.nTermsSuggested = nterms 
    841         # Save useful info 
    842         self.updateDynamicGuiValues() 
    843         if message: 
    844             logger.info(message) 
    845         if self.isBatch: 
    846             self.acceptAlpha() 
    847             self.acceptNoTerms() 
    848             self.startThread() 
    849  
    850749    def _calculateCompleted(self, out, cov, pr, elapsed): 
    851750        ''' Send a signal to the main thread for model update''' 
Note: See TracChangeset for help on using the changeset viewer.