Changeset ff2b961 in sasview


Ignore:
Timestamp:
Oct 26, 2017 8:17:10 AM (7 years ago)
Author:
Adam Washington <adam.washington@…>
Children:
1eafef1
Parents:
a7067ef2
Message:

Provide better errors for bad fits in Corfunc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Perspectives/Corfunc/CorfuncPerspective.py

    recdf172 rff2b961  
    2121    as FigureCanvas 
    2222from matplotlib.figure import Figure 
     23from numpy.linalg.linalg import LinAlgError 
    2324 
    2425 
     
    182183        """Extend the experiemntal data with guinier and porod curves.""" 
    183184        self._update_calculator() 
    184         params, extrapolation, _ = self._calculator.compute_extrapolation() 
    185  
    186         self.model.setItem(W.W_GUINIERA, QtGui.QStandardItem(str(params['A']))) 
    187         self.model.setItem(W.W_GUINIERB, QtGui.QStandardItem(str(params['B']))) 
    188         self.model.setItem(W.W_PORODK, QtGui.QStandardItem(str(params['K']))) 
    189         self.model.setItem(W.W_PORODSIGMA, 
    190                            QtGui.QStandardItem(str(params['sigma']))) 
    191  
    192         self._canvas.extrap = extrapolation 
    193         self._canvas.draw_q_space() 
    194         self.transformBtn.setEnabled(True) 
     185        try: 
     186            params, extrapolation, _ = self._calculator.compute_extrapolation() 
     187            self.model.setItem(W.W_GUINIERA, QtGui.QStandardItem(str(params['A']))) 
     188            self.model.setItem(W.W_GUINIERB, QtGui.QStandardItem(str(params['B']))) 
     189            self.model.setItem(W.W_PORODK, QtGui.QStandardItem(str(params['K']))) 
     190            self.model.setItem(W.W_PORODSIGMA, 
     191                               QtGui.QStandardItem(str(params['sigma']))) 
     192 
     193            self._canvas.extrap = extrapolation 
     194            self._canvas.draw_q_space() 
     195            self.transformBtn.setEnabled(True) 
     196        except (LinAlgError, ValueError): 
     197            message = "These is not enough data in the fitting range. "\ 
     198                      "Try decreasing the upper Q, increasing the "\ 
     199                      "cutoff Q, or increasing the lower Q." 
     200            QtGui.QMessageBox.warning(self, "Calculation Error", 
     201                                      message) 
     202            self._canvas.extrap = None 
     203            self._canvas.draw_q_space() 
     204 
    195205 
    196206    def transform(self): 
     
    260270        """Find a good estimate of the background value.""" 
    261271        self._update_calculator() 
    262         background = self._calculator.compute_background() 
    263         temp = QtGui.QStandardItem(str(background)) 
    264         self.model.setItem(W.W_BACKGROUND, temp) 
     272        try: 
     273            background = self._calculator.compute_background() 
     274            temp = QtGui.QStandardItem(str(background)) 
     275            self.model.setItem(W.W_BACKGROUND, temp) 
     276        except (LinAlgError, ValueError): 
     277            message = "These is not enough data in the fitting range. "\ 
     278                      "Try decreasing the upper Q or increasing the cutoff Q" 
     279            QtGui.QMessageBox.warning(self, "Calculation Error", 
     280                                      message) 
     281 
    265282 
    266283    # pylint: disable=invalid-name 
Note: See TracChangeset for help on using the changeset viewer.