1 | from bumps.names import * |
---|
2 | |
---|
3 | from sasmodels import core, bumps_model |
---|
4 | |
---|
5 | if True: # fix when data loader exists |
---|
6 | # from sas.dataloader.readers\ |
---|
7 | from sas.dataloader.loader import Loader |
---|
8 | loader = Loader() |
---|
9 | filename = 'testsasview1.ses' |
---|
10 | data = loader.load(filename) |
---|
11 | if data is None: raise IOError("Could not load file %r"%(filename,)) |
---|
12 | data.x /= 10 |
---|
13 | # print data |
---|
14 | # data = load_sesans('mydatfile.pz') |
---|
15 | # sans_data = load_sans('mysansfile.xml') |
---|
16 | |
---|
17 | else: |
---|
18 | SElength = np.linspace(0, 2400, 61) # [A] |
---|
19 | data = np.ones_like(SElength) |
---|
20 | err_data = np.ones_like(SElength)*0.03 |
---|
21 | |
---|
22 | class Sample: |
---|
23 | zacceptance = 0.1 # [A^-1] |
---|
24 | thickness = 0.2 # [cm] |
---|
25 | |
---|
26 | class SESANSData1D: |
---|
27 | #q_zmax = 0.23 # [A^-1] |
---|
28 | lam = 0.2 # [nm] |
---|
29 | x = SElength |
---|
30 | y = data |
---|
31 | dy = err_data |
---|
32 | sample = Sample() |
---|
33 | data = SESANSData1D() |
---|
34 | |
---|
35 | radius = 1000 |
---|
36 | data.Rmax = 3*radius # [A] |
---|
37 | |
---|
38 | ## Sphere parameters |
---|
39 | |
---|
40 | kernel = core.load_model("sphere", dtype='single') |
---|
41 | phi = Parameter(0.1, name="phi") |
---|
42 | model = bumps_model.Model(kernel, |
---|
43 | scale=phi*(1-phi), sld=7.0, solvent_sld=1.0, radius=radius, |
---|
44 | ) |
---|
45 | phi.range(0.001,0.5) |
---|
46 | #model.radius.pmp(40) |
---|
47 | model.radius.range(1,10000) |
---|
48 | #model.sld.pm(5) |
---|
49 | #model.background |
---|
50 | #model.radius_pd=0 |
---|
51 | #model.radius_pd_n=0 |
---|
52 | |
---|
53 | ### Tri-Axial Ellipsoid |
---|
54 | # |
---|
55 | #kernel = core.load_model("triaxial_ellipsoid", dtype='single') |
---|
56 | #phi = Parameter(0.1, name='phi') |
---|
57 | #model = bumps_model.Model(kernel, |
---|
58 | # scale=phi*(1-phi), sld=7.0, solvent_sld=1.0, radius=radius, |
---|
59 | # ) |
---|
60 | #phi.range(0.001,0.90) |
---|
61 | ##model.radius.pmp(40) |
---|
62 | #model.radius.range(100,10000) |
---|
63 | ##model.sld.pmp(5) |
---|
64 | ##model.background |
---|
65 | ##model.radius_pd = 0 |
---|
66 | ##model.radius_pd_n = 0 |
---|
67 | |
---|
68 | if False: # have sans data |
---|
69 | M_sesans = bumps_model.Experiment(data=data, model=model) |
---|
70 | M_sans = bumps_model.Experiment(data=sans_data, model=model) |
---|
71 | problem = FitProblem([M_sesans, M_sans]) |
---|
72 | else: |
---|
73 | M_sesans = bumps_model.Experiment(data=data, model=model) |
---|
74 | problem = FitProblem(M_sesans) |
---|
75 | |
---|