Changeset adf1c2a in sasview for src/sas/qtgui/Perspectives


Ignore:
Timestamp:
Sep 21, 2018 8:34:54 AM (6 years ago)
Author:
Torin Cooper-Bennun <torin.cooper-bennun@…>
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:
80a327d
Parents:
6fbb859 (diff), dad086f (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.
Message:

Merge branch 'ESS_GUI' into ESS_GUI_iss1052

Location:
src/sas/qtgui/Perspectives
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Perspectives/Fitting/ComplexConstraint.py

    raed0532 r305114c  
    1313import webbrowser 
    1414 
     15from sas.qtgui.Perspectives.Fitting import FittingUtilities 
    1516import sas.qtgui.Utilities.GuiUtils as GuiUtils 
    1617ALLOWED_OPERATORS = ['=','<','>','>=','<='] 
     
    3233        self.operator = '=' 
    3334 
     35        self.warning = self.lblWarning.text() 
    3436        self.setupData() 
     37        self.setupSignals() 
    3538        self.setupWidgets() 
    36         self.setupSignals() 
    3739        self.setupTooltip() 
    38  
    39         self.setFixedSize(self.minimumSizeHint()) 
    4040 
    4141        # Default focus is on OK 
     
    101101        # Find out the signal source 
    102102        source = self.sender().objectName() 
     103        param1 = self.cbParam1.currentText() 
     104        param2 = self.cbParam2.currentText() 
    103105        if source == "cbParam1": 
    104             self.txtParam.setText(self.tab_names[0] + ":" + self.cbParam1.currentText()) 
     106            self.txtParam.setText(self.tab_names[0] + ":" + param1) 
    105107        else: 
    106             self.txtConstraint.setText(self.tab_names[1] + "." + self.cbParam2.currentText()) 
     108            self.txtConstraint.setText(self.tab_names[1] + "." + param2) 
     109        # Check if any of the parameters are polydisperse 
     110        params_list = [param1, param2] 
     111        all_pars = [tab.model_parameters for tab in self.tabs] 
     112        is2Ds = [tab.is2D for tab in self.tabs] 
     113        txt = "" 
     114        for pars, is2D in zip(all_pars, is2Ds): 
     115            if any([FittingUtilities.isParamPolydisperse(p, pars, is2D) for p in params_list]): 
     116                # no parameters are pd - reset the text to not show the warning 
     117                txt = self.warning 
     118        self.lblWarning.setText(txt) 
     119 
    107120 
    108121    def onOperatorChange(self, index): 
  • src/sas/qtgui/Perspectives/Fitting/FittingLogic.py

    r5a96a72 radf1c2a  
    154154        new_plot.xaxis(_xaxis, _xunit) 
    155155        new_plot.yaxis(_yaxis, _yunit) 
     156 
     157        if component is not None: 
     158            new_plot.plot_role = Data1D.ROLE_DELETABLE #deletable 
    156159 
    157160        return new_plot 
  • src/sas/qtgui/Perspectives/Fitting/FittingOptions.py

    rff3b293 r8873ab7  
    6464        default_index = self.cbAlgorithm.findText(default_name) 
    6565        self.cbAlgorithm.setCurrentIndex(default_index) 
     66        # previous algorithm choice 
     67        self.previous_index = default_index 
    6668 
    6769        # Assign appropriate validators 
     
    121123 
    122124        # Convert the name into widget instance 
    123         widget_to_activate = eval(widget_name) 
     125        try: 
     126            widget_to_activate = eval(widget_name) 
     127        except AttributeError: 
     128            # We don't yet have this optimizer. 
     129            # Show message 
     130            msg = "This algorithm has not yet been implemented in SasView.\n" 
     131            msg += "Please choose a different algorithm" 
     132            QtWidgets.QMessageBox.warning(self, 
     133                                        'Warning', 
     134                                        msg, 
     135                                        QtWidgets.QMessageBox.Ok) 
     136            # Move the index to previous position 
     137            self.cbAlgorithm.setCurrentIndex(self.previous_index) 
     138            return 
     139 
    124140        index_for_this_id = self.stackedWidget.indexOf(widget_to_activate) 
    125141 
     
    133149        # OK has to be reinitialized to True 
    134150        self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(True) 
     151 
     152        # keep reference 
     153        self.previous_index = index 
    135154 
    136155    def onApply(self): 
     
    143162            # e.g. 'samples' for 'dream' is 'self.samples_dream' 
    144163            widget_name = 'self.'+option+'_'+self.current_fitter_id 
    145             line_edit = eval(widget_name) 
     164            try: 
     165                line_edit = eval(widget_name) 
     166            except AttributeError: 
     167                # Skip bumps monitors 
     168                continue 
    146169            if line_edit is None or not isinstance(line_edit, QtWidgets.QLineEdit): 
    147170                continue 
     
    165188                return 
    166189            try: 
    167                 new_value = widget.currentText() if isinstance(widget, QtWidgets.QComboBox) \ 
    168                     else float(widget.text()) 
     190                if isinstance(widget, QtWidgets.QComboBox): 
     191                    new_value = widget.currentText() 
     192                else: 
     193                    try: 
     194                        new_value = int(widget.text()) 
     195                    except ValueError: 
     196                        new_value = float(widget.text()) 
     197                #new_value = widget.currentText() if isinstance(widget, QtWidgets.QComboBox) \ 
     198                #    else float(widget.text()) 
    169199                self.config.values[self.current_fitter_id][option] = new_value 
    170200            except ValueError: 
  • src/sas/qtgui/Perspectives/Fitting/FittingUtilities.py

    r01b4877 r30bed93  
    2323 
    2424poly_header_tooltips = ['Select parameter for fitting', 
    25                         'Enter polydispersity ratio (STD/mean). ' 
    26                         'STD: standard deviation from the mean value', 
     25                        'Enter polydispersity ratio (Std deviation/mean).\n'+ 
     26                        'For angles this can be either std deviation or half width (for uniform distributions) in degrees', 
    2727                        'Enter minimum value for parameter', 
    2828                        'Enter maximum value for parameter', 
     
    128128 
    129129            # Find param in volume_params 
    130             for p in parameters.form_volume_parameters: 
     130            poly_pars = copy.deepcopy(parameters.form_volume_parameters) 
     131            if is2D: 
     132                poly_pars += parameters.orientation_parameters 
     133            for p in poly_pars: 
    131134                if p.name != param.name: 
    132135                    continue 
     
    567570    return residuals 
    568571 
     572def plotPolydispersities(model): 
     573    plots = [] 
     574    if model is None: 
     575        return plots 
     576    # test for model being a sasmodels.sasview_model.SasviewModel? 
     577    for name in model.dispersion.keys(): 
     578        xarr, yarr = model.get_weights(name) 
     579        if len(xarr) <= 1: # param name not found or no polydisp. 
     580            continue 
     581        # create Data1D as in residualsData1D() and fill x/y members 
     582        # similar to FittingLogic._create1DPlot() but different data/axes 
     583        data1d = Data1D(x=xarr, y=yarr) 
     584        xunit = model.details[name][0] 
     585        data1d.xaxis(r'\rm{{{}}}'.format(name.replace('_', '\_')), xunit) 
     586        data1d.yaxis(r'\rm{weight}', 'normalized') 
     587        data1d.scale = 'linear' 
     588        data1d.symbol = 'Line' 
     589        data1d.name = "{} polydispersity".format(name) 
     590        data1d.id = data1d.name # placeholder, has to be completed later 
     591        data1d.plot_role = Data1D.ROLE_RESIDUAL 
     592        plots.append(data1d) 
     593    return plots 
     594 
    569595def binary_encode(i, digits): 
    570596    return [i >> d & 1 for d in range(digits)] 
     
    777803 
    778804    return output_string 
     805 
     806def isParamPolydisperse(param_name, kernel_params, is2D=False): 
     807    """ 
     808    Simple lookup for polydispersity for the given param name 
     809    """ 
     810    parameters = kernel_params.form_volume_parameters 
     811    if is2D: 
     812        parameters += kernel_params.orientation_parameters 
     813    has_poly = False 
     814    for param in parameters: 
     815        if param.name==param_name and param.polydisperse: 
     816            has_poly = True 
     817            break 
     818    return has_poly 
     819 
  • src/sas/qtgui/Perspectives/Fitting/FittingWidget.py

    r6fbb859 radf1c2a  
    2828from sas.qtgui.Plotting.PlotterData import Data1D 
    2929from sas.qtgui.Plotting.PlotterData import Data2D 
     30from sas.qtgui.Plotting.Plotter import PlotterWidget 
    3031 
    3132from sas.qtgui.Perspectives.Fitting.UI.FittingWidgetUI import Ui_FittingWidgetUI 
     
    5758DEFAULT_POLYDISP_FUNCTION = 'gaussian' 
    5859 
     60# CRUFT: remove when new release of sasmodels is available 
     61# https://github.com/SasView/sasview/pull/181#discussion_r218135162 
     62from sasmodels.sasview_model import SasviewModel 
     63if not hasattr(SasviewModel, 'get_weights'): 
     64    def get_weights(self, name): 
     65        """ 
     66        Returns the polydispersity distribution for parameter *name* as *value* and *weight* arrays. 
     67        """ 
     68        # type: (str) -> Tuple(np.ndarray, np.ndarray) 
     69        _, x, w = self._get_weights(self._model_info.parameters[name]) 
     70        return x, w 
     71 
     72    SasviewModel.get_weights = get_weights 
    5973 
    6074logger = logging.getLogger(__name__) 
     
    273287        self.theory_item = None 
    274288 
     289        # list column widths 
     290        self.lstParamHeaderSizes = {} 
     291 
    275292        # signal communicator 
    276293        self.communicate = self.parent.communicate 
     
    361378        self.lstParams.customContextMenuRequested.connect(self.showModelContextMenu) 
    362379        self.lstParams.setAttribute(QtCore.Qt.WA_MacShowFocusRect, False) 
     380        # Column resize signals 
     381        self.lstParams.header().sectionResized.connect(self.onColumnWidthUpdate) 
     382 
    363383        # Poly model displayed in poly list 
    364384        self.lstPoly.setModel(self._poly_model) 
     
    642662        # Create and display the widget for param1 and param2 
    643663        mc_widget = MultiConstraint(self, params=params_list) 
     664        # Check if any of the parameters are polydisperse 
     665        if not np.any([FittingUtilities.isParamPolydisperse(p, self.model_parameters, is2D=self.is2D) for p in params_list]): 
     666            # no parameters are pd - reset the text to not show the warning 
     667            mc_widget.lblWarning.setText("") 
    644668        if mc_widget.exec_() != QtWidgets.QDialog.Accepted: 
    645669            return 
     
    10611085            if not self.rowHasConstraint(row): 
    10621086                return 
     1087            constr = self.getConstraintForRow(row) 
    10631088            func = self.getConstraintForRow(row).func 
    1064             if func is not None: 
    1065                 self.communicate.statusBarUpdateSignal.emit("Active constrain: "+func) 
     1089            if constr.func is not None: 
     1090                # inter-parameter constraint 
     1091                update_text = "Active constraint: "+func 
     1092            elif constr.param == rows[0].data(): 
     1093                # current value constraint 
     1094                update_text = "Value constrained to: " + str(constr.value) 
     1095            else: 
     1096                # ill defined constraint 
     1097                return 
     1098            self.communicate.statusBarUpdateSignal.emit(update_text) 
    10661099 
    10671100    def replaceConstraintName(self, old_name, new_name=""): 
     
    11001133            # Create default datasets if no data passed 
    11011134            self.createDefaultDataset() 
     1135            self.theory_item = None # ensure theory is recalc. before plot, see showTheoryPlot() 
    11021136 
    11031137    def respondToModelStructure(self, model=None, structure_factor=None): 
     
    11071141        # kernel parameters -> model_model 
    11081142        self.SASModelToQModel(model, structure_factor) 
     1143 
     1144        for column, width in self.lstParamHeaderSizes.items(): 
     1145            self.lstParams.setColumnWidth(column, width) 
    11091146 
    11101147        # Update plot 
     
    12191256        if model_column in [delegate.poly_pd, delegate.poly_error, delegate.poly_min, delegate.poly_max]: 
    12201257            row = self.getRowFromName(parameter_name) 
    1221             param_item = self._model_model.item(row) 
     1258            param_item = self._model_model.item(row).child(0).child(0, model_column) 
     1259            if param_item is None: 
     1260                return 
    12221261            self._model_model.blockSignals(True) 
    1223             param_item.child(0).child(0, model_column).setText(item.text()) 
     1262            param_item.setText(item.text()) 
    12241263            self._model_model.blockSignals(False) 
    12251264 
     
    13661405        self.communicate.statusBarUpdateSignal.emit('Fitting started...') 
    13671406        self.fit_started = True 
     1407 
    13681408        # Disable some elements 
    1369         self.setFittingStarted() 
     1409        self.disableInteractiveElements() 
    13701410 
    13711411    def stopFit(self): 
     
    13761416            return 
    13771417        self.calc_fit.stop() 
    1378         #self.fit_started=False 
    13791418        #re-enable the Fit button 
    1380         self.setFittingStopped() 
     1419        self.enableInteractiveElements() 
    13811420 
    13821421        msg = "Fitting cancelled." 
     
    13921431        """ 
    13931432        """ 
    1394         self.setFittingStopped() 
     1433        self.enableInteractiveElements() 
    13951434        msg = "Fitting failed with: "+ str(reason) 
    13961435        self.communicate.statusBarUpdateSignal.emit(msg) 
     
    14091448        """ 
    14101449        #re-enable the Fit button 
    1411         self.setFittingStopped() 
     1450        self.enableInteractiveElements() 
    14121451 
    14131452        if len(result) == 0: 
     
    14811520        """ 
    14821521        #re-enable the Fit button 
    1483         self.setFittingStopped() 
     1522        self.enableInteractiveElements() 
    14841523 
    14851524        if len(result) == 0: 
     
    16661705        self.iterateOverModel(updatePolyValues) 
    16671706        self._model_model.itemChanged.connect(self.onMainParamsChange) 
    1668  
    1669         # Adjust the table cells width. 
    1670         # TODO: find a way to dynamically adjust column width while resized expanding 
    1671         self.lstParams.resizeColumnToContents(0) 
    1672         self.lstParams.resizeColumnToContents(4) 
    1673         self.lstParams.resizeColumnToContents(5) 
    1674         self.lstParams.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Expanding) 
    16751707 
    16761708    def iterateOverPolyModel(self, func): 
     
    18131845        self.cmdPlot.setText("Show Plot") 
    18141846        # Force data recalculation so existing charts are updated 
    1815         self.showPlot() 
     1847        if not self.data_is_loaded: 
     1848            self.showTheoryPlot() 
     1849        else: 
     1850            self.showPlot() 
    18161851        # This is an important processEvent. 
    18171852        # This allows charts to be properly updated in order 
    18181853        # of plots being applied. 
    18191854        QtWidgets.QApplication.processEvents() 
    1820         self.recalculatePlotData() 
     1855        self.recalculatePlotData() # recalc+plot theory again (2nd) 
    18211856 
    18221857    def onSmearingOptionsUpdate(self): 
     
    18341869        self.calculateQGridForModel() 
    18351870 
     1871    def showTheoryPlot(self): 
     1872        """ 
     1873        Show the current theory plot in MPL 
     1874        """ 
     1875        # Show the chart if ready 
     1876        if self.theory_item is None: 
     1877            self.recalculatePlotData() 
     1878        elif self.model_data: 
     1879            self._requestPlots(self.model_data.filename, self.theory_item.model()) 
     1880 
    18361881    def showPlot(self): 
    18371882        """ 
     
    18391884        """ 
    18401885        # Show the chart if ready 
    1841         data_to_show = self.data if self.data_is_loaded else self.model_data 
    1842         if data_to_show is not None: 
    1843             self.communicate.plotRequestedSignal.emit([data_to_show], self.tab_id) 
     1886        data_to_show = self.data 
     1887        # Any models for this page 
     1888        current_index = self.all_data[self.data_index] 
     1889        item = self._requestPlots(self.data.filename, current_index.model()) 
     1890        if item: 
     1891            # fit+data has not been shown - show just data 
     1892            self.communicate.plotRequestedSignal.emit([item, data_to_show], self.tab_id) 
     1893 
     1894    def _requestPlots(self, item_name, item_model): 
     1895        """ 
     1896        Emits plotRequestedSignal for all plots found in the given model under the provided item name. 
     1897        """ 
     1898        fitpage_name = "" if self.tab_id is None else "M"+str(self.tab_id) 
     1899        plots = GuiUtils.plotsFromFilename(item_name, item_model) 
     1900        # Has the fitted data been shown? 
     1901        data_shown = False 
     1902        item = None 
     1903        for item, plot in plots.items(): 
     1904            if fitpage_name in plot.name: 
     1905                data_shown = True 
     1906                self.communicate.plotRequestedSignal.emit([item, plot], self.tab_id) 
     1907        # return the last data item seen, if nothing was plotted; supposed to be just data) 
     1908        return None if data_shown else item 
    18441909 
    18451910    def onOptionsUpdate(self): 
     
    20132078            self.setMagneticModel() 
    20142079 
    2015         # Adjust the table cells width 
    2016         self.lstParams.resizeColumnToContents(0) 
    2017         self.lstParams.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Expanding) 
    2018  
    20192080        # Now we claim the model has been loaded 
    20202081        self.model_is_loaded = True 
     
    20752136        self.kernel_module = self.models[model_name]() 
    20762137 
     2138        # Change the model name to a monicker 
     2139        self.kernel_module.name = self.modelName() 
     2140 
    20772141        # Explicitly add scale and background with default values 
    20782142        temp_undo_state = self.undo_supported 
     
    21072171            # Structure factor is the only selected model; build it and show all its params 
    21082172            self.kernel_module = self.models[structure_factor]() 
     2173            self.kernel_module.name = self.modelName() 
    21092174            s_params = self.kernel_module._model_info.parameters 
    21102175            s_params_orig = s_params 
     
    21172182 
    21182183            self.kernel_module = MultiplicationModel(p_kernel, s_kernel) 
     2184            # Modify the name to correspond to shown items 
     2185            self.kernel_module.name = self.modelName() 
    21192186            all_params = self.kernel_module._model_info.parameters.kernel_parameters 
    21202187            all_param_names = [param.name for param in all_params] 
     
    24042471 
    24052472        # add polydisperse parameters if asked 
    2406         if self.chkPolydispersity.isChecked(): 
     2473        if self.chkPolydispersity.isChecked() and self._poly_model.rowCount() > 0: 
    24072474            for key, value in self.poly_params.items(): 
    24082475                model.setParam(key, value) 
    24092476        # add magnetic params if asked 
    24102477        if self.chkMagnetism.isChecked(): 
    2411             for key, value in self.magnet_params.items(): 
     2478            for key, value in self.magnet_params.items() and self._magnet_model.rowCount() > 0: 
    24122479                model.setParam(key, value) 
    24132480 
     
    24272494        weight = FittingUtilities.getWeight(data=data, is2d=self.is2D, flag=self.weighting) 
    24282495 
     2496        # Disable buttons/table 
     2497        self.disableInteractiveElements() 
    24292498        # Awful API to a backend method. 
    24302499        calc_thread = self.methodCalculateForData()(data=data, 
     
    24682537        Thread returned error 
    24692538        """ 
     2539        # Bring the GUI to normal state 
     2540        self.enableInteractiveElements() 
    24702541        print("Calculate Data failed with ", reason) 
    24712542 
     
    24802551        Plot the current 1D data 
    24812552        """ 
     2553        # Bring the GUI to normal state 
     2554        self.enableInteractiveElements() 
     2555        if return_data is None: 
     2556            self.calculateDataFailed("Results not available.") 
     2557            return 
    24822558        fitted_data = self.logic.new1DPlot(return_data, self.tab_id) 
     2559 
    24832560        residuals = self.calculateResiduals(fitted_data) 
    24842561        self.model_data = fitted_data 
     
    24882565 
    24892566        if self.data_is_loaded: 
    2490             # delete any plots associated with the data that were not updated (e.g. to remove beta(Q), S_eff(Q)) 
     2567            # delete any plots associated with the data that were not updated 
     2568            # (e.g. to remove beta(Q), S_eff(Q)) 
    24912569            GuiUtils.deleteRedundantPlots(self.all_data[self.data_index], new_plots) 
    24922570            pass 
    24932571        else: 
    2494             # delete theory items for the model, in order to get rid of any redundant items, e.g. beta(Q), S_eff(Q) 
     2572            # delete theory items for the model, in order to get rid of any 
     2573            # redundant items, e.g. beta(Q), S_eff(Q) 
    24952574            self.communicate.deleteIntermediateTheoryPlotsSignal.emit(self.kernel_module.id) 
     2575 
     2576        # Create plots for parameters with enabled polydispersity 
     2577        for plot in FittingUtilities.plotPolydispersities(return_data.get('model', None)): 
     2578            data_id = fitted_data.id.split() 
     2579            plot.id = "{} [{}] {}".format(data_id[0], plot.name, " ".join(data_id[1:])) 
     2580            data_name = fitted_data.name.split() 
     2581            plot.name = " ".join([data_name[0], plot.name] + data_name[1:]) 
     2582            self.createNewIndex(plot) 
     2583            new_plots.append(plot) 
    24962584 
    24972585        # Create plots for intermediate product data 
     
    25402628        Plot the current 2D data 
    25412629        """ 
     2630        # Bring the GUI to normal state 
     2631        self.enableInteractiveElements() 
     2632 
    25422633        fitted_data = self.logic.new2DPlot(return_data) 
    25432634        residuals = self.calculateResiduals(fitted_data) 
     
    25742665        residuals_plot = FittingUtilities.plotResiduals(self.data, weighted_data) 
    25752666        residuals_plot.id = "Residual " + residuals_plot.id 
     2667        residuals_plot.plot_role = Data1D.ROLE_RESIDUAL 
    25762668        self.createNewIndex(residuals_plot) 
    25772669        return residuals_plot 
     
    26092701        Thread threw an exception. 
    26102702        """ 
     2703        # Bring the GUI to normal state 
     2704        self.enableInteractiveElements() 
    26112705        # TODO: remimplement thread cancellation 
    26122706        logger.error("".join(traceback.format_exception(etype, value, tb))) 
     
    28202914        self._poly_model.setData(fname_index, fname) 
    28212915 
     2916    def onColumnWidthUpdate(self, index, old_size, new_size): 
     2917        """ 
     2918        Simple state update of the current column widths in the  param list 
     2919        """ 
     2920        self.lstParamHeaderSizes[index] = new_size 
     2921 
    28222922    def setMagneticModel(self): 
    28232923        """ 
     
    28912991 
    28922992        func = QtWidgets.QComboBox() 
    2893         # Available range of shells displayed in the combobox 
    2894         func.addItems([str(i) for i in range(param_length+1)]) 
    2895  
    2896         # Respond to index change 
    2897         func.currentIndexChanged.connect(self.modifyShellsInList) 
    28982993 
    28992994        # cell 2: combobox 
    29002995        item2 = QtGui.QStandardItem() 
    2901         self._model_model.appendRow([item1, item2]) 
     2996 
     2997        # cell 3: min value 
     2998        item3 = QtGui.QStandardItem() 
     2999 
     3000        # cell 4: max value 
     3001        item4 = QtGui.QStandardItem() 
     3002 
     3003        # cell 4: SLD button 
     3004        item5 = QtGui.QStandardItem() 
     3005        button = QtWidgets.QPushButton() 
     3006        button.setText("Show SLD Profile") 
     3007 
     3008        self._model_model.appendRow([item1, item2, item3, item4, item5]) 
    29023009 
    29033010        # Beautify the row:  span columns 2-4 
    29043011        shell_row = self._model_model.rowCount() 
    29053012        shell_index = self._model_model.index(shell_row-1, 1) 
     3013        button_index = self._model_model.index(shell_row-1, 4) 
    29063014 
    29073015        self.lstParams.setIndexWidget(shell_index, func) 
     3016        self.lstParams.setIndexWidget(button_index, button) 
    29083017        self._n_shells_row = shell_row - 1 
    29093018 
     
    29183027            logger.error("Could not find %s in kernel parameters.", param_name) 
    29193028        default_shell_count = shell_par.default 
     3029        shell_min = 0 
     3030        shell_max = 0 
     3031        try: 
     3032            shell_min = int(shell_par.limits[0]) 
     3033            shell_max = int(shell_par.limits[1]) 
     3034        except IndexError as ex: 
     3035            # no info about limits 
     3036            pass 
     3037        item3.setText(str(shell_min)) 
     3038        item4.setText(str(shell_max)) 
     3039 
     3040        # Respond to index change 
     3041        func.currentTextChanged.connect(self.modifyShellsInList) 
     3042 
     3043        # Respond to button press 
     3044        button.clicked.connect(self.onShowSLDProfile) 
     3045 
     3046        # Available range of shells displayed in the combobox 
     3047        func.addItems([str(i) for i in range(shell_min, shell_max+1)]) 
    29203048 
    29213049        # Add default number of shells to the model 
    2922         func.setCurrentIndex(default_shell_count) 
    2923  
    2924     def modifyShellsInList(self, index): 
     3050        func.setCurrentText(str(default_shell_count)) 
     3051 
     3052    def modifyShellsInList(self, text): 
    29253053        """ 
    29263054        Add/remove additional multishell parameters 
     
    29293057        first_row = self._n_shells_row + 1 
    29303058        remove_rows = self._num_shell_params 
    2931  
     3059        try: 
     3060            index = int(text) 
     3061        except ValueError: 
     3062            # bad text on the control! 
     3063            index = 0 
     3064            logger.error("Multiplicity incorrect! Setting to 0") 
     3065        self.kernel_module.multiplicity = index 
    29323066        if remove_rows > 1: 
    29333067            self._model_model.removeRows(first_row, remove_rows) 
     
    29563090        self.setMagneticModel() 
    29573091 
    2958     def setFittingStarted(self): 
    2959         """ 
    2960         Set buttion caption on fitting start 
     3092    def onShowSLDProfile(self): 
     3093        """ 
     3094        Show a quick plot of SLD profile 
     3095        """ 
     3096        # get profile data 
     3097        x, y = self.kernel_module.getProfile() 
     3098        y *= 1.0e6 
     3099        profile_data = Data1D(x=x, y=y) 
     3100        profile_data.name = "SLD" 
     3101        profile_data.scale = 'linear' 
     3102        profile_data.symbol = 'Line' 
     3103        profile_data.hide_error = True 
     3104        profile_data._xaxis = "R(\AA)" 
     3105        profile_data._yaxis = "SLD(10^{-6}\AA^{-2})" 
     3106 
     3107        plotter = PlotterWidget(self, quickplot=True) 
     3108        plotter.data = profile_data 
     3109        plotter.showLegend = True 
     3110        plotter.plot(hide_error=True, marker='-') 
     3111 
     3112        self.plot_widget = QtWidgets.QWidget() 
     3113        self.plot_widget.setWindowTitle("Scattering Length Density Profile") 
     3114        layout = QtWidgets.QVBoxLayout() 
     3115        layout.addWidget(plotter) 
     3116        self.plot_widget.setLayout(layout) 
     3117        self.plot_widget.show() 
     3118 
     3119    def setInteractiveElements(self, enabled=True): 
     3120        """ 
     3121        Switch interactive GUI elements on/off 
     3122        """ 
     3123        assert isinstance(enabled, bool) 
     3124 
     3125        self.lstParams.setEnabled(enabled) 
     3126        self.lstPoly.setEnabled(enabled) 
     3127        self.lstMagnetic.setEnabled(enabled) 
     3128 
     3129        self.cbCategory.setEnabled(enabled) 
     3130        self.cbModel.setEnabled(enabled) 
     3131        self.cbStructureFactor.setEnabled(enabled) 
     3132 
     3133        self.chkPolydispersity.setEnabled(enabled) 
     3134        self.chkMagnetism.setEnabled(enabled) 
     3135        self.chk2DView.setEnabled(enabled) 
     3136 
     3137    def enableInteractiveElements(self): 
     3138        """ 
     3139        Set buttion caption on fitting/calculate finish 
     3140        Enable the param table(s) 
     3141        """ 
     3142        # Notify the user that fitting is available 
     3143        self.cmdFit.setStyleSheet('QPushButton {color: black;}') 
     3144        self.cmdFit.setText("Fit") 
     3145        self.fit_started = False 
     3146        self.setInteractiveElements(True) 
     3147 
     3148    def disableInteractiveElements(self): 
     3149        """ 
     3150        Set buttion caption on fitting/calculate start 
     3151        Disable the param table(s) 
    29613152        """ 
    29623153        # Notify the user that fitting is being run 
     
    29643155        self.cmdFit.setStyleSheet('QPushButton {color: red;}') 
    29653156        self.cmdFit.setText('Stop fit') 
    2966  
    2967     def setFittingStopped(self): 
    2968         """ 
    2969         Set button caption on fitting stop 
    2970         """ 
    2971         # Notify the user that fitting is available 
    2972         self.cmdFit.setStyleSheet('QPushButton {color: black;}') 
    2973         self.cmdFit.setText("Fit") 
    2974         self.fit_started = False 
     3157        self.setInteractiveElements(False) 
    29753158 
    29763159    def readFitPage(self, fp): 
  • src/sas/qtgui/Perspectives/Fitting/MultiConstraint.py

    raed0532 r305114c  
    2828 
    2929        self.setupUi(self) 
    30         self.setFixedSize(self.minimumSizeHint()) 
    3130        self.setModal(True) 
    3231        self.params = params 
  • src/sas/qtgui/Perspectives/Fitting/UI/ComplexConstraintUI.ui

    ra90c9c5 r1738173  
    77    <x>0</x> 
    88    <y>0</y> 
    9     <width>406</width> 
    10     <height>167</height> 
     9    <width>367</width> 
     10    <height>199</height> 
    1111   </rect> 
    1212  </property> 
     
    2121     </property> 
    2222     <layout class="QGridLayout" name="gridLayout"> 
     23      <item row="1" column="0"> 
     24       <layout class="QHBoxLayout" name="horizontalLayout_2"> 
     25        <item> 
     26         <widget class="QLabel" name="txtParam"> 
     27          <property name="sizePolicy"> 
     28           <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> 
     29            <horstretch>0</horstretch> 
     30            <verstretch>0</verstretch> 
     31           </sizepolicy> 
     32          </property> 
     33          <property name="text"> 
     34           <string>param1</string> 
     35          </property> 
     36         </widget> 
     37        </item> 
     38        <item> 
     39         <widget class="QLabel" name="txtOperator"> 
     40          <property name="text"> 
     41           <string>=</string> 
     42          </property> 
     43         </widget> 
     44        </item> 
     45        <item> 
     46         <widget class="QLineEdit" name="txtConstraint"> 
     47          <property name="text"> 
     48           <string/> 
     49          </property> 
     50         </widget> 
     51        </item> 
     52       </layout> 
     53      </item> 
    2354      <item row="0" column="0"> 
    2455       <layout class="QHBoxLayout" name="horizontalLayout"> 
     
    98129       </layout> 
    99130      </item> 
    100       <item row="1" column="0"> 
    101        <spacer name="verticalSpacer"> 
    102         <property name="orientation"> 
    103          <enum>Qt::Vertical</enum> 
    104         </property> 
    105         <property name="sizeHint" stdset="0"> 
    106          <size> 
    107           <width>20</width> 
    108           <height>25</height> 
    109          </size> 
    110         </property> 
    111        </spacer> 
    112       </item> 
    113       <item row="2" column="0"> 
    114        <layout class="QHBoxLayout" name="horizontalLayout_2"> 
    115         <item> 
    116          <widget class="QLabel" name="txtParam"> 
    117           <property name="sizePolicy"> 
    118            <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> 
    119             <horstretch>0</horstretch> 
    120             <verstretch>0</verstretch> 
    121            </sizepolicy> 
    122           </property> 
    123           <property name="text"> 
    124            <string>param1</string> 
    125           </property> 
    126          </widget> 
    127         </item> 
    128         <item> 
    129          <widget class="QLabel" name="txtOperator"> 
    130           <property name="text"> 
    131            <string>=</string> 
    132           </property> 
    133          </widget> 
    134         </item> 
    135         <item> 
    136          <widget class="QLineEdit" name="txtConstraint"> 
    137           <property name="text"> 
    138            <string/> 
    139           </property> 
    140          </widget> 
    141         </item> 
    142        </layout> 
    143       </item> 
    144131     </layout> 
    145132    </widget> 
    146133   </item> 
    147134   <item row="1" column="0"> 
     135    <widget class="QLabel" name="lblWarning"> 
     136     <property name="text"> 
     137      <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; color:#ff0000;&quot;&gt;Warning! Polydisperse parameter selected.&lt;br/&gt;&lt;/span&gt;Constraints involving polydisperse parameters only apply to&lt;br/&gt;starting values and are not re-applied during size or angle polydispersity&lt;br/&gt;integrations. To do so requires creating a custom model.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> 
     138     </property> 
     139    </widget> 
     140   </item> 
     141   <item row="2" column="0"> 
     142    <spacer name="verticalSpacer_2"> 
     143     <property name="orientation"> 
     144      <enum>Qt::Vertical</enum> 
     145     </property> 
     146     <property name="sizeHint" stdset="0"> 
     147      <size> 
     148       <width>20</width> 
     149       <height>9</height> 
     150      </size> 
     151     </property> 
     152    </spacer> 
     153   </item> 
     154   <item row="3" column="0"> 
    148155    <layout class="QHBoxLayout" name="horizontalLayout_3"> 
    149156     <item> 
  • src/sas/qtgui/Perspectives/Fitting/UI/FittingWidgetUI.ui

    ra2e8ea5 rc928e81  
    77    <x>0</x> 
    88    <y>0</y> 
    9     <width>566</width> 
    10     <height>646</height> 
     9    <width>651</width> 
     10    <height>540</height> 
    1111   </rect> 
    1212  </property> 
  • src/sas/qtgui/Perspectives/Fitting/UI/MultiConstraintUI.ui

    ra90c9c5 r1738173  
    1010    <x>0</x> 
    1111    <y>0</y> 
    12     <width>426</width> 
    13     <height>162</height> 
     12    <width>369</width> 
     13    <height>201</height> 
    1414   </rect> 
    1515  </property> 
    1616  <property name="sizePolicy"> 
    17    <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> 
     17   <sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding"> 
    1818    <horstretch>0</horstretch> 
    1919    <verstretch>0</verstretch> 
     
    119119   </item> 
    120120   <item row="2" column="0"> 
     121    <widget class="QLabel" name="lblWarning"> 
     122     <property name="text"> 
     123      <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; color:#ff0000;&quot;&gt;Warning! Polydisperse parameter selected.&lt;br/&gt;&lt;/span&gt;Constraints involving polydisperse parameters only apply to&lt;br/&gt;starting values and are not re-applied during size or angle polydispersity&lt;br/&gt;integrations. To do so requires creating a custom model.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> 
     124     </property> 
     125    </widget> 
     126   </item> 
     127   <item row="3" column="0"> 
    121128    <spacer name="verticalSpacer"> 
    122129     <property name="orientation"> 
     
    131138    </spacer> 
    132139   </item> 
    133    <item row="3" column="0"> 
     140   <item row="4" column="0"> 
    134141    <layout class="QHBoxLayout" name="horizontalLayout_2"> 
    135142     <item> 
  • src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingWidgetTest.py

    rf712bf30 r8faac15  
    393393 
    394394        # Test tooltips 
    395         self.assertEqual(len(self.widget._poly_model.header_tooltips), 8) 
     395        self.assertEqual(len(self.widget._poly_model.header_tooltips), 9) 
    396396 
    397397        header_tooltips = ['Select parameter for fitting', 
    398                              'Enter polydispersity ratio (STD/mean). ' 
    399                              'STD: standard deviation from the mean value', 
    400                              'Enter minimum value for parameter', 
    401                              'Enter maximum value for parameter', 
    402                              'Enter number of points for parameter', 
    403                              'Enter number of sigmas parameter', 
    404                              'Select distribution function', 
    405                              'Select filename with user-definable distribution'] 
     398                            'Enter polydispersity ratio (Std deviation/mean).\n'+ 
     399                            'For angles this can be either std deviation or half width (for uniform distributions) in degrees', 
     400                            'Enter minimum value for parameter', 
     401                            'Enter maximum value for parameter', 
     402                            'Enter number of points for parameter', 
     403                            'Enter number of sigmas parameter', 
     404                            'Select distribution function', 
     405                            'Select filename with user-definable distribution'] 
    406406        for column, tooltip in enumerate(header_tooltips): 
    407407             self.assertEqual(self.widget._poly_model.headerData( column, 
     
    619619        # Set to 0 
    620620        self.widget.lstParams.indexWidget(func_index).setCurrentIndex(0) 
    621         self.assertEqual(self.widget._model_model.rowCount(), last_row - 2) # 2 fewer rows than default 
     621        self.assertEqual(self.widget._model_model.rowCount(), last_row - 2) 
    622622 
    623623    def testPlotTheory(self): 
     
    657657        self.assertEqual(spy.count(), 0) 
    658658 
    659     def testPlotData(self): 
     659    def notestPlotData(self): 
    660660        """ 
    661661        See that data item can produce a chart 
     
    908908        self.assertFalse(self.widget.tabFitting.isTabEnabled(4)) 
    909909 
    910     def testReadFitPage2D(self): 
     910    # to be fixed after functionality is ready 
     911    def notestReadFitPage2D(self): 
    911912        """ 
    912913        Read in the fitpage object and restore state 
  • src/sas/qtgui/Perspectives/Invariant/InvariantPerspective.py

    raed0532 rdee9e5f  
    233233 
    234234        plot_data = GuiUtils.plotsFromCheckedItems(self._manager.filesWidget.model) 
     235        #self.communicate.plotRequestedSignal.emit([item, plot], self.tab_id) 
    235236 
    236237        self._manager.filesWidget.plotData(plot_data) 
     
    347348                extrapolated_data.name = title 
    348349                extrapolated_data.title = title 
     350                extrapolated_data.style = "Line" 
     351                extrapolated_data.has_errors = False 
     352                extrapolated_data.plot_role = Data1D.ROLE_DEFAULT 
    349353 
    350354                # copy labels and units of axes for plotting 
     
    378382                high_out_data.name = title 
    379383                high_out_data.title = title 
     384                high_out_data.style = "Line" 
     385                high_out_data.has_errors = False 
     386                high_out_data.plot_role = Data1D.ROLE_DEFAULT 
    380387 
    381388                # copy labels and units of axes for plotting 
  • src/sas/qtgui/Perspectives/Inversion/DMaxExplorerWidget.py

    rb0ba43e r9f2f713  
    4242        self.parent = parent 
    4343 
    44         self.setWindowTitle("Dₐₓ Explorer") 
     44        self.setWindowTitle("Dmax Explorer") 
    4545 
    4646        self.pr_state = pr_state 
     
    116116        bck = [] 
    117117        chi2 = [] 
    118  
     118        plotable_xs = [] #Introducing this to make sure size of x and y for plotting is the same.8 
    119119        try: 
    120120            dmin = float(self.model.item(W.DMIN).text()) 
     
    128128 
    129129        original = self.pr_state.d_max 
     130 
    130131        for x in xs: 
    131132            self.pr_state.d_max = x 
     
    140141                bck.append(self.pr_state.background) 
    141142                chi2.append(self.pr_state.chi2) 
     143                plotable_xs.append(x) 
    142144            except Exception as ex: 
    143145                # This inversion failed, skip this D_max value 
     
    155157            logger.error(msg) 
    156158 
    157         plotter = self.model.item(W.VARIABLE).text() 
    158         y_label = y_unit = "" 
     159        plotter = self.dependentVariable.currentText() 
    159160        x_label = "D_{max}" 
    160161        x_unit = "A" 
     
    188189            y_unit = "a.u." 
    189190 
    190         data = Data1D(xs, ys) 
     191        data = Data1D(plotable_xs, ys) 
    191192        if self.hasPlot: 
    192             self.plot.removePlot(None) 
     193            self.plot.removePlot(data.name) 
    193194        self.hasPlot = True 
    194195        data.title = plotter 
  • src/sas/qtgui/Perspectives/Inversion/InversionLogic.py

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

    r2b8286c rdee9e5f  
    1414# pr inversion calculation elements 
    1515from sas.sascalc.pr.invertor import Invertor 
     16from sas.qtgui.Plotting.PlotterData import Data1D 
    1617# Batch calculation display 
    1718from sas.qtgui.Utilities.GridPanel import BatchInversionOutputPanel 
     
    4344    estimateSignal = QtCore.pyqtSignal(tuple) 
    4445    estimateNTSignal = QtCore.pyqtSignal(tuple) 
     46    estimateDynamicNTSignal = QtCore.pyqtSignal(tuple) 
     47    estimateDynamicSignal = QtCore.pyqtSignal(tuple) 
    4548    calculateSignal = QtCore.pyqtSignal(tuple) 
    4649 
     
    5255 
    5356        self._manager = parent 
     57        #Needed for Batch fitting 
     58        self._parent = parent 
    5459        self.communicate = parent.communicator() 
    5560        self.communicate.dataDeletedSignal.connect(self.removeData) 
     
    109114        # Set up the Widget Map 
    110115        self.setupMapper() 
     116 
     117        #Hidding calculate all buton 
     118        self.calculateAllButton.setVisible(False) 
    111119        # Set base window state 
    112120        self.setupWindow() 
     
    119127 
    120128    def allowBatch(self): 
    121         return True 
     129        return False 
    122130 
    123131    def setClosable(self, value=True): 
     
    194202        self.model.itemChanged.connect(self.model_changed) 
    195203        self.estimateNTSignal.connect(self._estimateNTUpdate) 
     204        self.estimateDynamicNTSignal.connect(self._estimateDynamicNTUpdate) 
     205        self.estimateDynamicSignal.connect(self._estimateDynamicUpdate) 
    196206        self.estimateSignal.connect(self._estimateUpdate) 
    197207        self.calculateSignal.connect(self._calculateUpdate) 
     208 
     209        self.maxDistanceInput.textEdited.connect(self.performEstimateDynamic) 
    198210 
    199211    def setupMapper(self): 
     
    309321                                            and not self.isCalculating) 
    310322        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)) 
     323        self.explorerButton.setEnabled(self.logic.data_is_loaded) 
    313324        self.stopButton.setVisible(self.isCalculating) 
    314325        self.regConstantSuggestionButton.setEnabled( 
     
    453464            # Create initial internal mappings 
    454465            self.logic.data = GuiUtils.dataFromItem(data) 
     466            if not isinstance(self.logic.data, Data1D): 
     467                msg = "P(r) perspective works for 1D data only" 
     468                logger.warning(msg) 
     469                continue 
    455470            # Estimate q range 
    456471            qmin, qmax = self.logic.computeDataRange() 
    457472            self._calculator.set_qmin(qmin) 
    458473            self._calculator.set_qmax(qmax) 
     474            if np.size(self.logic.data.dy) == 0 or np.all(self.logic.data.dy) == 0: 
     475                self.logic.data.dy = self._calculator.add_errors(self.logic.data.y) 
    459476            self.updateDataList(data) 
    460477            self.populateDataComboBox(self.logic.data.filename, data) 
    461478        self.dataList.setCurrentIndex(len(self.dataList) - 1) 
    462         self.setCurrentData(data) 
     479        #Checking for 1D again to mitigate the case when 2D data is last on the data list 
     480        if isinstance(self.logic.data, Data1D): 
     481            self.setCurrentData(data) 
    463482 
    464483    def updateDataList(self, dataRef): 
     
    501520        self.dataPlot = self._dataList[data_ref].get(DICT_KEYS[2]) 
    502521        self.performEstimate() 
     522 
     523    def updateDynamicGuiValues(self): 
     524        pr = self._calculator 
     525        alpha = self._calculator.suggested_alpha 
     526        self.model.setItem(WIDGETS.W_MAX_DIST, 
     527                            QtGui.QStandardItem("{:.4g}".format(pr.get_dmax()))) 
     528        self.regConstantSuggestionButton.setText("{:-3.2g}".format(alpha)) 
     529        self.noOfTermsSuggestionButton.setText( 
     530             "{:n}".format(self.nTermsSuggested)) 
     531 
     532        self.enableButtons() 
    503533 
    504534    def updateGuiValues(self): 
     
    520550        self.model.setItem(WIDGETS.W_MAX_DIST, 
    521551                           QtGui.QStandardItem("{:.4g}".format(pr.get_dmax()))) 
    522         self.regConstantSuggestionButton.setText("{:-3.2g}".format(alpha)) 
    523         self.noOfTermsSuggestionButton.setText( 
    524             "{:n}".format(self.nTermsSuggested)) 
    525552 
    526553        if isinstance(pr.chi2, np.ndarray): 
     
    544571        if self.prPlot is not None: 
    545572            title = self.prPlot.name 
     573            self.prPlot.plot_role = Data1D.ROLE_RESIDUAL 
    546574            GuiUtils.updateModelItemWithPlot(self._data, self.prPlot, title) 
    547             self.communicate.plotRequestedSignal.emit([self.prPlot], None) 
     575            self.communicate.plotRequestedSignal.emit([self._data,self.prPlot], None) 
    548576        if self.dataPlot is not None: 
    549577            title = self.dataPlot.name 
     578            self.dataPlot.plot_role = Data1D.ROLE_DEFAULT 
     579            self.dataPlot.symbol = "Line" 
     580            self.dataPlot.show_errors = False 
    550581            GuiUtils.updateModelItemWithPlot(self._data, self.dataPlot, title) 
    551             self.communicate.plotRequestedSignal.emit([self.dataPlot], None) 
     582            self.communicate.plotRequestedSignal.emit([self._data,self.dataPlot], None) 
    552583        self.enableButtons() 
    553584 
     
    633664 
    634665        pr = self._calculator.clone() 
    635         nfunc = self.getNFunc() 
    636         self.calcThread = CalcPr(pr, nfunc, 
     666        #Making sure that nfunc and alpha parameters are correctly initialized 
     667        pr.suggested_alpha = self._calculator.alpha 
     668        self.calcThread = CalcPr(pr, self.nTermsSuggested, 
    637669                                 error_func=self._threadError, 
    638670                                 completefn=self._calculateCompleted, 
     
    667699                                             error_func=self._threadError, 
    668700                                             completefn=self._estimateNTCompleted, 
     701                                             updatefn=None) 
     702        self.estimationThreadNT.queue() 
     703        self.estimationThreadNT.ready(2.5) 
     704 
     705    def performEstimateDynamicNT(self): 
     706        """ 
     707        Perform parameter estimation 
     708        """ 
     709        from .Thread import EstimateNT 
     710 
     711        self.updateCalculator() 
     712 
     713        # If a thread is already started, stop it 
     714        self.stopEstimateNTThread() 
     715 
     716        pr = self._calculator.clone() 
     717        # Skip the slit settings for the estimation 
     718        # It slows down the application and it doesn't change the estimates 
     719        pr.slit_height = 0.0 
     720        pr.slit_width = 0.0 
     721        nfunc = self.getNFunc() 
     722 
     723        self.estimationThreadNT = EstimateNT(pr, nfunc, 
     724                                             error_func=self._threadError, 
     725                                             completefn=self._estimateDynamicNTCompleted, 
    669726                                             updatefn=None) 
    670727        self.estimationThreadNT.queue() 
     
    693750        self.estimationThread.ready(2.5) 
    694751 
     752    def performEstimateDynamic(self): 
     753        """ 
     754            Perform parameter estimation 
     755        """ 
     756        from .Thread import EstimatePr 
     757 
     758        # If a thread is already started, stop it 
     759        self.stopEstimationThread() 
     760 
     761        self.estimationThread = EstimatePr(self._calculator.clone(), 
     762                                           self.getNFunc(), 
     763                                           error_func=self._threadError, 
     764                                           completefn=self._estimateDynamicCompleted, 
     765                                           updatefn=None) 
     766        self.estimationThread.queue() 
     767        self.estimationThread.ready(2.5) 
     768 
    695769    def stopEstimationThread(self): 
    696770        """ Stop the estimation thread if it exists and is running """ 
     
    705779        ''' Send a signal to the main thread for model update''' 
    706780        self.estimateSignal.emit((alpha, message, elapsed)) 
     781 
     782    def _estimateDynamicCompleted(self, alpha, message, elapsed): 
     783        ''' Send a signal to the main thread for model update''' 
     784        self.estimateDynamicSignal.emit((alpha, message, elapsed)) 
    707785 
    708786    def _estimateUpdate(self, output_tuple): 
     
    720798            logger.info(message) 
    721799        self.performEstimateNT() 
     800        self.performEstimateDynamicNT() 
     801 
     802    def _estimateDynamicUpdate(self, output_tuple): 
     803        """ 
     804        Parameter estimation completed, 
     805        display the results to the user 
     806 
     807        :param alpha: estimated best alpha 
     808        :param elapsed: computation time 
     809        """ 
     810        alpha, message, elapsed = output_tuple 
     811        self._calculator.alpha = alpha 
     812        self._calculator.elapsed += self._calculator.elapsed 
     813        if message: 
     814            logger.info(message) 
     815        self.performEstimateDynamicNT() 
    722816 
    723817    def _estimateNTCompleted(self, nterms, alpha, message, elapsed): 
    724818        ''' Send a signal to the main thread for model update''' 
    725819        self.estimateNTSignal.emit((nterms, alpha, message, elapsed)) 
     820 
     821    def _estimateDynamicNTCompleted(self, nterms, alpha, message, elapsed): 
     822        ''' Send a signal to the main thread for model update''' 
     823        self.estimateDynamicNTSignal.emit((nterms, alpha, message, elapsed)) 
    726824 
    727825    def _estimateNTUpdate(self, output_tuple): 
     
    747845            self.startThread() 
    748846 
     847    def _estimateDynamicNTUpdate(self, output_tuple): 
     848        """ 
     849        Parameter estimation completed, 
     850        display the results to the user 
     851 
     852        :param alpha: estimated best alpha 
     853        :param nterms: estimated number of terms 
     854        :param elapsed: computation time 
     855        """ 
     856        nterms, alpha, message, elapsed = output_tuple 
     857        self._calculator.elapsed += elapsed 
     858        self._calculator.suggested_alpha = alpha 
     859        self.nTermsSuggested = nterms 
     860        # Save useful info 
     861        self.updateDynamicGuiValues() 
     862        if message: 
     863            logger.info(message) 
     864        if self.isBatch: 
     865            self.acceptAlpha() 
     866            self.acceptNoTerms() 
     867            self.startThread() 
     868 
    749869    def _calculateCompleted(self, out, cov, pr, elapsed): 
    750870        ''' Send a signal to the main thread for model update''' 
  • src/sas/qtgui/Perspectives/Inversion/UI/DMaxExplorer.ui

    r8f83719f rcfd61f2  
    77    <x>0</x> 
    88    <y>0</y> 
    9     <width>394</width> 
    10     <height>426</height> 
     9    <width>586</width> 
     10    <height>538</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> 
    2923       </property> 
    3024      </spacer> 
  • src/sas/qtgui/Perspectives/Inversion/UI/TabbedInversionUI.ui

    r72ecbdf2 r68dc2873  
    77    <x>0</x> 
    88    <y>0</y> 
    9     <width>390</width> 
    10     <height>409</height> 
     9    <width>446</width> 
     10    <height>480</height> 
    1111   </rect> 
    1212  </property> 
     
    740740      <widget class="QPushButton" name="calculateAllButton"> 
    741741       <property name="enabled"> 
    742         <bool>true</bool> 
     742        <bool>false</bool> 
    743743       </property> 
    744744       <property name="sizePolicy"> 
  • src/sas/qtgui/Perspectives/Inversion/UnitTesting/InversionPerspectiveTest.py

    r144fe21 rccd2b87  
    9999    def baseBatchState(self): 
    100100        """ Testing the base batch fitting state """ 
    101         self.assertTrue(self.widget.allowBatch()) 
     101        self.assertFalse(self.widget.allowBatch()) 
    102102        self.assertFalse(self.widget.isBatch) 
    103103        self.assertFalse(self.widget.calculateAllButton.isEnabled()) 
     
    304304        self.assertIsNotNone(self.widget.dmaxWindow) 
    305305        self.assertTrue(self.widget.dmaxWindow.isVisible()) 
    306         self.assertTrue(self.widget.dmaxWindow.windowTitle() == "Dₐₓ Explorer") 
     306        self.assertTrue(self.widget.dmaxWindow.windowTitle() == "Dmax Explorer") 
    307307 
    308308 
Note: See TracChangeset for help on using the changeset viewer.