Changeset 1aa7990 in sasmodels
 Timestamp:
 Mar 21, 2017 11:12:00 AM (5 years ago)
 Branches:
 master, core_shell_microgels, costrafo411, magnetic_model, ticket1257vesicleproduct, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
 Children:
 3a45c2c, cb0dc22
 Parents:
 4050e6a (diff), d38f244 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.  gitauthor:
 Paul Kienzle <pkienzle@…> (03/21/17 11:12:00)
 gitcommitter:
 GitHub <noreply@…> (03/21/17 11:12:00)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

sasmodels/resolution.py
rb397165 rb32caab 17 17 18 18 MINIMUM_RESOLUTION = 1e8 19 20 21 # When extrapolating to q, what is the minimum positive q relative to q_min 22 # that we wish to calculate? 23 MIN_Q_SCALE_FOR_NEGATIVE_Q_EXTRAPOLATION = 0.01 19 MINIMUM_ABSOLUTE_Q = 0.02 # relative to the minimum q in the data 24 20 25 21 class Resolution(object): … … 82 78 self.q_calc = (pinhole_extend_q(q, q_width, nsigma=nsigma) 83 79 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 84 87 self.weight_matrix = pinhole_resolution(self.q_calc, self.q, 85 88 np.maximum(q_width, MINIMUM_RESOLUTION)) 89 self.q_calc = abs(self.q_calc) 86 90 87 91 def apply(self, theory): … … 123 127 self.q_calc = slit_extend_q(q, qx_width, qy_width) \ 124 128 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 125 136 self.weight_matrix = \ 126 137 slit_resolution(self.q_calc, self.q, qx_width, qy_width) 138 self.q_calc = abs(self.q_calc) 127 139 128 140 def apply(self, theory): … … 153 165 # neither trapezoid nor Simpson's rule improved the accuracy. 154 166 edges = bin_edges(q_calc) 155 edges[edges < 0.0] = 0.0 # clip edges below zero167 #edges[edges < 0.0] = 0.0 # clip edges below zero 156 168 cdf = erf((edges[:, None]  q[None, :]) / (sqrt(2.0)*q_width)[None, :]) 157 169 weights = cdf[1:]  cdf[:1] … … 286 298 # The current algorithm is a midpoint rectangle rule. 287 299 q_edges = bin_edges(q_calc) # Note: requires q > 0 288 q_edges[q_edges < 0.0] = 0.0 # clip edges below zero300 #q_edges[q_edges < 0.0] = 0.0 # clip edges below zero 289 301 weights = np.zeros((len(q), len(q_calc)), 'd') 290 302 … … 392 404 interval. 393 405 394 if *q_min* is zero or less then *q[0]/10* is used instead.406 Note that extrapolated values may be negative. 395 407 """ 396 408 q = np.sort(q) 397 409 if q_min + 2*MINIMUM_RESOLUTION < q[0]: 398 if q_min <= 0: q_min = q_min*MIN_Q_SCALE_FOR_NEGATIVE_Q_EXTRAPOLATION399 410 n_low = np.ceil((q[0]q_min) / (q[1]q[0])) if q[1] > q[0] else 15 400 411 q_low = np.linspace(q_min, q[0], n_low+1)[:1] … … 448 459 log_delta_q = log(10.) / points_per_decade 449 460 if q_min < q[0]: 450 if q_min < 0: q_min = q[0]*MIN _Q_SCALE_FOR_NEGATIVE_Q_EXTRAPOLATION461 if q_min < 0: q_min = q[0]*MINIMUM_ABSOLUTE_Q 451 462 n_low = log_delta_q * (log(q[0])log(q_min)) 452 463 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.