Changes in / [e2451f2:86d3207] in sasview


Ignore:
Location:
src/sas
Files:
6 edited

Legend:

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

    r9f2f713 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 
     
    157155            logger.error(msg) 
    158156 
    159         plotter = self.dependentVariable.currentText() 
     157        plotter = self.model.item(W.VARIABLE).text() 
     158        y_label = y_unit = "" 
    160159        x_label = "D_{max}" 
    161160        x_unit = "A" 
     
    189188            y_unit = "a.u." 
    190189 
    191         data = Data1D(plotable_xs, ys) 
     190        data = Data1D(xs, ys) 
    192191        if self.hasPlot: 
    193             self.plot.removePlot(data.name) 
     192            self.plot.removePlot(None) 
    194193        self.hasPlot = True 
    195194        data.title = plotter 
  • src/sas/qtgui/Perspectives/Inversion/InversionLogic.py

    r3c4f02e r6da860a  
    111111            new_plot.title = title 
    112112 
    113         new_plot.symbol = 'Line' 
    114         new_plot.hide_error = True 
    115  
    116113        return new_plot 
    117114 
  • src/sas/qtgui/Perspectives/Inversion/InversionPerspective.py

    r855e7ad r855e7ad  
    4444    estimateSignal = QtCore.pyqtSignal(tuple) 
    4545    estimateNTSignal = QtCore.pyqtSignal(tuple) 
    46     estimateDynamicNTSignal = QtCore.pyqtSignal(tuple) 
    47     estimateDynamicSignal = QtCore.pyqtSignal(tuple) 
    4846    calculateSignal = QtCore.pyqtSignal(tuple) 
    4947 
     
    197195        self.model.itemChanged.connect(self.model_changed) 
    198196        self.estimateNTSignal.connect(self._estimateNTUpdate) 
    199         self.estimateDynamicNTSignal.connect(self._estimateDynamicNTUpdate) 
    200         self.estimateDynamicSignal.connect(self._estimateDynamicUpdate) 
    201197        self.estimateSignal.connect(self._estimateUpdate) 
    202198        self.calculateSignal.connect(self._calculateUpdate) 
    203  
    204         self.maxDistanceInput.textEdited.connect(self.performEstimateDynamic) 
    205199 
    206200    def setupMapper(self): 
     
    316310                                            and not self.isCalculating) 
    317311        self.removeButton.setEnabled(self.logic.data_is_loaded) 
    318         self.explorerButton.setEnabled(self.logic.data_is_loaded) 
     312        self.explorerButton.setEnabled(self.logic.data_is_loaded 
     313                                       and np.all(self.logic.data.dy != 0)) 
    319314        self.stopButton.setVisible(self.isCalculating) 
    320315        self.regConstantSuggestionButton.setEnabled( 
     
    463458            self._calculator.set_qmin(qmin) 
    464459            self._calculator.set_qmax(qmax) 
    465             if np.size(self.logic.data.dy) == 0 or np.all(self.logic.data.dy) == 0: 
    466                 self.logic.data.dy = self._calculator.add_errors(self.logic.data.y) 
    467460            self.updateDataList(data) 
    468461            self.populateDataComboBox(self.logic.data.filename, data) 
     
    509502        self.dataPlot = self._dataList[data_ref].get(DICT_KEYS[2]) 
    510503        self.performEstimate() 
    511  
    512     def updateDynamicGuiValues(self): 
    513         pr = self._calculator 
    514         alpha = self._calculator.suggested_alpha 
    515         self.model.setItem(WIDGETS.W_MAX_DIST, 
    516                             QtGui.QStandardItem("{:.4g}".format(pr.get_dmax()))) 
    517         self.regConstantSuggestionButton.setText("{:-3.2g}".format(alpha)) 
    518         self.noOfTermsSuggestionButton.setText( 
    519              "{:n}".format(self.nTermsSuggested)) 
    520  
    521         self.enableButtons() 
    522504 
    523505    def updateGuiValues(self): 
     
    539521        self.model.setItem(WIDGETS.W_MAX_DIST, 
    540522                           QtGui.QStandardItem("{:.4g}".format(pr.get_dmax()))) 
     523        self.regConstantSuggestionButton.setText("{:-3.2g}".format(alpha)) 
     524        self.noOfTermsSuggestionButton.setText( 
     525            "{:n}".format(self.nTermsSuggested)) 
    541526 
    542527        if isinstance(pr.chi2, np.ndarray): 
     
    689674        self.estimationThreadNT.ready(2.5) 
    690675 
    691     def performEstimateDynamicNT(self): 
    692         """ 
    693         Perform parameter estimation 
    694         """ 
    695         from .Thread import EstimateNT 
    696  
    697         self.updateCalculator() 
    698  
    699         # If a thread is already started, stop it 
    700         self.stopEstimateNTThread() 
    701  
    702         pr = self._calculator.clone() 
    703         # Skip the slit settings for the estimation 
    704         # It slows down the application and it doesn't change the estimates 
    705         pr.slit_height = 0.0 
    706         pr.slit_width = 0.0 
    707         nfunc = self.getNFunc() 
    708  
    709         self.estimationThreadNT = EstimateNT(pr, nfunc, 
    710                                              error_func=self._threadError, 
    711                                              completefn=self._estimateDynamicNTCompleted, 
    712                                              updatefn=None) 
    713         self.estimationThreadNT.queue() 
    714         self.estimationThreadNT.ready(2.5) 
    715  
    716676    def stopEstimateNTThread(self): 
    717677        if (self.estimationThreadNT is not None and 
     
    736696        self.estimationThread.ready(2.5) 
    737697 
    738     def performEstimateDynamic(self): 
    739         """ 
    740             Perform parameter estimation 
    741         """ 
    742         from .Thread import EstimatePr 
    743  
    744         # If a thread is already started, stop it 
    745         self.stopEstimationThread() 
    746  
    747         self.estimationThread = EstimatePr(self._calculator.clone(), 
    748                                            self.getNFunc(), 
    749                                            error_func=self._threadError, 
    750                                            completefn=self._estimateDynamicCompleted, 
    751                                            updatefn=None) 
    752         self.estimationThread.queue() 
    753         self.estimationThread.ready(2.5) 
    754  
    755698    def stopEstimationThread(self): 
    756699        """ Stop the estimation thread if it exists and is running """ 
     
    765708        ''' Send a signal to the main thread for model update''' 
    766709        self.estimateSignal.emit((alpha, message, elapsed)) 
    767  
    768     def _estimateDynamicCompleted(self, alpha, message, elapsed): 
    769         ''' Send a signal to the main thread for model update''' 
    770         self.estimateDynamicSignal.emit((alpha, message, elapsed)) 
    771710 
    772711    def _estimateUpdate(self, output_tuple): 
     
    784723            logger.info(message) 
    785724        self.performEstimateNT() 
    786         self.performEstimateDynamicNT() 
    787  
    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() 
    802725 
    803726    def _estimateNTCompleted(self, nterms, alpha, message, elapsed): 
    804727        ''' Send a signal to the main thread for model update''' 
    805728        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)) 
    810729 
    811730    def _estimateNTUpdate(self, output_tuple): 
     
    831750            self.startThread() 
    832751 
    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  
    855752    def _calculateCompleted(self, out, cov, pr, elapsed): 
    856753        ''' Send a signal to the main thread for model update''' 
  • src/sas/qtgui/Perspectives/Inversion/UI/DMaxExplorer.ui

    rcfd61f2 r8f83719f  
    77    <x>0</x> 
    88    <y>0</y> 
    9     <width>586</width> 
    10     <height>538</height> 
     9    <width>394</width> 
     10    <height>426</height> 
    1111   </rect> 
    1212  </property> 
     
    2121       <property name="orientation"> 
    2222        <enum>Qt::Vertical</enum> 
     23       </property> 
     24       <property name="sizeHint" stdset="0"> 
     25        <size> 
     26         <width>20</width> 
     27         <height>305</height> 
     28        </size> 
    2329       </property> 
    2430      </spacer> 
  • src/sas/qtgui/Plotting/Plotter.py

    rd0952de r5b144c6  
    8484            if self.data.ytransform is None: 
    8585                self.data.ytransform = 'log10(y)' 
    86             #Added condition to Dmax explorer from P(r) perspective 
    87             if self.data._xaxis == 'D_{max}': 
    88                 self.xscale = 'linear' 
     86 
    8987            # Transform data if required. 
    9088            if transform and (self.data.xtransform is not None or self.data.ytransform is not None): 
  • src/sas/sascalc/pr/invertor.py

    reeea6a3 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        """ 
     
    282268            A[i][j] = (Fourier transformed base function for point j) 
    283269 
    284         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 
    285271        derivative of P(r) at. This is used as our regularization term. 
    286272        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.