Changeset 9b17efd in sasview
- Timestamp:
- Sep 11, 2018 7:40:15 AM (6 years ago)
- Branches:
- ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- 551f2bc
- Parents:
- 28965e9 (diff), 343d7fd (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Location:
- src/sas
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/FittingUtilities.py
r01b4877 rf3cc979 128 128 129 129 # Find param in volume_params 130 for p in parameters.form_volume_parameters: 130 poly_pars = parameters.form_volume_parameters 131 if is2D: 132 poly_pars += parameters.orientation_parameters 133 for p in poly_pars: 131 134 if p.name != param.name: 132 135 continue -
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
rbb477f5 rf3cc979 1219 1219 if model_column in [delegate.poly_pd, delegate.poly_error, delegate.poly_min, delegate.poly_max]: 1220 1220 row = self.getRowFromName(parameter_name) 1221 param_item = self._model_model.item(row) 1221 param_item = self._model_model.item(row).child(0).child(0, model_column) 1222 if param_item is None: 1223 return 1222 1224 self._model_model.blockSignals(True) 1223 param_item. child(0).child(0, model_column).setText(item.text())1225 param_item.setText(item.text()) 1224 1226 self._model_model.blockSignals(False) 1225 1227 … … 2796 2798 2797 2799 func = QtWidgets.QComboBox() 2798 # Available range of shells displayed in the combobox2799 func.addItems([str(i) for i in range(param_length+1)])2800 2801 # Respond to index change2802 func.currentIndexChanged.connect(self.modifyShellsInList)2803 2800 2804 2801 # cell 2: combobox 2805 2802 item2 = QtGui.QStandardItem() 2806 self._model_model.appendRow([item1, item2]) 2803 2804 # cell 3: min value 2805 item3 = QtGui.QStandardItem() 2806 2807 # cell 4: max value 2808 item4 = QtGui.QStandardItem() 2809 2810 self._model_model.appendRow([item1, item2, item3, item4]) 2807 2811 2808 2812 # Beautify the row: span columns 2-4 … … 2823 2827 logger.error("Could not find %s in kernel parameters.", param_name) 2824 2828 default_shell_count = shell_par.default 2829 shell_min = 0 2830 shell_max = 0 2831 try: 2832 shell_min = int(shell_par.limits[0]) 2833 shell_max = int(shell_par.limits[1]) 2834 except IndexError as ex: 2835 # no info about limits 2836 pass 2837 item3.setText(str(shell_min)) 2838 item4.setText(str(shell_max)) 2839 2840 # Respond to index change 2841 func.currentTextChanged.connect(self.modifyShellsInList) 2842 2843 # Available range of shells displayed in the combobox 2844 func.addItems([str(i) for i in range(shell_min, shell_max+1)]) 2825 2845 2826 2846 # Add default number of shells to the model 2827 func.setCurrent Index(default_shell_count)2828 2829 def modifyShellsInList(self, index):2847 func.setCurrentText(str(default_shell_count)) 2848 2849 def modifyShellsInList(self, text): 2830 2850 """ 2831 2851 Add/remove additional multishell parameters … … 2834 2854 first_row = self._n_shells_row + 1 2835 2855 remove_rows = self._num_shell_params 2856 try: 2857 index = int(text) 2858 except ValueError: 2859 # bad text on the control! 2860 index = 0 2861 logger.error("Multiplicity incorrect! Setting to 0") 2836 2862 2837 2863 if remove_rows > 1: … … 2848 2874 self.current_shell_displayed = index 2849 2875 2850 # Change 'n' in the parameter model, thereby updating the underlying model 2876 # Param values for existing shells were reset to default; force all changes into kernel module 2877 for row in new_rows: 2878 par = row[0].text() 2879 val = GuiUtils.toDouble(row[1].text()) 2880 self.kernel_module.setParam(par, val) 2881 2882 # Change 'n' in the parameter model; also causes recalculation 2851 2883 self._model_model.item(self._n_shells_row, 1).setText(str(index)) 2852 2884 -
src/sas/qtgui/Plotting/PlotterBase.py
rd9150d8 r343d7fd 10 10 11 11 import matplotlib.pyplot as plt 12 from matplotlib import rcParams 12 13 13 14 DEFAULT_CMAP = pylab.cm.jet … … 29 30 self.manager = manager 30 31 self.quickplot = quickplot 32 33 # Set auto layout so x/y axis captions don't get cut off 34 rcParams.update({'figure.autolayout': True}) 31 35 32 36 #plt.style.use('ggplot') -
src/sas/qtgui/Perspectives/Inversion/DMaxExplorerWidget.py
rb0ba43e re908916 42 42 self.parent = parent 43 43 44 self.setWindowTitle("D ââExplorer")44 self.setWindowTitle("Dmax Explorer") 45 45 46 46 self.pr_state = pr_state … … 116 116 bck = [] 117 117 chi2 = [] 118 118 plotable_xs = [] #Introducing this to make sure size of x and y for plotting is the same.8 119 119 try: 120 120 dmin = float(self.model.item(W.DMIN).text()) … … 128 128 129 129 original = self.pr_state.d_max 130 130 131 for x in xs: 131 132 self.pr_state.d_max = x … … 140 141 bck.append(self.pr_state.background) 141 142 chi2.append(self.pr_state.chi2) 143 plotable_xs.append(x) 142 144 except Exception as ex: 143 145 # This inversion failed, skip this D_max value … … 188 190 y_unit = "a.u." 189 191 190 data = Data1D( xs, ys)192 data = Data1D(plotable_xs, ys) 191 193 if self.hasPlot: 192 194 self.plot.removePlot(None) -
src/sas/qtgui/Perspectives/Inversion/InversionPerspective.py
r2b8286c r28965e9 43 43 estimateSignal = QtCore.pyqtSignal(tuple) 44 44 estimateNTSignal = QtCore.pyqtSignal(tuple) 45 estimateDynamicNTSignal = QtCore.pyqtSignal(tuple) 46 estimateDynamicSignal = QtCore.pyqtSignal(tuple) 45 47 calculateSignal = QtCore.pyqtSignal(tuple) 46 48 … … 194 196 self.model.itemChanged.connect(self.model_changed) 195 197 self.estimateNTSignal.connect(self._estimateNTUpdate) 198 self.estimateDynamicNTSignal.connect(self._estimateDynamicNTUpdate) 199 self.estimateDynamicSignal.connect(self._estimateDynamicUpdate) 196 200 self.estimateSignal.connect(self._estimateUpdate) 197 201 self.calculateSignal.connect(self._calculateUpdate) 202 203 self.maxDistanceInput.textEdited.connect(self.performEstimateDynamic) 198 204 199 205 def setupMapper(self): … … 309 315 and not self.isCalculating) 310 316 self.removeButton.setEnabled(self.logic.data_is_loaded) 311 self.explorerButton.setEnabled(self.logic.data_is_loaded 312 and np.all(self.logic.data.dy != 0)) 317 self.explorerButton.setEnabled(self.logic.data_is_loaded) 313 318 self.stopButton.setVisible(self.isCalculating) 314 319 self.regConstantSuggestionButton.setEnabled( … … 501 506 self.dataPlot = self._dataList[data_ref].get(DICT_KEYS[2]) 502 507 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() 503 519 504 520 def updateGuiValues(self): … … 520 536 self.model.setItem(WIDGETS.W_MAX_DIST, 521 537 QtGui.QStandardItem("{:.4g}".format(pr.get_dmax()))) 522 self.regConstantSuggestionButton.setText("{:-3.2g}".format(alpha))523 self.noOfTermsSuggestionButton.setText(524 "{:n}".format(self.nTermsSuggested))525 538 526 539 if isinstance(pr.chi2, np.ndarray): … … 671 684 self.estimationThreadNT.ready(2.5) 672 685 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 673 711 def stopEstimateNTThread(self): 674 712 if (self.estimationThreadNT is not None and … … 693 731 self.estimationThread.ready(2.5) 694 732 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 695 750 def stopEstimationThread(self): 696 751 """ Stop the estimation thread if it exists and is running """ … … 705 760 ''' Send a signal to the main thread for model update''' 706 761 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)) 707 766 708 767 def _estimateUpdate(self, output_tuple): … … 720 779 logger.info(message) 721 780 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() 722 797 723 798 def _estimateNTCompleted(self, nterms, alpha, message, elapsed): 724 799 ''' Send a signal to the main thread for model update''' 725 800 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)) 726 805 727 806 def _estimateNTUpdate(self, output_tuple): … … 747 826 self.startThread() 748 827 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 749 850 def _calculateCompleted(self, out, cov, pr, elapsed): 750 851 ''' Send a signal to the main thread for model update''' -
src/sas/sascalc/pr/invertor.py
rb8080e1 r6701a0b 71 71 A[j][i] = (Fourier transformed base function for point j) 72 72 73 We the mchoose a number of r-points, n_r, to evaluate the second73 We then 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 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 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 229 243 def clone(self): 230 244 """ … … 244 258 invertor.x = self.x 245 259 invertor.y = self.y 246 invertor.err = self.err 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 247 264 invertor.est_bck = self.est_bck 248 265 invertor.background = self.background … … 268 285 A[i][j] = (Fourier transformed base function for point j) 269 286 270 We the mchoose a number of r-points, n_r, to evaluate the second287 We then choose a number of r-points, n_r, to evaluate the second 271 288 derivative of P(r) at. This is used as our regularization term. 272 289 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.