Changeset c2a8523 in sasview


Ignore:
Timestamp:
Jan 15, 2009 12:44:25 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:
4853c04
Parents:
3bae6c8
Message:

Calculate correct number of bins for 1d plot after 2D sector averaging

File:
1 edited

Legend:

Unmodified
Added
Removed
  • DataLoader/manipulations.py

    rfb198a9 rc2a8523  
    633633    return None 
    634634     
    635  
     635#This class can be removed. 
    636636class _Sectorold: 
    637637    """ 
     
    804804        y_err    = numpy.zeros(self.nbins) 
    805805         
     806        # This If finds qmax within ROI defined by sector lines 
     807        if run.lower()=='q2'or run.lower()=='q':             
     808            tempq=0 #to find qmax within ROI 
     809            for i in range(numpy.size(data,1)):   
     810                dx = pixel_width_x*(i+0.5 - center_x)                   
     811                for j in range(numpy.size(data,0)): 
     812                     
     813                    dy = pixel_width_y*(j+0.5 - center_y) 
     814                    q_value = get_q(dx, dy, det_dist, wavelength) 
     815                    # Compute phi and check whether it's within the limits 
     816                    phi_value=math.atan2(dy,dx)+math.pi 
     817                    if self.phi_max>2*math.pi: 
     818                        self.phi_max=self.phi_max-2*math.pi 
     819                    if self.phi_min<0: 
     820                        self.phi_max=self.phi_max+2*math.pi 
     821                 
     822                    #In case of two ROI (symmetric major and minor regions)(for 'q2') 
     823                    if run.lower()=='q2': 
     824                        if ((self.phi_max>=0 and self.phi_max<math.pi)and (self.phi_min>=0 and self.phi_min<math.pi)): 
     825                            temp_max=self.phi_max+math.pi 
     826                            temp_min=self.phi_min+math.pi 
     827                        else: 
     828                            temp_max=self.phi_max 
     829                            temp_min=self.phi_min 
     830                        
     831                        if ((temp_max>=math.pi and temp_max<2*math.pi)and (temp_min>=math.pi and temp_min<2*math.pi)): 
     832                            if (phi_value<temp_min  or phi_value>temp_max): 
     833                                if (phi_value<temp_min-math.pi  or phi_value>temp_max-math.pi): 
     834                                    continue 
     835                        if (self.phi_max<self.phi_min): 
     836                            tmp_max=self.phi_max+math.pi 
     837                            tmp_min=self.phi_min-math.pi 
     838                        else: 
     839                            tmp_max=self.phi_max 
     840                            tmp_min=self.phi_min 
     841                        if (tmp_min<math.pi and tmp_max>math.pi): 
     842                            if((phi_value>tmp_max and phi_value<tmp_min+math.pi)or (phi_value>tmp_max-math.pi and phi_value<tmp_min)): 
     843                                continue 
     844                    #In case of one ROI (major only)(i.e.,for 'q' and 'phi') 
     845                    else:  
     846                        if (self.phi_max>=self.phi_min): 
     847                            if (phi_value<self.phi_min  or phi_value>self.phi_max): 
     848                                continue 
     849                        else: 
     850                            if (phi_value<self.phi_min and phi_value>self.phi_max): 
     851                                continue                       
     852                    if tempq<q_value: 
     853                        tempq=q_value 
     854            qmax=tempq                                             
     855        print "qmax=",qmax        
     856                 
    806857        for i in range(numpy.size(data,1)): 
    807858            dx = pixel_width_x*(i+0.5 - center_x) 
     
    827878                q_11 = get_q(maxx, maxy, det_dist, wavelength) 
    828879                 
    829                 # Look for intercept between each side of the pixel 
    830                 # and the constant-q ring for qmax 
    831                 frac_max = get_pixel_fraction(qmax, q_00, q_01, q_10, q_11) 
    832                  
    833                 # Look for intercept between each side of the pixel 
    834                 # and the constant-q ring for qmin 
    835                 frac_min = get_pixel_fraction(qmin, q_00, q_01, q_10, q_11) 
    836                  
    837                 # We are interested in the region between qmin and qmax 
    838                 # therefore the fraction of the surface of the pixel 
    839                 # that we will use to calculate the number of counts to  
    840                 # include is given by: 
    841                  
    842                 frac = frac_max - frac_min 
    843  
    844880                # Compute phi and check whether it's within the limits 
    845881                phi_value=math.atan2(dy,dx)+math.pi 
     
    848884                if self.phi_min<0: 
    849885                    self.phi_max=self.phi_max+2*math.pi 
    850  
    851                 #In case of two ROI (symetric major and minor regions)(for 'q2') 
     886                     
     887                # Look for intercept between each side of the pixel 
     888                # and the constant-q ring for qmax 
     889                frac_max = get_pixel_fraction(qmax, q_00, q_01, q_10, q_11) 
     890                 
     891                # Look for intercept between each side of the pixel 
     892                # and the constant-q ring for qmin 
     893                frac_min = get_pixel_fraction(qmin, q_00, q_01, q_10, q_11) 
     894                 
     895                # We are interested in the region between qmin and qmax 
     896                # therefore the fraction of the surface of the pixel 
     897                # that we will use to calculate the number of counts to  
     898                # include is given by: 
     899                 
     900                frac = frac_max - frac_min 
     901 
     902                #In case of two ROI (symmetric major and minor regions)(for 'q2') 
    852903                if run.lower()=='q2': 
    853904                    if ((self.phi_max>=0 and self.phi_max<math.pi)and (self.phi_min>=0 and self.phi_min<math.pi)): 
     
    871922                        if((phi_value>tmp_max and phi_value<tmp_min+math.pi)or (phi_value>tmp_max-math.pi and phi_value<tmp_min)): 
    872923                            continue 
    873                 #In case of one ROI (major only)(for 'q' and 'phi') 
     924                #In case of one ROI (major only)(i.e.,for 'q' and 'phi') 
    874925                else:  
    875926                    if (self.phi_max>=self.phi_min): 
     
    889940                    # the ring defined by q_min/q_max rather than the complete 
    890941                    # pixel  
    891                     if q_value<self.r_min or q_value>self.r_max: 
     942                    if q_value<qmin or q_value>qmax: 
    892943                        continue 
    893                     i_bin = int(math.ceil(self.nbins*(q_value-self.r_min)/(self.r_max-self.r_min))) - 1 
    894              
     944                    i_bin = int(math.ceil(self.nbins*(q_value-qmin)/(qmax-qmin))) - 1 
     945                            
    895946                try: 
    896947                    y[i_bin] += frac * data[j][i] 
     
    913964                x[i] = (self.phi_max-self.phi_min)/self.nbins*(1.0*i + 0.5)+self.phi_min 
    914965            else: 
    915                 x[i] = (self.r_max-self.r_min)/self.nbins*(1.0*i + 0.5)+self.r_min 
     966                x[i] = (qmax-qmin)/self.nbins*(1.0*i + 0.5)+qmin 
    916967             
    917968        return Data1D(x=x, y=y, dy=y_err) 
     
    9771028 
    9781029     
    979     r = SectorQ(r_min=.005, r_max=.01, phi_min=0.0, phi_max=math.pi/2.0) 
     1030    r = SectorQ(r_min=.000001, r_max=.01, phi_min=0.0, phi_max=math.pi/2.0) 
    9801031    o = r(d) 
    9811032     
Note: See TracChangeset for help on using the changeset viewer.