Skip to content

Commit 2fc80e0

Browse files
authored
Merge pull request #571 from SasView/568-fix-geometric-extrapolation-when-points-per-decade-is-provided-or-data-is-a-single-point
Fixed inverse q-spacing in the geometric extrapolation function
2 parents e57e776 + 98053f4 commit 2fc80e0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sasmodels/resolution.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -509,20 +509,20 @@ def geometric_extrapolation(q, q_min, q_max, points_per_decade=None):
509509
data_min, data_max = q[0], q[-1]
510510
if points_per_decade is None:
511511
if data_max > data_min:
512-
log_delta_q = (len(q) - 1) / (log(data_max) - log(data_min))
512+
log_delta_q = (log(data_max) - log(data_min)) / (len(q) - 1)
513513
else:
514514
log_delta_q = log(10.) / DEFAULT_POINTS_PER_DECADE
515515
else:
516516
log_delta_q = log(10.) / points_per_decade
517517
if q_min < data_min:
518518
if q_min < 0:
519519
q_min = data_min*MINIMUM_ABSOLUTE_Q
520-
n_low = int(np.ceil(log_delta_q * (log(q[0])-log(q_min))))
520+
n_low = int(np.ceil((log(q[0])-log(q_min)) / log_delta_q))
521521
q_low = np.logspace(log10(q_min), log10(q[0]), n_low+1)[:-1]
522522
else:
523523
q_low = []
524524
if q_max > data_max:
525-
n_high = int(np.ceil(log_delta_q * (log(q_max)-log(data_max))))
525+
n_high = int(np.ceil((log(q_max)-log(data_max)) / log_delta_q))
526526
q_high = np.logspace(log10(data_max), log10(q_max), n_high+1)[1:]
527527
else:
528528
q_high = []

0 commit comments

Comments
 (0)