Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/fitting/fitting.py

    r7673ecd rca4d985  
    313313        """ 
    314314        event_id = event.GetId() 
    315         self.update_custom_combo()         
     315        self.update_custom_combo() 
    316316 
    317317    def update_custom_combo(self): 
     
    342342                                page.formfactorbox.SetLabel(current_val) 
    343343        except: 
    344             pass 
    345  
     344            logging.error("update_custom_combo: %s", sys.exc_value) 
    346345 
    347346    def set_edit_menu(self, owner): 
     
    16661665        wx.PostEvent(self.parent, StatusEvent(status=msg, type="update")) 
    16671666 
     1667    def create_theory_1D(self, x, y, page_id, model, data, state, 
     1668                         data_description, data_id, dy=None): 
     1669        """ 
     1670            Create a theory object associate with an existing Data1D 
     1671            and add it to the data manager. 
     1672            @param x: x-values of the data 
     1673            @param y: y_values of the data 
     1674            @param page_id: fit page ID 
     1675            @param model: model used for fitting 
     1676            @param data: Data1D object to create the theory for 
     1677            @param state: model state 
     1678            @param data_description: title to use in the data manager 
     1679            @param data_id: unique data ID 
     1680        """ 
     1681        new_plot = Data1D(x=x, y=y) 
     1682        if dy is None: 
     1683            new_plot.is_data = False 
     1684            new_plot.dy = numpy.zeros(len(y)) 
     1685            # If this is a theory curve, pick the proper symbol to make it a curve 
     1686            new_plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM 
     1687        else: 
     1688            new_plot.is_data = True 
     1689            new_plot.dy = dy 
     1690        new_plot.interactive = True 
     1691        new_plot.dx = None 
     1692        new_plot.dxl = None 
     1693        new_plot.dxw = None 
     1694        _yaxis, _yunit = data.get_yaxis() 
     1695        _xaxis, _xunit = data.get_xaxis() 
     1696        new_plot.title = data.name 
     1697        new_plot.group_id = data.group_id 
     1698        if new_plot.group_id == None: 
     1699            new_plot.group_id = data.group_id 
     1700        new_plot.id = data_id 
     1701        # Find if this theory was already plotted and replace that plot given 
     1702        # the same id 
     1703        self.page_finder[page_id].get_theory_data(fid=data.id) 
     1704 
     1705        if data.is_data: 
     1706            data_name = str(data.name) 
     1707        else: 
     1708            data_name = str(model.__class__.__name__) 
     1709 
     1710        new_plot.name = data_description + " [" + data_name + "]" 
     1711        new_plot.xaxis(_xaxis, _xunit) 
     1712        new_plot.yaxis(_yaxis, _yunit) 
     1713        self.page_finder[page_id].set_theory_data(data=new_plot, 
     1714                                                  fid=data.id) 
     1715        self.parent.update_theory(data_id=data.id, theory=new_plot, 
     1716                                   state=state) 
     1717        return new_plot 
     1718 
    16681719    def _complete1D(self, x, y, page_id, elapsed, index, model, 
    16691720                    weight=None, fid=None, 
    16701721                    toggle_mode_on=False, state=None, 
    16711722                    data=None, update_chisqr=True, 
    1672                     source='model', plot_result=True): 
    1673         """ 
    1674         Complete plotting 1D data 
     1723                    source='model', plot_result=True, 
     1724                    unsmeared_model=None, unsmeared_data=None, 
     1725                    unsmeared_error=None, sq_model=None, pq_model=None): 
     1726        """ 
     1727            Complete plotting 1D data 
     1728            @param unsmeared_model: fit model, without smearing 
     1729            @param unsmeared_data: data, rescaled to unsmeared model 
     1730            @param unsmeared_error: data error, rescaled to unsmeared model 
    16751731        """ 
    16761732        try: 
    16771733            numpy.nan_to_num(y) 
    1678  
    1679             new_plot = Data1D(x=x, y=y) 
    1680             new_plot.is_data = False 
    1681             new_plot.dy = numpy.zeros(len(y)) 
    1682             new_plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM 
    1683             _yaxis, _yunit = data.get_yaxis() 
    1684             _xaxis, _xunit = data.get_xaxis() 
    1685             new_plot.title = data.name 
    1686  
    1687             new_plot.group_id = data.group_id 
    1688             if new_plot.group_id == None: 
    1689                 new_plot.group_id = data.group_id 
    1690             new_plot.id = str(page_id) + " " + data.name 
    1691             #if new_plot.id in self.color_dict: 
    1692             #    new_plot.custom_color = self.color_dict[new_plot.id] 
    1693             #find if this theory was already plotted and replace that plot given 
    1694             #the same id 
    1695             self.page_finder[page_id].get_theory_data(fid=data.id) 
    1696  
    1697             if data.is_data: 
    1698                 data_name = str(data.name) 
    1699             else: 
    1700                 data_name = str(model.__class__.__name__) 
    1701  
    1702             new_plot.name = model.name + " [" + data_name + "]" 
    1703             new_plot.xaxis(_xaxis, _xunit) 
    1704             new_plot.yaxis(_yaxis, _yunit) 
    1705             self.page_finder[page_id].set_theory_data(data=new_plot, 
    1706                                                       fid=data.id) 
    1707             self.parent.update_theory(data_id=data.id, theory=new_plot, 
    1708                                        state=state) 
     1734            new_plot = self.create_theory_1D(x, y, page_id, model, data, state, 
     1735                                             data_description=model.name, 
     1736                                             data_id=str(page_id) + " " + data.name) 
     1737            if unsmeared_model is not None: 
     1738                self.create_theory_1D(x, unsmeared_model, page_id, model, data, state, 
     1739                                      data_description=model.name + " unsmeared", 
     1740                                      data_id=str(page_id) + " " + data.name + " unsmeared") 
     1741 
     1742                self.create_theory_1D(x, unsmeared_data, page_id, model, data, state, 
     1743                                      data_description="Data unsmeared", 
     1744                                      data_id="Data  " + data.name + " unsmeared", 
     1745                                      dy=unsmeared_error) 
     1746                 
     1747            if sq_model is not None and pq_model is not None: 
     1748                self.create_theory_1D(x, sq_model, page_id, model, data, state, 
     1749                                      data_description=model.name + " S(q)", 
     1750                                      data_id=str(page_id) + " " + data.name + " S(q)") 
     1751                self.create_theory_1D(x, pq_model, page_id, model, data, state, 
     1752                                      data_description=model.name + " P(q)", 
     1753                                      data_id=str(page_id) + " " + data.name + " P(q)") 
     1754 
     1755 
    17091756            current_pg = self.fit_panel.get_page_by_id(page_id) 
    17101757            title = new_plot.title 
Note: See TracChangeset for help on using the changeset viewer.