Changes in / [e2451f2:86d3207] in sasview
- Location:
- src/sas
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Inversion/DMaxExplorerWidget.py
r9f2f713 rb0ba43e 42 42 self.parent = parent 43 43 44 self.setWindowTitle("D maxExplorer")44 self.setWindowTitle("Dââ Explorer") 45 45 46 46 self.pr_state = pr_state … … 116 116 bck = [] 117 117 chi2 = [] 118 plotable_xs = [] #Introducing this to make sure size of x and y for plotting is the same.8 118 119 119 try: 120 120 dmin = float(self.model.item(W.DMIN).text()) … … 128 128 129 129 original = self.pr_state.d_max 130 131 130 for x in xs: 132 131 self.pr_state.d_max = x … … 141 140 bck.append(self.pr_state.background) 142 141 chi2.append(self.pr_state.chi2) 143 plotable_xs.append(x)144 142 except Exception as ex: 145 143 # This inversion failed, skip this D_max value … … 157 155 logger.error(msg) 158 156 159 plotter = self.dependentVariable.currentText() 157 plotter = self.model.item(W.VARIABLE).text() 158 y_label = y_unit = "" 160 159 x_label = "D_{max}" 161 160 x_unit = "A" … … 189 188 y_unit = "a.u." 190 189 191 data = Data1D( plotable_xs, ys)190 data = Data1D(xs, ys) 192 191 if self.hasPlot: 193 self.plot.removePlot( data.name)192 self.plot.removePlot(None) 194 193 self.hasPlot = True 195 194 data.title = plotter -
src/sas/qtgui/Perspectives/Inversion/InversionLogic.py
r3c4f02e r6da860a 111 111 new_plot.title = title 112 112 113 new_plot.symbol = 'Line'114 new_plot.hide_error = True115 116 113 return new_plot 117 114 -
src/sas/qtgui/Perspectives/Inversion/InversionPerspective.py
r855e7ad r855e7ad 44 44 estimateSignal = QtCore.pyqtSignal(tuple) 45 45 estimateNTSignal = QtCore.pyqtSignal(tuple) 46 estimateDynamicNTSignal = QtCore.pyqtSignal(tuple)47 estimateDynamicSignal = QtCore.pyqtSignal(tuple)48 46 calculateSignal = QtCore.pyqtSignal(tuple) 49 47 … … 197 195 self.model.itemChanged.connect(self.model_changed) 198 196 self.estimateNTSignal.connect(self._estimateNTUpdate) 199 self.estimateDynamicNTSignal.connect(self._estimateDynamicNTUpdate)200 self.estimateDynamicSignal.connect(self._estimateDynamicUpdate)201 197 self.estimateSignal.connect(self._estimateUpdate) 202 198 self.calculateSignal.connect(self._calculateUpdate) 203 204 self.maxDistanceInput.textEdited.connect(self.performEstimateDynamic)205 199 206 200 def setupMapper(self): … … 316 310 and not self.isCalculating) 317 311 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)) 319 314 self.stopButton.setVisible(self.isCalculating) 320 315 self.regConstantSuggestionButton.setEnabled( … … 463 458 self._calculator.set_qmin(qmin) 464 459 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)467 460 self.updateDataList(data) 468 461 self.populateDataComboBox(self.logic.data.filename, data) … … 509 502 self.dataPlot = self._dataList[data_ref].get(DICT_KEYS[2]) 510 503 self.performEstimate() 511 512 def updateDynamicGuiValues(self):513 pr = self._calculator514 alpha = self._calculator.suggested_alpha515 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()522 504 523 505 def updateGuiValues(self): … … 539 521 self.model.setItem(WIDGETS.W_MAX_DIST, 540 522 QtGui.QStandardItem("{:.4g}".format(pr.get_dmax()))) 523 self.regConstantSuggestionButton.setText("{:-3.2g}".format(alpha)) 524 self.noOfTermsSuggestionButton.setText( 525 "{:n}".format(self.nTermsSuggested)) 541 526 542 527 if isinstance(pr.chi2, np.ndarray): … … 689 674 self.estimationThreadNT.ready(2.5) 690 675 691 def performEstimateDynamicNT(self):692 """693 Perform parameter estimation694 """695 from .Thread import EstimateNT696 697 self.updateCalculator()698 699 # If a thread is already started, stop it700 self.stopEstimateNTThread()701 702 pr = self._calculator.clone()703 # Skip the slit settings for the estimation704 # It slows down the application and it doesn't change the estimates705 pr.slit_height = 0.0706 pr.slit_width = 0.0707 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 716 676 def stopEstimateNTThread(self): 717 677 if (self.estimationThreadNT is not None and … … 736 696 self.estimationThread.ready(2.5) 737 697 738 def performEstimateDynamic(self):739 """740 Perform parameter estimation741 """742 from .Thread import EstimatePr743 744 # If a thread is already started, stop it745 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 755 698 def stopEstimationThread(self): 756 699 """ Stop the estimation thread if it exists and is running """ … … 765 708 ''' Send a signal to the main thread for model update''' 766 709 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))771 710 772 711 def _estimateUpdate(self, output_tuple): … … 784 723 logger.info(message) 785 724 self.performEstimateNT() 786 self.performEstimateDynamicNT()787 788 def _estimateDynamicUpdate(self, output_tuple):789 """790 Parameter estimation completed,791 display the results to the user792 793 :param alpha: estimated best alpha794 :param elapsed: computation time795 """796 alpha, message, elapsed = output_tuple797 self._calculator.alpha = alpha798 self._calculator.elapsed += self._calculator.elapsed799 if message:800 logger.info(message)801 self.performEstimateDynamicNT()802 725 803 726 def _estimateNTCompleted(self, nterms, alpha, message, elapsed): 804 727 ''' Send a signal to the main thread for model update''' 805 728 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))810 729 811 730 def _estimateNTUpdate(self, output_tuple): … … 831 750 self.startThread() 832 751 833 def _estimateDynamicNTUpdate(self, output_tuple):834 """835 Parameter estimation completed,836 display the results to the user837 838 :param alpha: estimated best alpha839 :param nterms: estimated number of terms840 :param elapsed: computation time841 """842 nterms, alpha, message, elapsed = output_tuple843 self._calculator.elapsed += elapsed844 self._calculator.suggested_alpha = alpha845 self.nTermsSuggested = nterms846 # Save useful info847 self.updateDynamicGuiValues()848 if message:849 logger.info(message)850 if self.isBatch:851 self.acceptAlpha()852 self.acceptNoTerms()853 self.startThread()854 855 752 def _calculateCompleted(self, out, cov, pr, elapsed): 856 753 ''' Send a signal to the main thread for model update''' -
src/sas/qtgui/Perspectives/Inversion/UI/DMaxExplorer.ui
rcfd61f2 r8f83719f 7 7 <x>0</x> 8 8 <y>0</y> 9 <width> 586</width>10 <height> 538</height>9 <width>394</width> 10 <height>426</height> 11 11 </rect> 12 12 </property> … … 21 21 <property name="orientation"> 22 22 <enum>Qt::Vertical</enum> 23 </property> 24 <property name="sizeHint" stdset="0"> 25 <size> 26 <width>20</width> 27 <height>305</height> 28 </size> 23 29 </property> 24 30 </spacer> -
src/sas/qtgui/Plotting/Plotter.py
rd0952de r5b144c6 84 84 if self.data.ytransform is None: 85 85 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 89 87 # Transform data if required. 90 88 if transform and (self.data.xtransform is not None or self.data.ytransform is not None): -
src/sas/sascalc/pr/invertor.py
reeea6a3 rb8080e1 71 71 A[j][i] = (Fourier transformed base function for point j) 72 72 73 We the nchoose a number of r-points, n_r, to evaluate the second73 We them choose a number of r-points, n_r, to evaluate the second 74 74 derivative of P(r) at. This is used as our regularization term. 75 75 For a vector r of length n_r, the following n_r rows are set to :: … … 144 144 x, y, err, d_max, q_min, q_max and alpha 145 145 """ 146 if name == 'x':146 if name == 'x': 147 147 if 0.0 in value: 148 148 msg = "Invertor: one of your q-values is zero. " … … 227 227 return None 228 228 229 def add_errors(self, yvalues):230 """231 Adds errors to data set is they are not avaialble232 :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 Q237 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_err240 logger.warning("Simulated errors have been added to the data set\n")241 return stats_errors242 243 229 def clone(self): 244 230 """ … … 282 268 A[i][j] = (Fourier transformed base function for point j) 283 269 284 We the nchoose a number of r-points, n_r, to evaluate the second270 We them choose a number of r-points, n_r, to evaluate the second 285 271 derivative of P(r) at. This is used as our regularization term. 286 272 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.