Changeset b7f7d3f in sasview for src/sas


Ignore:
Timestamp:
Aug 22, 2018 7:02:41 AM (6 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
Branches:
ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
54492dc
Parents:
f7d39c9 (diff), 0fe7e5b (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

Location:
src/sas/qtgui
Files:
5 edited

Legend:

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

    recfe6b6 r0fe7e5b  
    977977        if category == CATEGORY_STRUCTURE: 
    978978            model = None 
     979 
     980        # Reset parameters to fit 
     981        self.parameters_to_fit = None 
     982        self.has_error_column = False 
     983        self.has_poly_error_column = False 
     984 
    979985        self.respondToModelStructure(model=model, structure_factor=structure) 
    980986 
     
    16501656        Take func and throw it inside the magnet model row loop 
    16511657        """ 
    1652         for row_i in range(self._model_model.rowCount()): 
     1658        for row_i in range(self._magnet_model.rowCount()): 
    16531659            func(row_i) 
    16541660 
     
    16621668        if self._magnet_model.rowCount() == 0: 
    16631669            return 
    1664  
    1665         def iterateOverMagnetModel(func): 
    1666             """ 
    1667             Take func and throw it inside the magnet model row loop 
    1668             """ 
    1669             for row_i in range(self._magnet_model.rowCount()): 
    1670                 func(row_i) 
    16711670 
    16721671        def updateFittedValues(row): 
     
    22282227        """ 
    22292228        fitted_data = self.logic.new1DPlot(return_data, self.tab_id) 
    2230         self.calculateResiduals(fitted_data) 
     2229        residuals = self.calculateResiduals(fitted_data) 
    22312230        self.model_data = fitted_data 
     2231 
     2232        new_plots = [fitted_data, residuals] 
    22322233 
    22332234        # Create plots for intermediate product data 
     
    22362237            pq_data.symbol = "Line" 
    22372238            self.createNewIndex(pq_data) 
     2239            new_plots.append(pq_data) 
    22382240        if sq_data is not None: 
    22392241            sq_data.symbol = "Line" 
    22402242            self.createNewIndex(sq_data) 
     2243            new_plots.append(sq_data) 
     2244 
     2245        if self.data_is_loaded: 
     2246            GuiUtils.deleteRedundantPlots(self.all_data[self.data_index], new_plots) 
    22412247 
    22422248    def complete2D(self, return_data): 
     
    22742280        residuals_plot.id = "Residual " + residuals_plot.id 
    22752281        self.createNewIndex(residuals_plot) 
     2282        return residuals_plot 
    22762283 
    22772284    def onCategoriesChanged(self): 
  • src/sas/qtgui/Utilities/GuiUtils.py

    r3933ee9 r0fe7e5b  
    292292    # Append the new row to the main item 
    293293    item.appendRow(checkbox_item) 
     294 
     295def deleteRedundantPlots(item, new_plots): 
     296    """ 
     297    Checks all plots that are children of the given item; if any have an ID or name not included in new_plots, 
     298    it is deleted. Useful for e.g. switching from P(Q)S(Q) to P(Q); this would remove the old S(Q) plot. 
     299 
     300    Ensure that new_plots contains ALL the relevant plots(!!!) 
     301    """ 
     302    assert isinstance(item, QtGui.QStandardItem) 
     303 
     304    names = [p.name for p in new_plots if p.name is not None] 
     305    ids = [p.id for p in new_plots if p.id is not None] 
     306 
     307    items_to_delete = [] 
     308 
     309    for index in range(item.rowCount()): 
     310        plot_item = item.child(index) 
     311        if plot_item.isCheckable(): 
     312            plot_data = plot_item.child(0).data() 
     313            if (plot_data.id is not None) and (plot_data.id not in ids) and (plot_data.name not in names): 
     314                items_to_delete.append(plot_item) 
     315 
     316    for plot_item in items_to_delete: 
     317        item.removeRow(plot_item.row()) 
    294318 
    295319class HashableStandardItem(QtGui.QStandardItem): 
  • src/sas/qtgui/MainWindow/DataExplorer.py

    rb51c8fc rf7d39c9  
    542542                # 'sophisticated' test to generate standalone plot for residuals 
    543543                if 'esiduals' in plot.title: 
    544                     self.plotData([(item, plot)]) 
     544                    self.plotData([(item, plot)], transform=False) 
    545545                else: 
    546546                    new_plots.append((item, plot)) 
     
    583583        #============================================ 
    584584 
    585     def plotData(self, plots): 
     585    def plotData(self, plots, transform=True): 
    586586        """ 
    587587        Takes 1D/2D data and generates a single plot (1D) or multiple plots (2D) 
     
    594594                    new_plot = Plotter(self) 
    595595                    new_plot.item = item 
    596                 new_plot.plot(plot_set) 
     596                new_plot.plot(plot_set, transform=transform) 
    597597                # active_plots may contain multiple charts 
    598598                self.active_plots[plot_set.id] = new_plot 
  • src/sas/qtgui/Perspectives/Fitting/FittingOptions.py

    raed0532 rf7d39c9  
    146146            """ 
    147147            widget = self.widgetFromOption(option) 
    148             new_value = widget.currentText() if isinstance(widget, QtWidgets.QComboBox) \ 
    149                 else float(widget.text()) 
    150             self.config.values[self.current_fitter_id][option] = new_value 
     148            if widget is None: 
     149                return 
     150            try: 
     151                new_value = widget.currentText() if isinstance(widget, QtWidgets.QComboBox) \ 
     152                    else float(widget.text()) 
     153                self.config.values[self.current_fitter_id][option] = new_value 
     154            except ValueError: 
     155                # Don't update bumps if widget has bad data 
     156                self.reject 
    151157 
    152158        # Update the BUMPS singleton 
  • src/sas/qtgui/Perspectives/Fitting/FittingUtilities.py

    r04972ea rf7d39c9  
    335335    gn = reference_data.y 
    336336    en = dy[index][0] 
     337 
     338    # x values 
     339    x_current = current_data.x 
     340    x_reference = reference_data.x 
     341 
    337342    # build residuals 
    338343    residuals = Data1D() 
     
    340345        y = (fn - gn)/en 
    341346        residuals.y = -y 
     347    elif len(fn) > len(gn): 
     348        residuals.y = (fn - gn[1:len(fn)])/en 
    342349    else: 
    343         # TODO: fix case where applying new data from file on top of existing model data 
    344350        try: 
    345             y = (fn - gn[index][0]) / en 
     351            y = numpy.zeros(len(current_data.y)) 
     352            begin = 0 
     353            for i, x_value in enumerate(x_reference): 
     354                if x_value in x_current: 
     355                    begin = i 
     356                    break 
     357            end = len(x_reference) 
     358            endl = 0 
     359            for i, x_value in enumerate(list(x_reference)[::-1]): 
     360                if x_value in x_current: 
     361                    endl = i 
     362                    break 
     363            # make sure we have correct lengths 
     364            assert len(x_current) == len(x_reference[begin:end-endl]) 
     365 
     366            y = (fn - gn[begin:end-endl])/en 
    346367            residuals.y = y 
    347368        except ValueError: 
Note: See TracChangeset for help on using the changeset viewer.