Changeset 0b127025 in sasview for sanscalculator


Ignore:
Timestamp:
Aug 16, 2011 6:50:56 PM (13 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:
aaeae3a0
Parents:
d66196a
Message:

for tof rectangular lamda distribution used

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sanscalculator/src/sans/calculator/resolution_calculator.py

    rbcfc969 r0b127025  
    3939        # resolutions 
    4040        # lamda in r-direction 
    41         self.sigma_lamda = 0 
     41        self.sigma_lamd = 0 
    4242        # x-dir (no lamda) 
    4343        self.sigma_1 = 0 
     
    6161        self.qymin_limit = 0 
    6262        self.qymax_limit = 0 
    63         # set sigmas 
    64         self.sigma_1 = 0 
    65         self.sigma_lamd = 0 
    66         self.sigma_2 = 0 
    67         self.sigma_1d = 0 
     63 
    6864        # plots 
    6965        self.plot = None 
     
    114110            intens = self.setup_tof(lam, dlam) 
    115111            intens_list.append(intens) 
    116             # save q min max 
    117             #qx_min = 0 
    118             #qx_max = 0 
    119             #qy_min = 0 
    120             #qy_max = 0 
     112            # cehck if tof 
     113            if num_lamda > 1: 
     114                tof = True 
     115            else: 
     116                tof = False 
    121117            # compute 2d resolution 
    122118            _, _, sigma_1, sigma_2, sigma_r, sigma1d = \ 
    123                             self.compute(lam, dlam, qx_value, qy_value, coord) 
     119                        self.compute(lam, dlam, qx_value, qy_value, coord, tof) 
    124120            # make image 
    125121            image = self.get_image(qx_value, qy_value, sigma_1, sigma_2,  
     
    222218         
    223219    def compute(self, wavelength, wavelength_spread, qx_value, qy_value,  
    224                 coord = 'cartesian'): 
     220                coord = 'cartesian', tof=False): 
    225221        """ 
    226222        Compute the Q resoltuion in || and + direction of 2D 
     
    231227        lamb = wavelength 
    232228        lamb_spread = wavelength_spread 
    233          
     229        # the shape of wavelength distribution 
     230        if tof: 
     231            # rectangular 
     232            tof_factor =  2 
     233        else: 
     234            # triangular 
     235            tof_factor =  1 
    234236        # Find polar values 
    235237        qr_value, phi = self._get_polar_value(qx_value, qy_value) 
     
    288290                                          phi, 'radial', 'on') 
    289291        # for 1d 
    290         variance_1d_1 = sigma_1/2 + sigma_wave_1 
     292        variance_1d_1 = sigma_1/2 + sigma_wave_1 / tof_factor 
    291293        # normalize 
    292294        variance_1d_1 = knot * knot * variance_1d_1 / 12 
     
    296298        # normalize 
    297299        sigma_1 = knot*sqrt(sigma_1 / 12) 
    298         sigma_r = knot*sqrt(sigma_wave_1 / 12) 
     300        sigma_r = knot*sqrt(sigma_wave_1 / (tof_factor *12)) 
    299301        # sigma in the phi/y direction 
    300302        # for source apperture 
     
    317319                                          phi, 'phi', 'on')  
    318320        # for 1d 
    319         variance_1d_2 = sigma_2/2 +sigma_wave_2 
     321        variance_1d_2 = sigma_2 / 2 + sigma_wave_2 / tof_factor 
    320322        # normalize 
    321323        variance_1d_2 = knot*knot*variance_1d_2 / 12 
     
    878880        phi_i = numpy.arctan2(y_val, x_val) 
    879881 
     882        phi_i = numpy.arctan2(y_val, x_val) 
    880883        sin_phi = numpy.sin(phi_i) 
    881884        cos_phi = numpy.cos(phi_i) 
     
    11101113        plane_dist = dx_size 
    11111114        # full scattering angle on the x-axis 
    1112         theta  = math.atan(plane_dist / det_dist) 
    1113         qx_value     = (2.0 * pi / wavelength) * math.sin(theta) 
     1115        theta  = numpy.arctan(plane_dist / det_dist) 
     1116        qx_value     = (2.0 * pi / wavelength) * numpy.sin(theta) 
    11141117        return qx_value   
    11151118     
     
    11621165        delta_y = 0.5 
    11631166        delta_y *= _GRAVITY 
    1164         delta_y *= self.sample2detector_distance[0]  
     1167        sampletodetector = self.sample2detector_distance[0] - \ 
     1168                                    self.sample2sample_distance[0] 
     1169        delta_y *= sampletodetector 
    11651170        delta_y *= (self.source2sample_distance[0] + self.sample2detector_distance[0]) 
    11661171        delta_y /= (velocity * velocity) 
Note: See TracChangeset for help on using the changeset viewer.