Changeset 400155b in sasview for src/sas/dataloader


Ignore:
Timestamp:
Feb 17, 2015 8:20:48 AM (10 years ago)
Author:
gonzalezm
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:
66f21cd
Parents:
7eaf9f2
Message:

Implementing request from ticket 261 - default number of bins in Annulus [Phi View] is now 36 and the first bin is now centered at 0 degrees

File:
1 edited

Legend:

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

    r79492222 r400155b  
    582582    """ 
    583583    #Todo: remove center. 
    584     def __init__(self, r_min=0, r_max=0, center_x=0, center_y=0, nbins=20): 
     584    def __init__(self, r_min=0, r_max=0, center_x=0, center_y=0, nbins=36): 
    585585        # Minimum radius 
    586586        self.r_min = r_min 
     
    593593        # Number of angular bins 
    594594        self.nbins_phi = nbins 
     595 
    595596         
    596597    def __call__(self, data2D): 
     
    622623        phi_values = numpy.zeros(self.nbins_phi) 
    623624        phi_err    = numpy.zeros(self.nbins_phi) 
    624          
     625         
     626        # Shift to apply to calculated phi values in order to center first bin at zero 
     627        phi_shift = Pi / self.nbins_phi 
     628 
    625629        for npt in range(len(data)): 
    626630            frac = 0 
     
    637641                continue 
    638642            # binning            
    639             i_phi = int(math.floor((self.nbins_phi) * phi_value / (2 * Pi))) 
     643            i_phi = int(math.floor((self.nbins_phi) * (phi_value+phi_shift) / (2 * Pi))) 
    640644             
    641645            # Take care of the edge case at phi = 2pi. 
    642             if i_phi == self.nbins_phi: 
    643                 i_phi =  self.nbins_phi - 1 
     646            if i_phi >= self.nbins_phi: 
     647                i_phi =  0 
    644648            phi_bins[i_phi] += frac * data[npt] 
    645649             
     
    655659            phi_bins[i] = phi_bins[i] / phi_counts[i] 
    656660            phi_err[i] = math.sqrt(phi_err[i]) / phi_counts[i] 
    657             phi_values[i] = 2.0 * math.pi / self.nbins_phi * (1.0 * i + 0.5) 
     661            phi_values[i] = 2.0 * math.pi / self.nbins_phi * (1.0 * i) 
    658662             
    659663        idx = (numpy.isfinite(phi_bins)) 
Note: See TracChangeset for help on using the changeset viewer.