Changeset 785c8233 in sasview for sansview


Ignore:
Timestamp:
Aug 10, 2009 9:42:20 AM (15 years ago)
Author:
Gervaise Alina <gervyh@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
7e752fe
Parents:
fd0d30fd
Message:

modify chisqr calculation to use evaldistribution

Location:
sansview/perspectives/fitting
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • sansview/perspectives/fitting/fit_thread.py

    r60c1943 r785c8233  
    146146                          cpage= self.cpage, 
    147147                          elapsed=elapsed ) 
    148              
     148            
    149149        except KeyboardInterrupt: 
    150150            # Thread was interrupted, just proceed and re-raise. 
     
    155155        except : 
    156156            #Stop on exception during fitting. Todo: need to put some mssg and reset progress bar. 
    157             wx.PostEvent(self.parent, StatusEvent(status=" Fit exception occurred..." ,type="stop")) 
     157            msg= " Fit Error occurred... %s"%sys.exc_value 
     158            wx.PostEvent(self.parent, StatusEvent(status= msg,type="stop")) 
    158159            #raise 
    159160     
  • sansview/perspectives/fitting/gui_thread.py

    r077809c r785c8233  
    6262        res=[] 
    6363        try: 
    64             res = self.fitdata.residuals(self.model.run) 
     64            res = self.fitdata.residuals(self.model.evalDistribution) 
    6565            sum=0 
    6666            for item in res: 
     
    133133        res=[] 
    134134        try: 
    135             res = self.fitdata.residuals(self.model.run) 
     135            res = self.fitdata.residuals(self.model.evalDistribution) 
    136136            sum=0 
    137137            for item in res: 
  • sansview/perspectives/fitting/model_thread.py

    rb293683 r785c8233  
    5454        index_model = (self.qmin <= radius)&(radius<= self.qmax) 
    5555        
    56         ## receive only list of 2 numpy array  
    57         ## One must reshape to vertical and the other to horizontal 
    58         value = self.model.evalDistribution([self.y_array,self.x_array] ) 
    59         ## for data ignore the qmax  
    60         if self.data == None: 
    61             # Only qmin value will be consider for the detector 
    62             output = value *index_data   
    63         else: 
    64             # The user can define qmin and qmax for the detector 
    65             output = value*index_model 
    66          
     56        try: 
     57            ## receive only list of 2 numpy array  
     58            ## One must reshape to vertical and the other to horizontal 
     59            value = self.model.evalDistribution([self.y_array,self.x_array] ) 
     60            ## for data ignore the qmax  
     61            if self.data == None: 
     62                # Only qmin value will be consider for the detector 
     63                output = value *index_data   
     64            else: 
     65                # The user can define qmin and qmax for the detector 
     66                output = value*index_model 
     67        except: 
     68            raise 
     69            
     70        
    6771        elapsed = time.time()-self.starttime 
    6872        self.complete( image = output, 
     
    7478                       qstep = self.qstep ) 
    7579         
    76     def compute_point(self): 
    77         """ 
    78             Compute the data given a model function. Loop through each point 
    79             of x and y to compute the model 
    80             @return output : is a matrix of size x*y 
    81         """ 
    82         output = numpy.zeros((len(self.x),len(self.y))) 
    83         
    84         for i_x in range(len(self.x)): 
    85             # Check whether we need to bail out 
    86             self.update(output=output ) 
    87             self.isquit() 
    88         
    89             for i_y in range(int(len(self.y))): 
    90                 radius = math.sqrt(self.x[i_x]*self.x[i_x]+self.y[i_y]*self.y[i_y]) 
    91                 ## for data ignore the qmax  
    92                 if self.data == None: 
    93                     if  self.qmin <= radius : 
    94                         value = self.model.runXY( [self.x[i_x], self.y[i_y]] ) 
    95                         output[i_y][i_x] =value    
    96                     else: 
    97                         output[i_y][i_x] =0    
    98                 else:   
    99                     if  self.qmin <= radius and radius<= self.qmax: 
    100                         value = self.model.runXY( [self.x[i_x], self.y[i_y]] ) 
    101                         output[i_y][i_x] =value    
    102                     else: 
    103                         output[i_y][i_x] =0   
    104         return output  
    105       
     80    
    10681     
    10782 
     
    138113        self.starttime = time.time() 
    139114         
    140         index= (self.qmin <= self.x)& (self.x <= self.qmax) 
    141         output = self.model.evalDistribution(self.x[index]) 
    142   
     115        try: 
     116            index= (self.qmin <= self.x)& (self.x <= self.qmax) 
     117            output = self.model.evalDistribution(self.x[index]) 
     118        except: 
     119            raise 
     120             
     121 
    143122        ##smearer the ouput of the plot     
    144123        if self.smearer!=None: 
     
    150129                 
    151130        elapsed = time.time()-self.starttime 
    152          
     131        
    153132        self.complete(x= self.x, y= output,  
    154133                      elapsed=elapsed, model= self.model, data=self.data) 
    155134         
    156     def compute_point(self): 
    157         """ 
    158             Compute the data given a model function. Loop through each point 
    159             of x  compute the model 
    160             @return output : is a numpy vector of size x 
    161         """   
    162         output = numpy.zeros(len(self.x))       
    163         # Loop through each q of data.x 
    164         for i_x in range(len(self.x)): 
    165             self.update(x= self.x, output=output ) 
    166             # Check whether we need to bail out 
    167             self.isquit() 
    168             if self.qmin <= self.x[i_x] and self.x[i_x] <= self.qmax: 
    169                 value = self.model.run(self.x[i_x]) 
    170                 output[i_x] = value 
    171                  
    172         return output 
    173                  
     135  
    174136                 
    175137class CalcCommandline: 
Note: See TracChangeset for help on using the changeset viewer.