Changeset fe2ade9 in sasview for DataLoader/qsmearing.py


Ignore:
Timestamp:
Mar 4, 2009 3:47:12 PM (15 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:
6c0568b
Parents:
eba08f1a
Message:

fixed a bug in slit smearing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • DataLoader/qsmearing.py

    rc0d9981 rfe2ade9  
    107107             
    108108            for i in range(self.nbins): 
    109                 sum += iq[i] * self._weights[q_i][i] 
    110                 counts += self._weights[q_i][i] 
    111                  
     109                if iq[i]!=0 and self._weights[q_i][i]!=0: 
     110                    sum += iq[i] * self._weights[q_i][i]  
     111                    counts += self._weights[q_i][i] 
     112                    #print "i,iq[i],self._weights[q_i][i] ",i,iq[i],self._weights[q_i][i] 
    112113            iq_smeared[q_i] = sum/counts  
    113                  
     114            #print "q_i,iq_smeared[q_i]",q_i,iq[i],iq_smeared[q_i] 
     115            #print "iq[i],iq_smeared[q_i],sum,counts,self.nbins",iq[i], iq_smeared[q_i],sum,counts,self.nbins 
    114116        return iq_smeared     
    115117     
     
    156158            # For each q-value, compute the weight of each other q-bin 
    157159            # in the I(q) array 
    158             npts_h = self.npts if self.height>0 else 1 
    159             npts_w = self.npts if self.width>0 else 1 
     160            npts_h = self.nbins if self.height>0 else 1 #changed self.npts=>self.nbins 
     161            npts_w = self.nbins if self.width>0 else 1 #changed self.npts=>self.nbins 
    160162             
    161163            # If both height and width are great than zero, 
     
    184186                    if q_i<self.nbins: 
    185187                        weights[i][q_i] = weights[i][q_i]+1.0 
    186                                  
     188 
    187189        self._weights = weights 
    188190        return self._weights 
     
    264266            q_min = q - 0.5*step 
    265267            q_max = q + 0.5*step 
    266              
    267268            for j in range(self.nbins): 
    268269                q_j = self.min + j*step 
     
    270271                # Compute the fraction of the Gaussian contributing 
    271272                # to the q bin between q_min and q_max 
     273                #value =  math.exp(-math.pow((q_max-q_j),2)/(2*math.pow(self.width[j],2) )) 
     274                #value +=  math.exp(-math.pow((q_max-q_j),2)/(2*math.pow(self.width[j],2) ))  
    272275                value =  scipy.special.erf( (q_max-q_j)/(math.sqrt(2.0)*self.width[j]) )  
    273276                value -=scipy.special.erf( (q_min-q_j)/(math.sqrt(2.0)*self.width[j]) )  
    274  
    275277                weights[i][j] += value 
    276278                                 
     
    321323    if True: 
    322324        for i in range(10): 
    323             print x[i], sy[i] 
     325            print x[i],y[i], sy[i] 
    324326            #print q, ' : ', s.weight(q), s._compute_iq(q)  
    325327            #print q, ' : ', s(q), s._compute_iq(q)  
Note: See TracChangeset for help on using the changeset viewer.