Changeset c8a6c3d7 in sasview for src/sas


Ignore:
Timestamp:
Mar 3, 2015 10:28:02 AM (9 years ago)
Author:
Doucet, Mathieu <doucetm@…>
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:
3c3a440
Parents:
f06d7fc
Message:

pylint fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/dataloader/manipulations.py

    rddc192a rc8a6c3d7  
    2424    :param dx: x-distance from beam center [mm] 
    2525    :param dy: y-distance from beam center [mm] 
    26      
    2726    :return: q-value at the given position 
    2827    """ 
    2928    # Distance from beam center in the plane of detector 
    30     plane_dist = math.sqrt(dx*dx + dy*dy) 
     29    plane_dist = math.sqrt(dx * dx + dy * dy) 
    3130    # Half of the scattering angle 
    32     theta = 0.5 * math.atan(plane_dist/det_dist) 
    33     return (4.0 * math.pi/wavelength) * math.sin(theta) 
     31    theta = 0.5 * math.atan(plane_dist / det_dist) 
     32    return (4.0 * math.pi / wavelength) * math.sin(theta) 
    3433 
    3534 
     
    4544            angle_xy = math.pi 
    4645    else: 
    47         angle_xy = math.atan(dx/dy) 
    48          
     46        angle_xy = math.atan(dx / dy) 
     47 
    4948    if compo == "x": 
    5049        out = get_q(dx, dy, det_dist, wavelength) * math.cos(angle_xy) 
     
    5958    """ 
    6059    Correct phi to within the 0 <= to <= 2pi range 
    61      
     60 
    6261    :return: phi in >=0 and <=2Pi 
    6362    """ 
     
    7675    convert old 2d format opened by IhorReader or danse_reader 
    7776    to new Data2D format 
    78      
     77 
    7978    :param data2d: 2d array of Data2D object 
    80      
    8179    :return: 1d arrays of Data2D object 
    82      
     80 
    8381    """ 
    8482    if data2d.data == None or data2d.x_bins == None or data2d.y_bins == None: 
    8583        raise ValueError, "Can't convert this data: data=None..." 
    86      
    87     from sas.dataloader.data_info import Data2D 
    88  
    8984    new_x = numpy.tile(data2d.x_bins, (len(data2d.y_bins), 1)) 
    9085    new_y = numpy.tile(data2d.y_bins, (len(data2d.x_bins), 1)) 
     
    9489    qx_data = new_x.flatten() 
    9590    qy_data = new_y.flatten() 
    96     q_data = numpy.sqrt(qx_data*qx_data + qy_data*qy_data) 
     91    q_data = numpy.sqrt(qx_data * qx_data + qy_data * qy_data) 
    9792    if data2d.err_data == None or numpy.any(data2d.err_data <= 0): 
    9893        new_err_data = numpy.sqrt(numpy.abs(new_data)) 
     
    10297 
    10398    #TODO: make sense of the following two lines... 
    104     output = Data2D() 
     99    #from sas.dataloader.data_info import Data2D 
     100    #output = Data2D() 
    105101    output = data2d 
    106102    output.data = new_data 
     
    133129        # negative q-values are allowed 
    134130        self.fold = False 
    135          
     131 
    136132    def __call__(self, data2D): 
    137133        return NotImplemented 
    138          
     134 
    139135    def _avg(self, data2D, maj): 
    140136        """ 
     
    142138        The major axis is defined as the axis of Q_maj. 
    143139        The minor axis is the axis that we average over. 
    144           
     140 
    145141        :param data2D: Data2D object 
    146142        :param maj_min: min value on the major axis 
    147          
    148143        :return: Data1D object 
    149144        """ 
     
    152147            msg += " detectors: %g" % len(data2D.detector) 
    153148            raise RuntimeError, msg 
    154          
     149 
    155150        # Get data 
    156151        data = data2D.data[numpy.isfinite(data2D.data)] 
    157         q_data = data2D.q_data[numpy.isfinite(data2D.data)] 
    158152        err_data = data2D.err_data[numpy.isfinite(data2D.data)] 
    159153        qx_data = data2D.qx_data[numpy.isfinite(data2D.data)] 
    160154        qy_data = data2D.qy_data[numpy.isfinite(data2D.data)] 
    161               
     155 
    162156        # Build array of Q intervals 
    163157        if maj == 'x': 
     
    167161                x_min = self.x_min 
    168162            nbins = int(math.ceil((self.x_max - x_min) / self.bin_width)) 
    169             qbins = self.bin_width * numpy.arange(nbins) + x_min 
    170163        elif maj == 'y': 
    171164            if self.fold: 
     
    173166            else: 
    174167                y_min = self.y_min 
    175             nbins = int(math.ceil((self.y_max - y_min)/self.bin_width)) 
    176             qbins = self.bin_width * numpy.arange(nbins) + y_min 
     168            nbins = int(math.ceil((self.y_max - y_min) / self.bin_width)) 
    177169        else: 
    178170            raise RuntimeError, "_Slab._avg: unrecognized axis %s" % str(maj) 
    179                                  
     171 
    180172        x = numpy.zeros(nbins) 
    181173        y = numpy.zeros(nbins) 
     
    194186                frac_y = 1 
    195187            frac = frac_x * frac_y 
    196              
     188 
    197189            if frac == 0: 
    198190                continue 
     
    200192            if maj == 'x': 
    201193                q_value = qx_data[npts] 
    202                 min = x_min 
     194                min_value = x_min 
    203195            if maj == 'y': 
    204196                q_value = qy_data[npts] 
    205                 min = y_min  
     197                min_value = y_min 
    206198            if self.fold and q_value < 0: 
    207199                q_value = -q_value 
    208200            # bin 
    209             i_q = int(math.ceil((q_value - min) / self.bin_width)) - 1 
    210              
     201            i_q = int(math.ceil((q_value - min_value) / self.bin_width)) - 1 
     202 
    211203            # skip outside of max bins 
    212204            if i_q < 0 or i_q >= nbins: 
    213205                continue 
    214              
     206 
    215207            #TODO: find better definition of x[i_q] based on q_data 
    216             x[i_q] += frac * q_value  # min + (i_q + 1) * self.bin_width / 2.0 
     208            x[i_q] += frac * q_value  # min_value + (i_q + 1) * self.bin_width / 2.0 
    217209            y[i_q] += frac * data[npts] 
    218              
     210 
    219211            if err_data == None or err_data[npts] == 0.0: 
    220212                if data[npts] < 0: 
     
    224216                err_y[i_q] += frac * frac * err_data[npts] * err_data[npts] 
    225217            y_counts[i_q] += frac 
    226                  
     218 
    227219        # Average the sums 
    228220        for n in range(nbins): 
    229221            err_y[n] = math.sqrt(err_y[n]) 
    230            
     222 
    231223        err_y = err_y / y_counts 
    232224        y = y / y_counts 
    233225        x = x / y_counts 
    234226        idx = (numpy.isfinite(y) & numpy.isfinite(x)) 
    235          
    236         if not idx.any():  
     227 
     228        if not idx.any(): 
    237229            msg = "Average Error: No points inside ROI to average..." 
    238230            raise ValueError, msg 
    239         #elif len(y[idx])!= nbins: 
    240         #    msg = "empty bin(s) due to tight binning..." 
    241         #    print "resulted",nbins- len(y[idx]), msg 
    242231        return Data1D(x=x[idx], y=y[idx], dy=err_y[idx]) 
    243          
    244          
     232 
     233 
    245234class SlabY(_Slab): 
    246235    """ 
     
    250239        """ 
    251240        Compute average I(Qy) for a region of interest 
    252           
    253         :param data2D: Data2D object 
    254          
     241 
     242        :param data2D: Data2D object 
    255243        :return: Data1D object 
    256244        """ 
    257245        return self._avg(data2D, 'y') 
    258          
    259          
     246 
     247 
    260248class SlabX(_Slab): 
    261249    """ 
     
    265253        """ 
    266254        Compute average I(Qx) for a region of interest 
    267           
    268         :param data2D: Data2D object 
    269          
     255        :param data2D: Data2D object 
    270256        :return: Data1D object 
    271          
    272257        """ 
    273258        return self._avg(data2D, 'x') 
     
    291276        """ 
    292277        Perform the sum in the region of interest 
    293           
    294         :param data2D: Data2D object 
    295          
     278 
     279        :param data2D: Data2D object 
    296280        :return: number of counts, error on number of counts, 
    297281            number of points summed 
    298          
    299282        """ 
    300283        y, err_y, y_counts = self._sum(data2D) 
    301          
     284 
    302285        # Average the sums 
    303286        counts = 0 if y_counts == 0 else y 
    304287        error = 0 if y_counts == 0 else math.sqrt(err_y) 
    305          
     288 
    306289        # Added y_counts to return, SMK & PDB, 04/03/2013 
    307290        return counts, error, y_counts 
    308          
     291 
    309292    def _sum(self, data2D): 
    310293        """ 
    311294        Perform the sum in the region of interest 
    312          
    313         :param data2D: Data2D object 
    314          
     295 
     296        :param data2D: Data2D object 
    315297        :return: number of counts, 
    316298            error on number of counts, number of entries summed 
    317          
    318299        """ 
    319300        if len(data2D.detector) != 1: 
     
    323304        # Get data 
    324305        data = data2D.data[numpy.isfinite(data2D.data)] 
    325         q_data = data2D.q_data[numpy.isfinite(data2D.data)] 
    326306        err_data = data2D.err_data[numpy.isfinite(data2D.data)] 
    327307        qx_data = data2D.qx_data[numpy.isfinite(data2D.data)] 
    328308        qy_data = data2D.qy_data[numpy.isfinite(data2D.data)] 
    329     
     309 
    330310        y = 0.0 
    331311        err_y = 0.0 
     
    337317            frac_x = 0 
    338318            frac_y = 0 
    339              
     319 
    340320            # get min and max at each points 
    341321            qx = qx_data[npts] 
    342322            qy = qy_data[npts] 
    343              
     323 
    344324            # get the ROI 
    345325            if self.x_min <= qx and self.x_max > qx: 
     
    368348    def __init__(self, x_min=0.0, x_max=0.0, y_min=0.0, y_max=0.0): 
    369349        super(Boxavg, self).__init__(x_min=x_min, x_max=x_max, 
    370                                       y_min=y_min, y_max=y_max) 
     350                                     y_min=y_min, y_max=y_max) 
    371351 
    372352    def __call__(self, data2D): 
    373353        """ 
    374354        Perform the sum in the region of interest 
    375           
    376         :param data2D: Data2D object 
    377          
     355 
     356        :param data2D: Data2D object 
    378357        :return: average counts, error on average counts 
    379          
     358 
    380359        """ 
    381360        y, err_y, y_counts = self._sum(data2D) 
    382          
     361 
    383362        # Average the sums 
    384363        counts = 0 if y_counts == 0 else y / y_counts 
    385364        error = 0 if y_counts == 0 else math.sqrt(err_y) / y_counts 
    386          
     365 
    387366        return counts, error 
    388          
    389          
     367 
     368 
    390369def get_pixel_fraction_square(x, xmin, xmax): 
    391370    """ 
    392371    Return the fraction of the length 
    393372    from xmin to x.:: 
    394     
    395       
     373 
    396374           A            B 
    397375       +-----------+---------+ 
    398376       xmin        x         xmax 
    399       
     377 
    400378    :param x: x-value 
    401379    :param xmin: minimum x for the length considered 
    402380    :param xmax: minimum x for the length considered 
    403      
    404381    :return: (x-xmin)/(xmax-xmin) when xmin < x < xmax 
    405      
     382 
    406383    """ 
    407384    if x <= xmin: 
     
    416393    """ 
    417394    Perform circular averaging on 2D data 
    418      
     395 
    419396    The data returned is the distribution of counts 
    420397    as a function of Q 
     
    431408        """ 
    432409        Perform circular averaging on the data 
    433          
    434         :param data2D: Data2D object 
    435          
     410 
     411        :param data2D: Data2D object 
    436412        :return: Data1D object 
    437413        """ 
     
    439415        data = data2D.data[numpy.isfinite(data2D.data)] 
    440416        q_data = data2D.q_data[numpy.isfinite(data2D.data)] 
    441         qx_data = data2D.qx_data[numpy.isfinite(data2D.data)] 
    442417        err_data = data2D.err_data[numpy.isfinite(data2D.data)] 
    443418        mask_data = data2D.mask[numpy.isfinite(data2D.data)] 
    444          
     419 
    445420        dq_data = None 
    446          
     421 
    447422        # Get the dq for resolution averaging 
    448423        if data2D.dqx_data != None and data2D.dqy_data != None: 
     
    484459            dq_data = numpy.add(dqx, dqy) 
    485460            dq_data = numpy.sqrt(dq_data) 
    486              
     461 
    487462        #q_data_max = numpy.max(q_data) 
    488463        if len(data2D.q_data) == None: 
     
    492467        # Build array of Q intervals 
    493468        nbins = int(math.ceil((self.r_max - self.r_min) / self.bin_width)) 
    494         qbins = self.bin_width * numpy.arange(nbins) + self.r_min 
    495469 
    496470        x = numpy.zeros(nbins) 
     
    501475 
    502476        for npt in range(len(data)): 
    503              
     477 
    504478            if ismask and not mask_data[npt]: 
    505479                continue 
    506              
     480 
    507481            frac = 0 
    508              
     482 
    509483            # q-value at the pixel (j,i) 
    510484            q_value = q_data[npt] 
    511485            data_n = data[npt] 
    512              
     486 
    513487            ## No need to calculate the frac when all data are within range 
    514488            if self.r_min >= self.r_max: 
    515489                raise ValueError, "Limit Error: min > max" 
    516              
     490 
    517491            if self.r_min <= q_value and q_value <= self.r_max: 
    518492                frac = 1 
    519493            if frac == 0: 
    520                 continue  
     494                continue 
    521495            i_q = int(math.floor((q_value - self.r_min) / self.bin_width)) 
    522496 
     
    542516                err_x = None 
    543517            y_counts[i_q] += frac 
    544          
     518 
    545519        # Average the sums 
    546520        for n in range(nbins): 
     
    550524            #if err_x != None: 
    551525            #    err_x[n] = math.sqrt(err_x[n]) 
    552              
     526 
    553527        err_y = err_y / y_counts 
    554528        err_y[err_y == 0] = numpy.average(err_y) 
     
    556530        x = x / y_counts 
    557531        idx = (numpy.isfinite(y)) & (numpy.isfinite(x)) 
    558          
     532 
    559533        if err_x != None: 
    560534            d_x = err_x[idx] / y_counts[idx] 
     
    565539            msg = "Average Error: No points inside ROI to average..." 
    566540            raise ValueError, msg 
    567          
     541 
    568542        return Data1D(x=x[idx], y=y[idx], dy=err_y[idx], dx=d_x) 
    569      
     543 
    570544 
    571545class Ring(object): 
     
    574548    The ring is defined by r_min, r_max, and 
    575549    the position of the center of the ring. 
    576      
     550 
    577551    The data returned is the distribution of counts 
    578552    around the ring as a function of phi. 
    579      
     553 
    580554    Phi_min and phi_max should be defined between 0 and 2*pi 
    581555    in anti-clockwise starting from the x- axis on the left-hand side 
     
    594568        self.nbins_phi = nbins 
    595569 
    596          
     570 
    597571    def __call__(self, data2D): 
    598572        """ 
     
    606580        if data2D.__class__.__name__ not in ["Data2D", "plottable_2D"]: 
    607581            raise RuntimeError, "Ring averaging only take plottable_2D objects" 
    608          
     582 
    609583        Pi = math.pi 
    610   
     584 
    611585        # Get data 
    612586        data = data2D.data[numpy.isfinite(data2D.data)] 
     
    615589        qx_data = data2D.qx_data[numpy.isfinite(data2D.data)] 
    616590        qy_data = data2D.qy_data[numpy.isfinite(data2D.data)] 
    617          
    618         q_data_max = numpy.max(q_data) 
    619          
     591 
    620592        # Set space for 1d outputs 
    621         phi_bins   = numpy.zeros(self.nbins_phi) 
     593        phi_bins = numpy.zeros(self.nbins_phi) 
    622594        phi_counts = numpy.zeros(self.nbins_phi) 
    623595        phi_values = numpy.zeros(self.nbins_phi) 
    624         phi_err    = numpy.zeros(self.nbins_phi) 
    625      
     596        phi_err = numpy.zeros(self.nbins_phi) 
     597 
    626598        # Shift to apply to calculated phi values in order to center first bin at zero 
    627599        phi_shift = Pi / self.nbins_phi 
     
    632604            q_value = q_data[npt] 
    633605            data_n = data[npt] 
    634                          
     606 
    635607            # phi-value at the point (npt) 
    636608            phi_value = math.atan2(qy_data[npt], qx_data[npt]) + Pi 
    637              
     609 
    638610            if self.r_min <= q_value and q_value <= self.r_max: 
    639611                frac = 1 
     
    641613                continue 
    642614            # binning            
    643             i_phi = int(math.floor((self.nbins_phi) * (phi_value+phi_shift) / (2 * Pi))) 
    644              
     615            i_phi = int(math.floor((self.nbins_phi) * (phi_value + phi_shift) / (2 * Pi))) 
     616 
    645617            # Take care of the edge case at phi = 2pi. 
    646618            if i_phi >= self.nbins_phi: 
    647                 i_phi =  0 
     619                i_phi = 0 
    648620            phi_bins[i_phi] += frac * data[npt] 
    649              
     621 
    650622            if err_data == None or err_data[npt] == 0.0: 
    651623                if data_n < 0: 
     
    655627                phi_err[i_phi] += frac * frac * err_data[npt] * err_data[npt] 
    656628            phi_counts[i_phi] += frac 
    657                            
     629 
    658630        for i in range(self.nbins_phi): 
    659631            phi_bins[i] = phi_bins[i] / phi_counts[i] 
    660632            phi_err[i] = math.sqrt(phi_err[i]) / phi_counts[i] 
    661633            phi_values[i] = 2.0 * math.pi / self.nbins_phi * (1.0 * i) 
    662              
     634 
    663635        idx = (numpy.isfinite(phi_bins)) 
    664636 
     
    670642        #,"empty bin(s) due to tight binning..." 
    671643        return Data1D(x=phi_values[idx], y=phi_bins[idx], dy=phi_err[idx]) 
    672      
    673      
     644 
     645 
    674646def get_pixel_fraction(qmax, q_00, q_01, q_10, q_11): 
    675647    """ 
     
    693665    # y side for x = maxx 
    694666    x_1 = get_intercept(qmax, q_10, q_11) 
    695      
     667 
    696668    # x side for y = miny 
    697669    y_0 = get_intercept(qmax, q_00, q_10) 
    698670    # x side for y = maxy 
    699671    y_1 = get_intercept(qmax, q_01, q_11) 
    700      
     672 
    701673    # surface fraction for a 1x1 pixel 
    702674    frac_max = 0 
    703      
     675 
    704676    if x_0 and x_1: 
    705677        frac_max = (x_0 + x_1) / 2.0 
     
    726698        else: 
    727699            frac_max = (1.0 - x_1) * (1.0 - y_1) / 2.0 
    728              
     700 
    729701    # If we make it here, there is no intercept between 
    730702    # this pixel and the constant-q ring. We only need 
    731703    # to know if we have to include it or exclude it. 
    732     elif (q_00 + q_01 + q_10 + q_11) / 4.0 <  qmax: 
     704    elif (q_00 + q_01 + q_10 + q_11) / 4.0 < qmax: 
    733705        frac_max = 1.0 
    734706 
    735707    return frac_max 
    736               
    737               
     708 
     709 
    738710def get_intercept(q, q_0, q_1): 
    739711    """ 
     
    760732            return (q - q_1) / (q_0 - q_1) 
    761733    return None 
    762       
    763       
     734 
     735 
    764736class _Sector: 
    765737    """ 
     
    774746    starting from the x- axis on the left-hand side 
    775747    """ 
    776     def __init__(self, r_min, r_max, phi_min=0, phi_max=2*math.pi, nbins=20): 
     748    def __init__(self, r_min, r_max, phi_min=0, phi_max=2 * math.pi, nbins=20): 
    777749        self.r_min = r_min 
    778750        self.r_max = r_max 
     
    780752        self.phi_max = phi_max 
    781753        self.nbins = nbins 
    782          
     754 
    783755    def _agv(self, data2D, run='phi'): 
    784756        """ 
     
    801773        qy_data = data2D.qy_data[numpy.isfinite(data2D.data)] 
    802774        dq_data = None 
    803              
     775 
    804776        # Get the dq for resolution averaging 
    805777        if data2D.dqx_data != None and data2D.dqy_data != None: 
     
    840812            dq_data = numpy.add(dqx, dqy) 
    841813            dq_data = numpy.sqrt(dq_data) 
    842              
     814 
    843815        #set space for 1d outputs 
    844         x        = numpy.zeros(self.nbins) 
    845         y        = numpy.zeros(self.nbins) 
    846         y_err    = numpy.zeros(self.nbins) 
    847         x_err    = numpy.zeros(self.nbins) 
     816        x = numpy.zeros(self.nbins) 
     817        y = numpy.zeros(self.nbins) 
     818        y_err = numpy.zeros(self.nbins) 
     819        x_err = numpy.zeros(self.nbins) 
    848820        y_counts = numpy.zeros(self.nbins) 
    849                        
     821 
    850822        # Get the min and max into the region: 0 <= phi < 2Pi 
    851823        phi_min = flip_phi(self.phi_min) 
    852824        phi_max = flip_phi(self.phi_max) 
    853          
    854         q_data_max = numpy.max(q_data) 
    855                        
     825 
    856826        for n in range(len(data)): 
    857827            frac = 0 
    858              
     828 
    859829            # q-value at the pixel (j,i) 
    860830            q_value = q_data[n] 
    861831            data_n = data[n] 
    862              
     832 
    863833            # Is pixel within range? 
    864834            is_in = False 
    865              
     835 
    866836            # phi-value of the pixel (j,i) 
    867837            phi_value = math.atan2(qy_data[n], qx_data[n]) + Pi 
    868              
     838 
    869839            ## No need to calculate the frac when all data are within range 
    870840            if self.r_min <= q_value and q_value <= self.r_max: 
     
    894864                is_in = is_in or (phi_value >= phi_min  and \ 
    895865                                    phi_value < phi_max) 
    896              
     866 
    897867            if not is_in: 
    898868                frac = 0 
     
    912882            if i_bin == self.nbins: 
    913883                i_bin = self.nbins - 1 
    914                  
     884 
    915885            ## Get the total y 
    916886            y[i_bin] += frac * data_n 
     
    922892            else: 
    923893                y_err[i_bin] += frac * frac * err_data[n] * err_data[n] 
    924                  
     894 
    925895            if dq_data != None: 
    926896                # To be consistent with dq calculation in 1d reduction, 
     
    932902                x_err = None 
    933903            y_counts[i_bin] += frac 
    934     
     904 
    935905        # Organize the results 
    936906        for i in range(self.nbins): 
     
    964934        #"empty bin(s) due to tight binning..." 
    965935        return Data1D(x=x[idx], y=y[idx], dy=y_err[idx], dx=d_x) 
    966                  
    967                  
     936 
     937 
    968938class SectorPhi(_Sector): 
    969939    """ 
     
    982952        """ 
    983953        return self._agv(data2D, 'phi') 
    984      
    985      
     954 
     955 
    986956class SectorQ(_Sector): 
    987957    """ 
     
    10401010        qx_data = data2D.qx_data 
    10411011        qy_data = data2D.qy_data 
    1042         mask = data2D.mask 
    10431012        q_data = numpy.sqrt(qx_data * qx_data + qy_data * qy_data) 
    10441013 
     
    10471016 
    10481017        return (out) 
    1049          
     1018 
    10501019 
    10511020class Boxcut(object): 
     
    10721041        """ 
    10731042        mask = self._find(data2D) 
    1074          
     1043 
    10751044        return mask 
    1076          
     1045 
    10771046    def _find(self, data2D): 
    10781047        """ 
     
    10891058        qx_data = data2D.qx_data 
    10901059        qy_data = data2D.qy_data 
    1091         mask = data2D.mask 
    1092          
     1060 
    10931061        # check whether or not the data point is inside ROI 
    10941062        outx = (self.x_min <= qx_data) & (self.x_max > qx_data) 
     
    11111079        self.phi_min = phi_min 
    11121080        self.phi_max = phi_max 
    1113                
     1081 
    11141082    def __call__(self, data2D): 
    11151083        """ 
     
    11231091        """ 
    11241092        mask = self._find(data2D) 
    1125          
     1093 
    11261094        return mask 
    1127          
     1095 
    11281096    def _find(self, data2D): 
    11291097        """ 
     
    11421110        qx_data = data2D.qx_data 
    11431111        qy_data = data2D.qy_data 
    1144         phi_data = numpy.zeros(len(qx_data)) 
    11451112 
    11461113        # get phi from data 
    11471114        phi_data = numpy.arctan2(qy_data, qx_data) 
    1148          
     1115 
    11491116        # Get the min and max into the region: -pi <= phi < Pi 
    11501117        phi_min_major = flip_phi(self.phi_min + Pi) - Pi 
     
    11551122        else: 
    11561123            out_major = (phi_min_major <= phi_data) & (phi_max_major > phi_data) 
    1157            
     1124 
    11581125        # minor sector 
    11591126        # Get the min and max into the region: -pi <= phi < Pi 
    11601127        phi_min_minor = flip_phi(self.phi_min) - Pi 
    11611128        phi_max_minor = flip_phi(self.phi_max) - Pi 
    1162                
     1129 
    11631130        # check for minor sector 
    11641131        if phi_min_minor > phi_max_minor: 
     
    11691136                            (phi_max_minor >= phi_data) 
    11701137        out = out_major + out_minor 
    1171          
     1138 
    11721139        return out 
Note: See TracChangeset for help on using the changeset viewer.