Changes in sasmodels/sesans.py [3c56da87:384d114] in sasmodels


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/sesans.py

    r3c56da87 r384d114  
    1212import numpy as np 
    1313from numpy import pi, exp 
    14  
    1514from scipy.special import jv as besselj 
    1615 
    17 def make_q(q_zmax, Rmax): 
     16def make_q(q_max, Rmax): 
     17    r""" 
     18    Return a $q$ vector suitable for SESANS covering from $2\pi/ (10 R_{\max})$ 
     19    to $q_max$. 
     20    """ 
    1821    q_min = dq = 0.1 * 2*pi / Rmax 
    19     #q_min = 0.00003 
    20     return np.arange(q_min, q_zmax, dq) 
    21  
    22 # TODO: dead code; for now the call to the hankel transform happens in BumpsModel 
    23 class SesansCalculator: 
    24     def __init__(self, kernel, q_zmax, Rmax, SElength, wavelength, thickness): 
    25         self._set_kernel(kernel, q_zmax, Rmax) 
    26         self.SElength = SElength 
    27         self.wavelength = wavelength 
    28         self.thickness = thickness 
    29  
    30     def _set_kernel(self, kernel, q_zmax, Rmax): 
    31         kernel_input = kernel.make_input([make_q(q_zmax, Rmax)]) 
    32         self.sans_calculator = kernel(kernel_input) 
    33  
    34     def __call__(self, pars, pd_pars, cutoff=1e-5): 
    35         Iq = self.sans_calculator(pars, pd_pars, cutoff) 
    36         P = hankel(self.SElength, self.wavelength, self.thickness, self.q, Iq) 
    37         self.Iq = Iq 
    38         return P 
     22    return np.arange(q_min, q_max, dq) 
    3923 
    4024def hankel(SElength, wavelength, thickness, q, Iq): 
    41     """ 
     25    r""" 
    4226    Compute the expected SESANS polarization for a given SANS pattern. 
    4327 
    44     Uses the hankel transform followed by the exponential.  The values 
    45     for zz (or spin echo length, or delta), wavelength and sample thickness 
    46     information should come from the dataset.  *q* should be chosen such 
    47     that the oscillations in *I(q)* are well sampled (e.g., 5*2*pi/d_max). 
     28    Uses the hankel transform followed by the exponential.  The values for *zz* 
     29    (or spin echo length, or delta), wavelength and sample thickness should 
     30    come from the dataset.  $q$ should be chosen such that the oscillations 
     31    in $I(q)$ are well sampled (e.g., $5 \cdot 2 \pi/d_{\max}$). 
    4832 
    49     *SElength* [A] is the set of z points at which to compute the hankel transform 
     33    *SElength* [A] is the set of $z$ points at which to compute the 
     34    Hankel transform 
    5035 
    5136    *wavelength* [m]  is the wavelength of each individual point *zz* 
     
    5338    *thickness* [cm] is the sample thickness. 
    5439 
    55     *q* [A^{-1}] is the set of q points at which the model has been computed. 
    56     These should be equally spaced. 
     40    *q* [A$^{-1}$] is the set of $q$ points at which the model has been 
     41    computed. These should be equally spaced. 
    5742 
    58     *I* [cm^{-1}] is the value of the SANS model at *q* 
     43    *I* [cm$^{-1}$] is the value of the SANS model at *q* 
    5944    """ 
    6045    G = np.zeros(len(SElength), 'd') 
    6146    for i in range(len(SElength)): 
    62         integr = besselj(0,q*SElength[i])*Iq*q 
     47        integr = besselj(0, q*SElength[i])*Iq*q 
    6348        G[i] = np.sum(integr) 
    64     dq=(q[1]-q[0])*1e10   # [m^-1] step size in q, needed for integration 
    65     G *= dq*1e10*2*pi # integr step, conver q into [m**-1] and 2 pi circle integr 
     49 
     50    # [m^-1] step size in q, needed for integration 
     51    dq=(q[1]-q[0])*1e10 
     52 
     53    # integration step, convert q into [m**-1] and 2 pi circle integration 
     54    G *= dq*1e10*2*pi 
     55 
    6656    P = exp(thickness*wavelength**2/(4*pi**2)*(G-G[0])) 
    6757 
Note: See TracChangeset for help on using the changeset viewer.