Skip to content

Commit a2b169e

Browse files
authored
Merge branch 'master' into 568-fix-geometric-extrapolation-when-points-per-decade-is-provided-or-data-is-a-single-point
2 parents f07dc5d + 59f5bae commit a2b169e

File tree

5 files changed

+51
-27
lines changed

5 files changed

+51
-27
lines changed

.github/workflows/test.yml

+9
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,12 @@ jobs:
5959
if: ${{ matrix.os == 'ubuntu-latest' }}
6060
run: |
6161
make -j 4 -C doc SPHINXOPTS="-W --keep-going -n" html
62+
63+
- name: Publish samodels docs
64+
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10'}}
65+
uses: actions/upload-artifact@v3
66+
with:
67+
name: sasmodels-docs-${{ matrix.os }}-${{ matrix.python-version }}
68+
path: |
69+
doc/_build/html
70+
if-no-files-found: error

doc/guide/theory.rst

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.. currentmodule:: sasmodels
12
.. theory.rst
23
34
.. Much of the following text was scraped from fitting_sq.py

sasmodels/direct_model.py

+15-7
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,10 @@ def get_mesh(model_info, values, dim='1d', mono=False):
121121
values = values.copy()
122122
mesh = [_pop_par_weights(p, values, active(p.name))
123123
for p in parameters.call_parameters]
124+
124125
if values:
125126
raise TypeError(f"Unused parameters in call: {', '.join(values.keys())}")
127+
126128
return mesh
127129

128130

@@ -561,16 +563,17 @@ def near(value, target):
561563
return np.allclose(value, target, rtol=1e-6, atol=0, equal_nan=True)
562564
# Note: target values taken from running main() on parameters.
563565
# Resolution was 5% dq/q.
564-
pars = dict(radius=200)
566+
pars = dict(radius=200, background=0) # default background=1e-3, scale=1
565567
# simple sphere in 1D (perfect, pinhole, slit)
566-
assert near(Iq('sphere', [0.1], **pars), [0.6200146273894904])
567-
assert near(Iq('sphere', [0.1], dq=[0.005], **pars), [2.3019224683980215])
568-
assert near(Iq('sphere', [0.1], qw=[0.005], ql=[1.0], **pars), [0.3673431784535172])
568+
perfect_target = 0.6190146273894904
569+
assert near(Iq('sphere', [0.1], **pars), [perfect_target])
570+
assert near(Iq('sphere', [0.1], dq=[0.005], **pars), [2.3009224683980215])
571+
assert near(Iq('sphere', [0.1], qw=[0.005], ql=[1.0], **pars), [0.3663431784535172])
569572
# simple sphere in 2D (perfect, pinhole)
570-
assert near(Iqxy('sphere', [0.1], [0.1], **pars), [1.1781532874802199])
573+
assert near(Iqxy('sphere', [0.1], [0.1], **pars), [1.1771532874802199])
571574
assert near(Iqxy('sphere', [0.1], [0.1], dqx=[0.005], dqy=[0.005], **pars),
572-
[0.8177780778578667])
573-
# sesans
575+
[0.8167780778578667])
576+
# sesans (no background or scale)
574577
assert near(Gxi('sphere', [100], **pars), [-0.19146959126623486])
575578
# Check that single point sesans matches value in an array
576579
xi = np.logspace(1, 3, 100)
@@ -587,6 +590,11 @@ def near(value, target):
587590
radius=200, radius_pd=0.1, radius_pd_n=15, radius_pd_nsigma=2.5,
588591
radius_pd_type="uniform")
589592
assert near(Iq('sphere', [0.1], **pars), [2.703169824954617])
593+
# background and scale
594+
background, scale = 1e-4, 0.1
595+
pars = dict(radius=200, background=background, scale=scale)
596+
assert near(Iq('sphere', [0.1], **pars), [perfect_target*scale + background])
597+
590598

591599
if __name__ == "__main__":
592600
import logging

sasmodels/jitter.py

+25-19
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ def build_model(model_name, n=150, qmax=0.5, **pars):
881881

882882
# stuff the values for non-orientation parameters into the calculator
883883
calculator.pars = pars.copy()
884-
calculator.pars.setdefault('backgound', 1e-3)
884+
calculator.pars.setdefault('background', 1e-3)
885885

