Changes in / [1bd266b:5e0891b] in sasview


Ignore:
Location:
src/sas
Files:
3 edited

Legend:

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

    re908916 rb0ba43e  
    4242        self.parent = parent 
    4343 
    44         self.setWindowTitle("Dmax Explorer") 
     44        self.setWindowTitle("Dₐₓ Explorer") 
    4545 
    4646        self.pr_state = pr_state 
     
    116116        bck = [] 
    117117        chi2 = [] 
    118         plotable_xs = [] #Introducing this to make sure size of x and y for plotting is the same.8 
     118 
    119119        try: 
    120120            dmin = float(self.model.item(W.DMIN).text()) 
     
    128128 
    129129        original = self.pr_state.d_max 
    130  
    131130        for x in xs: 
    132131            self.pr_state.d_max = x 
     
    141140                bck.append(self.pr_state.background) 
    142141                chi2.append(self.pr_state.chi2) 
    143                 plotable_xs.append(x) 
    144142            except Exception as ex: 
    145143                # This inversion failed, skip this D_max value 
     
    190188            y_unit = "a.u." 
    191189 
    192         data = Data1D(plotable_xs, ys) 
     190        data = Data1D(xs, ys) 
    193191        if self.hasPlot: 
    194192            self.plot.removePlot(None) 
  • src/sas/qtgui/Perspectives/Inversion/InversionPerspective.py

    r34cf92c rb0ba43e  
    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): 
     
    657641        self.calcThread.ready(2.5) 
    658642 
    659         #Perform estimate should be done on value enter this should solve delay problem 
    660         self.performEstimate() 
    661  
    662643    def stopCalcThread(self): 
    663644        """ Stops a thread if it exists and is running """ 
     
    686667                                             error_func=self._threadError, 
    687668                                             completefn=self._estimateNTCompleted, 
    688                                              updatefn=None) 
    689         self.estimationThreadNT.queue() 
    690         self.estimationThreadNT.ready(2.5) 
    691  
    692     def performEstimateDynamicNT(self): 
    693         """ 
    694         Perform parameter estimation 
    695         """ 
    696         from .Thread import EstimateNT 
    697  
    698         self.updateCalculator() 
    699  
    700         # If a thread is already started, stop it 
    701         self.stopEstimateNTThread() 
    702  
    703         pr = self._calculator.clone() 
    704         # Skip the slit settings for the estimation 
    705         # It slows down the application and it doesn't change the estimates 
    706         pr.slit_height = 0.0 
    707         pr.slit_width = 0.0 
    708         nfunc = self.getNFunc() 
    709  
    710         self.estimationThreadNT = EstimateNT(pr, nfunc, 
    711                                              error_func=self._threadError, 
    712                                              completefn=self._estimateDynamicNTCompleted, 
    713669                                             updatefn=None) 
    714670        self.estimationThreadNT.queue() 
     
    737693        self.estimationThread.ready(2.5) 
    738694 
    739     def performEstimateDynamic(self): 
    740         """ 
    741             Perform parameter estimation 
    742         """ 
    743         from .Thread import EstimatePr 
    744  
    745         # If a thread is already started, stop it 
    746         self.stopEstimationThread() 
    747  
    748         self.estimationThread = EstimatePr(self._calculator.clone(), 
    749                                            self.getNFunc(), 
    750                                            error_func=self._threadError, 
    751                                            completefn=self._estimateDynamicCompleted, 
    752                                            updatefn=None) 
    753         self.estimationThread.queue() 
    754         self.estimationThread.ready(2.5) 
    755  
    756695    def stopEstimationThread(self): 
    757696        """ Stop the estimation thread if it exists and is running """ 
     
    766705        ''' Send a signal to the main thread for model update''' 
    767706        self.estimateSignal.emit((alpha, message, elapsed)) 
    768  
    769     def _estimateDynamicCompleted(self, alpha, message, elapsed): 
    770         ''' Send a signal to the main thread for model update''' 
    771         self.estimateDynamicSignal.emit((alpha, message, elapsed)) 
    772707 
    773708    def _estimateUpdate(self, output_tuple): 
     
    786721        self.performEstimateNT() 
    787722 
    788     def _estimateDynamicUpdate(self, output_tuple): 
    789         """ 
    790         Parameter estimation completed, 
    791         display the results to the user 
    792  
    793         :param alpha: estimated best alpha 
    794         :param elapsed: computation time 
    795         """ 
    796         alpha, message, elapsed = output_tuple 
    797         self._calculator.alpha = alpha 
    798         self._calculator.elapsed += self._calculator.elapsed 
    799         if message: 
    800             logger.info(message) 
    801         self.performEstimateDynamicNT() 
    802  
    803723    def _estimateNTCompleted(self, nterms, alpha, message, elapsed): 
    804724        ''' Send a signal to the main thread for model update''' 
    805725        self.estimateNTSignal.emit((nterms, alpha, message, elapsed)) 
    806  
    807     def _estimateDynamicNTCompleted(self, nterms, alpha, message, elapsed): 
    808         ''' Send a signal to the main thread for model update''' 
    809         self.estimateDynamicNTSignal.emit((nterms, alpha, message, elapsed)) 
    810726 
    811727    def _estimateNTUpdate(self, output_tuple): 
     
    831747            self.startThread() 
    832748 
    833     def _estimateDynamicNTUpdate(self, output_tuple): 
    834         """ 
    835         Parameter estimation completed, 
    836         display the results to the user 
    837  
    838         :param alpha: estimated best alpha 
    839         :param nterms: estimated number of terms 
    840         :param elapsed: computation time 
    841         """ 
    842         nterms, alpha, message, elapsed = output_tuple 
    843         self._calculator.elapsed += elapsed 
    844         self._calculator.suggested_alpha = alpha 
    845         self.nTermsSuggested = nterms 
    846         # Save useful info 
    847         self.updateDynamicGuiValues() 
    848         if message: 
    849             logger.info(message) 
    850         if self.isBatch: 
    851             self.acceptAlpha() 
    852             self.acceptNoTerms() 
    853             self.startThread() 
    854  
    855749    def _calculateCompleted(self, out, cov, pr, elapsed): 
    856750        ''' Send a signal to the main thread for model update''' 
  • src/sas/sascalc/pr/invertor.py

    r6701a0b rb8080e1  
    7171        A[j][i] = (Fourier transformed base function for point j) 
    7272 
    73     We then choose a number of r-points, n_r, to evaluate the second 
     73    We them choose a number of r-points, n_r, to evaluate the second 
    7474    derivative of P(r) at. This is used as our regularization term. 
    7575    For a vector r of length n_r, the following n_r rows are set to :: 
     
    144144        x, y, err, d_max, q_min, q_max and alpha 
    145145        """ 
    146         if name == 'x': 
     146        if   name == 'x': 
    147147            if 0.0 in value: 
    148148                msg = "Invertor: one of your q-values is zero. " 
     
    227227        return None 
    228228 
    229     def add_errors(self, yvalues): 
    230         """ 
    231         Adds errors to data set is they are not avaialble 
    232         :return: 
    233         """ 
    234         stats_errors = np.zeros(len(yvalues)) 
    235         for i in range(len(yvalues)): 
    236             # Scale the error so that we can fit over several decades of Q 
    237             scale = 0.05 * np.sqrt(yvalues[i]) 
    238             min_err = 0.01 * yvalues[i] 
    239             stats_errors[i] = scale * np.sqrt(np.fabs(yvalues[i])) + min_err 
    240         logger.warning("Simulated errors have been added to the data set\n") 
    241         return stats_errors 
    242  
    243229    def clone(self): 
    244230        """ 
     
    258244        invertor.x = self.x 
    259245        invertor.y = self.y 
    260         if np.size(self.err) == 0 or np.all(self.err) == 0: 
    261             invertor.err = self.add_errors(self.y) 
    262         else: 
    263             invertor.err = self.err 
     246        invertor.err = self.err 
    264247        invertor.est_bck = self.est_bck 
    265248        invertor.background = self.background 
     
    285268            A[i][j] = (Fourier transformed base function for point j) 
    286269 
    287         We then choose a number of r-points, n_r, to evaluate the second 
     270        We them choose a number of r-points, n_r, to evaluate the second 
    288271        derivative of P(r) at. This is used as our regularization term. 
    289272        For a vector r of length n_r, the following n_r rows are set to :: 
Note: See TracChangeset for help on using the changeset viewer.