Changes in / [1aa7990:4050e6a] in sasmodels


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/resolution.py

    rb32caab rb397165  
    1717 
    1818MINIMUM_RESOLUTION = 1e-8 
    19 MINIMUM_ABSOLUTE_Q = 0.02  # relative to the minimum q in the data 
     19 
     20 
     21# When extrapolating to -q, what is the minimum positive q relative to q_min 
     22# that we wish to calculate? 
     23MIN_Q_SCALE_FOR_NEGATIVE_Q_EXTRAPOLATION = 0.01 
    2024 
    2125class Resolution(object): 
     
    7882        self.q_calc = (pinhole_extend_q(q, q_width, nsigma=nsigma) 
    7983                       if q_calc is None else np.sort(q_calc)) 
    80  
    81         # Protect against models which are not defined for very low q.  Limit 
    82         # the smallest q value evaluated (in absolute) to 0.02*min 
    83         cutoff = MINIMUM_ABSOLUTE_Q*np.min(self.q) 
    84         self.q_calc = self.q_calc[abs(self.q_calc) >= cutoff] 
    85  
    86         # Build weight matrix from calculated q values 
    8784        self.weight_matrix = pinhole_resolution(self.q_calc, self.q, 
    8885                                np.maximum(q_width, MINIMUM_RESOLUTION)) 
    89         self.q_calc = abs(self.q_calc) 
    9086 
    9187    def apply(self, theory): 
     
    127123        self.q_calc = slit_extend_q(q, qx_width, qy_width) \ 
    128124            if q_calc is None else np.sort(q_calc) 
    129  
    130         # Protect against models which are not defined for very low q.  Limit 
    131         # the smallest q value evaluated (in absolute) to 0.02*min 
    132         cutoff = MINIMUM_ABSOLUTE_Q*np.min(self.q) 
    133         self.q_calc = self.q_calc[abs(self.q_calc) >= cutoff] 
    134  
    135         # Build weight matrix from calculated q values 
    136125        self.weight_matrix = \ 
    137126            slit_resolution(self.q_calc, self.q, qx_width, qy_width) 
    138         self.q_calc = abs(self.q_calc) 
    139127 
    140128    def apply(self, theory): 
     
    165153    # neither trapezoid nor Simpson's rule improved the accuracy. 
    166154    edges = bin_edges(q_calc) 
    167     #edges[edges < 0.0] = 0.0 # clip edges below zero 
     155    edges[edges < 0.0] = 0.0 # clip edges below zero 
    168156    cdf = erf((edges[:, None] - q[None, :]) / (sqrt(2.0)*q_width)[None, :]) 
    169157    weights = cdf[1:] - cdf[:-1] 
     
    298286    # The current algorithm is a midpoint rectangle rule. 
    299287    q_edges = bin_edges(q_calc) # Note: requires q > 0 
    300     #q_edges[q_edges < 0.0] = 0.0 # clip edges below zero 
     288    q_edges[q_edges < 0.0] = 0.0 # clip edges below zero 
    301289    weights = np.zeros((len(q), len(q_calc)), 'd') 
    302290 
     
    404392    interval. 
    405393 
    406     Note that extrapolated values may be negative. 
     394    if *q_min* is zero or less then *q[0]/10* is used instead. 
    407395    """ 
    408396    q = np.sort(q) 
    409397    if q_min + 2*MINIMUM_RESOLUTION < q[0]: 
     398        if q_min <= 0: q_min = q_min*MIN_Q_SCALE_FOR_NEGATIVE_Q_EXTRAPOLATION 
    410399        n_low = np.ceil((q[0]-q_min) / (q[1]-q[0])) if q[1] > q[0] else 15 
    411400        q_low = np.linspace(q_min, q[0], n_low+1)[:-1] 
     
    459448        log_delta_q = log(10.) / points_per_decade 
    460449    if q_min < q[0]: 
    461         if q_min < 0: q_min = q[0]*MINIMUM_ABSOLUTE_Q 
     450        if q_min < 0: q_min = q[0]*MIN_Q_SCALE_FOR_NEGATIVE_Q_EXTRAPOLATION 
    462451        n_low = log_delta_q * (log(q[0])-log(q_min)) 
    463452        q_low = np.logspace(log10(q_min), log10(q[0]), np.ceil(n_low)+1)[:-1] 
Note: See TracChangeset for help on using the changeset viewer.