Changes in / [694c6d0:7050455] in sasmodels


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/sesans.py

    rb297ba9 rda33725  
    1515from numpy import pi  # type: ignore 
    1616from scipy.special import j0 
     17 
    1718 
    1819class SesansTransform(object): 
     
    3839 
    3940    # transform arrays 
    40     _H = None  # type: np.ndarray 
    41     _H0 = None # type: np.ndarray 
     41    _H = None   # type: np.ndarray 
     42    _H0 = None  # type: np.ndarray 
    4243 
    43     def __init__(self, z, SElength, lam, zaccept, Rmax): 
     44    def __init__(self, z, SElength, lam, zaccept, Rmax, log_spacing=1.0003): 
    4445        # type: (np.ndarray, float, float) -> None 
    45         #import logging; logging.info("creating SESANS transform") 
    4646        self.q = z 
     47        self.log_spacing = log_spacing 
    4748        self._set_hankel(SElength, lam, zaccept, Rmax) 
    4849 
     
    5960    def _set_hankel(self, SElength, lam, zaccept, Rmax): 
    6061        # type: (np.ndarray, float, float) -> None 
    61         # Force float32 arrays, otherwise run into memory problems on some machines 
    62         SElength = np.asarray(SElength, dtype='float32') 
    63  
    64         #Rmax = #value in text box somewhere in FitPage? 
     62        SElength = np.asarray(SElength) 
    6563        q_max = 2*pi / (SElength[1] - SElength[0]) 
    6664        q_min = 0.1 * 2*pi / (np.size(SElength) * SElength[-1]) 
    67         q = np.arange(q_min, q_max, q_min, dtype='float32') 
    68         dq = q_min 
     65        q = np.exp(np.arange(np.log(q_min), np.log(q_max), 
     66                             np.log(self.log_spacing))) 
    6967 
    70         H0 = np.float32(dq/(2*pi)) * q 
     68        dq = np.diff(q) 
     69        dq = np.insert(dq, 0, dq[0]) 
    7170 
    72         repq = np.tile(q, (SElength.size, 1)).T 
    73         repSE = np.tile(SElength, (q.size, 1)) 
    74         H = np.float32(dq/(2*pi)) * j0(repSE*repq) * repq 
     71        H0 = dq/(2*pi) * q 
    7572 
    76         replam = np.tile(lam, (q.size, 1)) 
    77         reptheta = np.arcsin(repq*replam/2*np.pi) 
     73        H = np.outer(q, SElength) 
     74        j0(H, out=H) 
     75        H *= (dq * q / (2*pi)).reshape((-1, 1)) 
     76 
     77        reptheta = np.outer(q, lam/(2*pi)) 
     78        np.arcsin(reptheta, out=reptheta) 
    7879        mask = reptheta > zaccept 
    7980        H[mask] = 0 
Note: See TracChangeset for help on using the changeset viewer.