886886
# fix the data limits so that we can see if the pattern fades
887887
# under rotation or angular dispersion
@@ -908,47 +908,53 @@ def select_calculator(model_name, n=150, size=(10, 40, 100)):
908908
a, b, c = size
909909
d_factor = 0.06 # for paracrystal models
910910
if model_name == 'sphere':
911-
calculator = build_model('sphere', n=n, radius=c)
911+
calculator = build_model(
912+
'sphere', n=n, radius=c)
912913
a = b = c
913914
elif model_name == 'sc_paracrystal':
914915
a = b = c
915916
dnn = c
916917
radius = 0.5*c
917-
calculator = build_model('sc_paracrystal', n=n, dnn=dnn,
918-
d_factor=d_factor, radius=(1-d_factor)*radius,
919-
background=0)
918+
calculator = build_model(
919+
'sc_paracrystal', n=n,
920+
dnn=dnn, d_factor=d_factor, radius=(1-d_factor)*radius,
921+
background=0)
920922
elif model_name == 'fcc_paracrystal':
921923
a = b = c
922924
# nearest neigbour distance dnn should be 2 radius, but I think the
923925
# model uses lattice spacing rather than dnn in its calculations
924926
dnn = 0.5*c
925927
radius = sqrt(2)/4 * c
926-
calculator = build_model('fcc_paracrystal', n=n, dnn=dnn,
927-
d_factor=d_factor, radius=(1-d_factor)*radius,
928-
background=0)
928+
calculator = build_model(
929+
'fcc_paracrystal', n=n,
930+
dnn=dnn, d_factor=d_factor, radius=(1-d_factor)*radius,
931+
background=0)
929932
elif model_name == 'bcc_paracrystal':
930933
a = b = c
931934
# nearest neigbour distance dnn should be 2 radius, but I think the
932935
# model uses lattice spacing rather than dnn in its calculations
933936
dnn = 0.5*c
934937
radius = sqrt(3)/2 * c
935-
calculator = build_model('bcc_paracrystal', n=n, dnn=dnn,
936-
d_factor=d_factor, radius=(1-d_factor)*radius,
937-
background=0)
938+
calculator = build_model(
939+
'bcc_paracrystal', n=n,
940+
dnn=dnn, d_factor=d_factor, radius=(1-d_factor)*radius,
941+
background=0)
938942
elif model_name == 'cylinder':
939-
calculator = build_model('cylinder', n=n, qmax=0.3, radius=b, length=c)
943+
calculator = build_model(
944+
'cylinder', n=n, qmax=0.3, radius=b, length=c)
940945
a = b
941946
elif model_name == 'ellipsoid':
942-
calculator = build_model('ellipsoid', n=n, qmax=1.0,
943-
radius_polar=c, radius_equatorial=b)
947+
calculator = build_model(
948+
'ellipsoid', n=n, qmax=1.0,
949+
radius_polar=c, radius_equatorial=b)
944950
a = b
945951
elif model_name == 'triaxial_ellipsoid':
946-
calculator = build_model('triaxial_ellipsoid', n=n, qmax=0.5,
947-
radius_equat_minor=a,
948-
radius_equat_major=b,
949-
radius_polar=c)
952+
calculator = build_model(
953+
'triaxial_ellipsoid', n=n, qmax=0.5,
954+
radius_equat_minor=a, radius_equat_major=b, radius_polar=c)
950955
elif model_name == 'parallelepiped':
951-
calculator = build_model('parallelepiped', n=n, a=a, b=b, c=c)
956+
calculator = build_model(
957+
'parallelepiped', n=n, length_a=a, length_b=b, length_c=c)
952958
else:
953959
raise ValueError("unknown model %s"%model_name)
954960

sasmodels/models/lamellar_hg.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
and $\Delta\rho_T$ is tail contrast (*sld* $-$ *sld_solvent*).
3030
3131
The total thickness of the lamellar sheet is
32-
a_H + \delta_T + \delta_T + \delta_H$. Note that in a non aqueous solvent
32+
$a_H + \delta_T + \delta_T + \delta_H$. Note that in a non aqueous solvent
3333
the chemical "head" group may be the "Tail region" and vice-versa.
3434
3535
The 2D scattering intensity is calculated in the same way as 1D, where

0 commit comments

Comments
 (0)