Changes in / [658dd57:fc6651c] in sasview


Ignore:
Location:
src/sas/sasgui/perspectives/fitting
Files:
2 edited

Legend:

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

    ra1b8fee ra1b8fee  
    361361                                   'Add a new model function') 
    362362        wx.EVT_MENU(owner, wx_id, self.make_new_model) 
    363          
     363 
    364364        wx_id = wx.NewId() 
    365365        self.edit_model_menu.Append(wx_id, 'Sum|Multi(p1, p2)', 
     
    383383          '(Re)Load all models present in user plugin_models folder') 
    384384        wx.EVT_MENU(owner, wx_id, self.load_plugin_models) 
    385                  
     385    
    386386    def set_edit_menu_helper(self, owner=None, menu=None): 
    387387        """ 
     
    17491749                                          data_id="Data  " + data.name + " unsmeared", 
    17501750                                          dy=unsmeared_error) 
    1751             # Comment this out until we can get P*S models with correctly populated parameters 
    1752             #if sq_model is not None and pq_model is not None: 
    1753             #    self.create_theory_1D(x, sq_model, page_id, model, data, state, 
    1754             #                          data_description=model.name + " S(q)", 
    1755             #                          data_id=str(page_id) + " " + data.name + " S(q)") 
    1756             #    self.create_theory_1D(x, pq_model, page_id, model, data, state, 
    1757             #                          data_description=model.name + " P(q)", 
    1758             #                          data_id=str(page_id) + " " + data.name + " P(q)") 
     1751            if sq_model is not None and pq_model is not None: 
     1752                self.create_theory_1D(x, sq_model, page_id, model, data, state, 
     1753                                      data_description=model.name + " S(q)", 
     1754                                      data_id=str(page_id) + " " + data.name + " S(q)") 
     1755                self.create_theory_1D(x, pq_model, page_id, model, data, state, 
     1756                                      data_description=model.name + " P(q)", 
     1757                                      data_id=str(page_id) + " " + data.name + " P(q)") 
    17591758 
    17601759            current_pg = self.fit_panel.get_page_by_id(page_id) 
     
    19121911                ## and may be the cause of other noted instabilities 
    19131912                ## 
    1914                 ##    -PDB August 12, 2014  
     1913                ##    -PDB August 12, 2014 
    19151914                while self.calc_2D.isrunning(): 
    19161915                    time.sleep(0.1) 
     
    19541953            if (self.calc_1D is not None) and self.calc_1D.isrunning(): 
    19551954                self.calc_1D.stop() 
    1956                 ## stop just raises the flag -- the thread is supposed to  
     1955                ## stop just raises the flag -- the thread is supposed to 
    19571956                ## then kill itself but cannot.  Paul Kienzle came up with 
    19581957                ## this fix to prevent threads from stepping on each other 
     
    19661965                ## a request to stop the computation. 
    19671966                ## It seems thus that the whole thread approach used here 
    1968                 ## May need rethinking   
     1967                ## May need rethinking 
    19691968                ## 
    19701969                ##    -PDB August 12, 2014 
     
    21312130            residuals.dxw = None 
    21322131            residuals.ytransform = 'y' 
    2133             # For latter scale changes  
     2132            # For latter scale changes 
    21342133            residuals.xaxis('\\rm{Q} ', 'A^{-1}') 
    21352134            residuals.yaxis('\\rm{Residuals} ', 'normalized') 
  • src/sas/sasgui/perspectives/fitting/model_thread.py

    r7432acb r426df2e  
    7171                    (self.data.qy_data * self.data.qy_data)) 
    7272 
    73         # For theory, qmax is based on 1d qmax  
     73        # For theory, qmax is based on 1d qmax 
    7474        # so that must be mulitified by sqrt(2) to get actual max for 2d 
    7575        index_model = (self.qmin <= radius) & (radius <= self.qmax) 
     
    9191                self.data.qy_data[index_model] 
    9292            ]) 
    93         output = np.zeros(len(self.data.qx_data)) 
     93        # Initialize output to NaN so masked elements do not get plotted. 
     94        output = np.empty_like(self.data.qx_data) 
    9495        # output default is None 
    9596        # This method is to distinguish between masked 
    9697        #point(nan) and data point = 0. 
    97         output = output / output 
     98        output[:] = np.NaN 
    9899        # set value for self.mask==True, else still None to Plottools 
    99100        output[index_model] = value 
     
    198199            output[index] = self.model.evalDistribution(self.data.x[index]) 
    199200 
     201        x=self.data.x[index] 
     202        y=output[index] 
    200203        sq_values = None 
    201204        pq_values = None 
    202         s_model = None 
    203         p_model = None 
    204205        if isinstance(self.model, MultiplicationModel): 
    205206            s_model = self.model.s_model 
    206207            p_model = self.model.p_model 
    207         elif hasattr(self.model, "get_composition_models"): 
    208             p_model, s_model = self.model.get_composition_models() 
    209  
    210         if p_model is not None and s_model is not None: 
    211             sq_values = np.zeros((len(self.data.x))) 
    212             pq_values = np.zeros((len(self.data.x))) 
    213             sq_values[index] = s_model.evalDistribution(self.data.x[index]) 
    214             pq_values[index] = p_model.evalDistribution(self.data.x[index]) 
     208            sq_values = s_model.evalDistribution(x) 
     209            pq_values = p_model.evalDistribution(x) 
     210        elif hasattr(self.model, "calc_composition_models"): 
     211            results = self.model.calc_composition_models(x) 
     212            if results is not None: 
     213                sq_values = results[0] 
     214                pq_values = results[1] 
     215 
    215216 
    216217        elapsed = time.time() - self.starttime 
    217218 
    218         self.complete(x=self.data.x[index], y=output[index], 
     219        self.complete(x=x, y=y, 
    219220                      page_id=self.page_id, 
    220221                      state=self.state, 
Note: See TracChangeset for help on using the changeset viewer.