Ignore:
Timestamp:
May 10, 2010 4:50:05 PM (14 years ago)
Author:
Jae Cho <jhjcho@…>
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:
4fbc93e
Parents:
2d409fa
Message:

Plugged in 2D smear: traditional over-sampling method

File:
1 edited

Legend:

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

    r51a71a3 rf72333f  
    33import sys 
    44import numpy,math 
    5  
     5from DataLoader.smearing_2d import Smearer2D 
     6import fitpage 
    67class Calc2D(CalcThread): 
    78    """ 
     
    1213    """ 
    1314     
    14     def __init__(self, x, y, data,model,qmin, qmax,qstep, 
     15    def __init__(self, x, y, data,model,smearer,qmin, qmax,qstep, 
    1516                 completefn = None, 
    1617                 updatefn   = None, 
     
    3132        # the model on to calculate 
    3233        self.model = model 
     34        self.smearer = smearer#(data=self.data,model=self.model) 
    3335        self.starttime = 0   
    3436         
     
    5153            self.qx_data = self.data.qx_data 
    5254            self.qy_data = self.data.qy_data 
     55            self.dqx_data = self.data.dqx_data 
     56            self.dqy_data = self.data.dqy_data 
    5357            self.mask    = self.data.mask 
    5458        else:           
     
    8690            # Only qmin value will be consider for the detector 
    8791            index_model = index_data   
    88               
    89         value = self.model.evalDistribution([self.qx_data[index_model],self.qy_data[index_model]] ) 
     92 
     93        if self.smearer != None: 
     94            # Set smearer w/ data, model and index. 
     95            fn = self.smearer 
     96            fn.set_model(self.model) 
     97            fn.set_index(index_model) 
     98            # Get necessary data from self.data and set the data for smearing 
     99            fn.get_data() 
     100            # Calculate smeared Intensity (by Gaussian averaging): DataLoader/smearing2d/Smearer2D() 
     101            value = fn.get_value() 
     102 
     103        else:     
     104            # calculation w/o smearing 
     105            value =  self.model.evalDistribution([self.qx_data[index_model],self.qy_data[index_model]]) 
    90106 
    91107        output = numpy.zeros(len(self.qx_data)) 
    92108         
    93109        # output default is None 
    94         # This method is to distinguish between masked point and data point = 0. 
     110        # This method is to distinguish between masked point(nan) and data point = 0. 
    95111        output = output/output 
    96112        # set value for self.mask==True, else still None to Plottools 
    97113        output[index_model] = value  
     114 
    98115        elapsed = time.time()-self.starttime 
    99116        self.complete( image = output, 
     
    101118                       model = self.model, 
    102119                       elapsed = elapsed, 
     120                       index = index_model, 
    103121                       qmin = self.qmin, 
    104122                       qmax = self.qmax, 
    105123                       qstep = self.qstep ) 
    106124         
    107     
    108      
    109125 
    110126class Calc1D(CalcThread): 
     
    153169        
    154170        self.complete(x= self.x[index], y= output[index],  
    155                       elapsed=elapsed, model= self.model, data=self.data) 
    156          
    157   
     171                      elapsed=elapsed,index=index, model= self.model, data=self.data) 
     172 
     173         
     174    def results(self): 
     175        """ 
     176            Send resuts of the computation 
     177        """ 
     178        return [self.out, self.index] 
    158179                 
    159180class CalcCommandline: 
Note: See TracChangeset for help on using the changeset viewer.