Changeset 4b7d322 in sasview for src


Ignore:
Timestamp:
Sep 13, 2018 9:59:29 AM (6 years ago)
Author:
wojciech
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:
9f2f713
Parents:
eeea6a3 (diff), 855e7ad (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' of https://github.com/SasView/sasview into ESS_GUI_Pr_fixes

Location:
src/sas
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/MainWindow/DataExplorer.py

    r33b3e4d r855e7ad  
    574574        new_plots = [] 
    575575        for item, plot in plots.items(): 
    576             if self.updatePlot(plot) or filename not in plot.name: 
     576            if self.updatePlot(plot): 
     577                # Don't create plots which are already displayed 
    577578                continue 
    578579            # Don't plot intermediate results, e.g. P(Q), S(Q) 
     
    582583                continue 
    583584            # Don't include plots from different fitpages, but always include the original data 
    584             if fitpage_name in plot.name or filename == plot.name: 
     585            if fitpage_name in plot.name or filename in plot.name or filename == plot.filename: 
    585586                # Residuals get their own plot 
    586587                if plot.plot_role == Data1D.ROLE_RESIDUAL: 
  • src/sas/qtgui/Perspectives/Fitting/FittingWidget.py

    r6889ba2 r557fc498  
    13771377        self.communicate.statusBarUpdateSignal.emit('Fitting started...') 
    13781378        self.fit_started = True 
     1379 
    13791380        # Disable some elements 
    1380         self.setFittingStarted() 
     1381        self.disableInteractiveElements() 
    13811382 
    13821383    def stopFit(self): 
     
    13871388            return 
    13881389        self.calc_fit.stop() 
    1389         #self.fit_started=False 
    13901390        #re-enable the Fit button 
    1391         self.setFittingStopped() 
     1391        self.enableInteractiveElements() 
    13921392 
    13931393        msg = "Fitting cancelled." 
     
    14031403        """ 
    14041404        """ 
    1405         self.setFittingStopped() 
     1405        self.enableInteractiveElements() 
    14061406        msg = "Fitting failed with: "+ str(reason) 
    14071407        self.communicate.statusBarUpdateSignal.emit(msg) 
     
    14201420        """ 
    14211421        #re-enable the Fit button 
    1422         self.setFittingStopped() 
     1422        self.enableInteractiveElements() 
    14231423 
    14241424        if len(result) == 0: 
     
    14921492        """ 
    14931493        #re-enable the Fit button 
    1494         self.setFittingStopped() 
     1494        self.enableInteractiveElements() 
    14951495 
    14961496        if len(result) == 0: 
     
    23632363        weight = FittingUtilities.getWeight(data=data, is2d=self.is2D, flag=self.weighting) 
    23642364 
     2365        # Disable buttons/table 
     2366        self.disableInteractiveElements() 
    23652367        # Awful API to a backend method. 
    23662368        calc_thread = self.methodCalculateForData()(data=data, 
     
    24042406        Thread returned error 
    24052407        """ 
     2408        # Bring the GUI to normal state 
     2409        self.enableInteractiveElements() 
    24062410        print("Calculate Data failed with ", reason) 
    24072411 
     
    24162420        Plot the current 1D data 
    24172421        """ 
     2422        # Bring the GUI to normal state 
     2423        self.enableInteractiveElements() 
     2424 
    24182425        fitted_data = self.logic.new1DPlot(return_data, self.tab_id) 
    24192426        residuals = self.calculateResiduals(fitted_data) 
     
    24452452        Plot the current 2D data 
    24462453        """ 
     2454        # Bring the GUI to normal state 
     2455        self.enableInteractiveElements() 
     2456 
    24472457        fitted_data = self.logic.new2DPlot(return_data) 
    24482458        residuals = self.calculateResiduals(fitted_data) 
     
    25152525        Thread threw an exception. 
    25162526        """ 
     2527        # Bring the GUI to normal state 
     2528        self.enableInteractiveElements() 
    25172529        # TODO: remimplement thread cancellation 
    25182530        logger.error("".join(traceback.format_exception(etype, value, tb))) 
     
    28922904        self.setMagneticModel() 
    28932905 
    2894     def setFittingStarted(self): 
    2895         """ 
    2896         Set buttion caption on fitting start 
     2906    def setInteractiveElements(self, enabled=True): 
     2907        """ 
     2908        Switch interactive GUI elements on/off 
     2909        """ 
     2910        assert isinstance(enabled, bool) 
     2911 
     2912        self.lstParams.setEnabled(enabled) 
     2913        self.lstPoly.setEnabled(enabled) 
     2914        self.lstMagnetic.setEnabled(enabled) 
     2915 
     2916        self.cbCategory.setEnabled(enabled) 
     2917        self.cbModel.setEnabled(enabled) 
     2918        self.cbStructureFactor.setEnabled(enabled) 
     2919 
     2920        self.chkPolydispersity.setEnabled(enabled) 
     2921        self.chkMagnetism.setEnabled(enabled) 
     2922        self.chk2DView.setEnabled(enabled) 
     2923 
     2924    def enableInteractiveElements(self): 
     2925        """ 
     2926        Set buttion caption on fitting/calculate finish 
     2927        Enable the param table(s) 
     2928        """ 
     2929        # Notify the user that fitting is available 
     2930        self.cmdFit.setStyleSheet('QPushButton {color: black;}') 
     2931        self.cmdFit.setText("Fit") 
     2932        self.fit_started = False 
     2933        self.setInteractiveElements(True) 
     2934 
     2935    def disableInteractiveElements(self): 
     2936        """ 
     2937        Set buttion caption on fitting/calculate start 
     2938        Disable the param table(s) 
    28972939        """ 
    28982940        # Notify the user that fitting is being run 
     
    29002942        self.cmdFit.setStyleSheet('QPushButton {color: red;}') 
    29012943        self.cmdFit.setText('Stop fit') 
    2902  
    2903     def setFittingStopped(self): 
    2904         """ 
    2905         Set button caption on fitting stop 
    2906         """ 
    2907         # Notify the user that fitting is available 
    2908         self.cmdFit.setStyleSheet('QPushButton {color: black;}') 
    2909         self.cmdFit.setText("Fit") 
    2910         self.fit_started = False 
     2944        self.setInteractiveElements(False) 
    29112945 
    29122946    def readFitPage(self, fp): 
  • src/sas/qtgui/Perspectives/Inversion/InversionPerspective.py

    reeea6a3 r4b7d322  
    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 
     
    559560        if self.prPlot is not None: 
    560561            title = self.prPlot.name 
     562            self.prPlot.plot_role = Data1D.ROLE_RESIDUAL 
    561563            GuiUtils.updateModelItemWithPlot(self._data, self.prPlot, title) 
    562             self.communicate.plotRequestedSignal.emit([self.prPlot], None) 
    563564        if self.dataPlot is not None: 
    564565            title = self.dataPlot.name 
     566            self.dataPlot.plot_role = Data1D.ROLE_DEFAULT 
    565567            GuiUtils.updateModelItemWithPlot(self._data, self.dataPlot, title) 
    566             self.communicate.plotRequestedSignal.emit([self.dataPlot], None) 
     568        if self.dataPlot is not None or self.prPlot is not None: 
     569            self.communicate.plotRequestedSignal.emit([self.logic.data], None) 
    567570        self.enableButtons() 
    568571 
  • src/sas/qtgui/Perspectives/Inversion/DMaxExplorerWidget.py

    rb0ba43e re908916  
    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 
     
    188190            y_unit = "a.u." 
    189191 
    190         data = Data1D(xs, ys) 
     192        data = Data1D(plotable_xs, ys) 
    191193        if self.hasPlot: 
    192194            self.plot.removePlot(None) 
  • src/sas/sascalc/pr/invertor.py

    rb8080e1 reeea6a3  
    7171        A[j][i] = (Fourier transformed base function for point j) 
    7272 
    73     We them choose a number of r-points, n_r, to evaluate the second 
     73    We then 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 
    229243    def clone(self): 
    230244        """ 
     
    268282            A[i][j] = (Fourier transformed base function for point j) 
    269283 
    270         We them choose a number of r-points, n_r, to evaluate the second 
     284        We then choose a number of r-points, n_r, to evaluate the second 
    271285        derivative of P(r) at. This is used as our regularization term. 
    272286        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.