1 | #!/usr/bin/env python |
---|
2 | # -*- coding: utf-8 -*- |
---|
3 | |
---|
4 | import sys |
---|
5 | from bumps.names import * |
---|
6 | from sasmodels import bumps_model as sas |
---|
7 | |
---|
8 | """ IMPORT THE DATA USED """ |
---|
9 | radial_data = sas.load_data('DEC07267.DAT') |
---|
10 | sas.set_beam_stop(radial_data, 0.00669, outer=0.025) |
---|
11 | sas.set_top(radial_data, -.0185) |
---|
12 | |
---|
13 | tan_data = sas.load_data('DEC07266.DAT') |
---|
14 | sas.set_beam_stop(tan_data, 0.00669, outer=0.025) |
---|
15 | sas.set_top(tan_data, -.0185) |
---|
16 | #sas.set_half(tan_data, 'right') |
---|
17 | |
---|
18 | name = "ellipsoid" if len(sys.argv) < 2 else sys.argv[1] |
---|
19 | section = "radial" if len(sys.argv) < 3 else sys.argv[2] |
---|
20 | if section not in ("radial","tangential","both"): |
---|
21 | raise ValueError("section %r should be 'radial', 'tangential' or 'both'" |
---|
22 | % section) |
---|
23 | data = radial_data if section != "tangential" else tan_data |
---|
24 | phi = 0 if section != "tangential" else 90 |
---|
25 | kernel = sas.load_model(name, dtype="single") |
---|
26 | cutoff = 1e-3 |
---|
27 | |
---|
28 | if name == "ellipsoid": |
---|
29 | model = sas.BumpsModel(data, kernel, |
---|
30 | scale=0.08, |
---|
31 | rpolar=15, requatorial=800, |
---|
32 | sld=.291, solvent_sld=7.105, |
---|
33 | background=0, |
---|
34 | theta=90, phi=phi, |
---|
35 | theta_pd=15, theta_pd_n=40, theta_pd_nsigma=3, |
---|
36 | rpolar_pd=0.222296, rpolar_pd_n=1, rpolar_pd_nsigma=0, |
---|
37 | requatorial_pd=.000128, requatorial_pd_n=1, requatorial_pd_nsigma=0, |
---|
38 | phi_pd=0, phi_pd_n=20, phi_pd_nsigma=3, |
---|
39 | ) |
---|
40 | |
---|
41 | |
---|
42 | # SET THE FITTING PARAMETERS |
---|
43 | #model.rpolar.range(15, 1000) |
---|
44 | #model.requatorial.range(15, 1000) |
---|
45 | #model.theta_pd.range(0, 360) |
---|
46 | #model.background.range(0,1000) |
---|
47 | model.scale.range(0, 10) |
---|
48 | |
---|
49 | |
---|
50 | elif name == "lamellar": |
---|
51 | model = sas.BumpsModel(data, kernel, |
---|
52 | scale=0.08, |
---|
53 | thickness=19.2946, |
---|
54 | sld=5.38,sld_sol=7.105, |
---|
55 | background=0.003, |
---|
56 | thickness_pd= 0.37765, thickness_pd_n=10, thickness_pd_nsigma=3, |
---|
57 | ) |
---|
58 | |
---|
59 | # SET THE FITTING PARAMETERS |
---|
60 | #model.thickness.range(0, 1000) |
---|
61 | #model.scale.range(0, 1) |
---|
62 | #model.thickness_pd.range(0, 1000) |
---|
63 | #model.background.range(0, 1000) |
---|
64 | model.sld.range(0, 1) |
---|
65 | |
---|
66 | |
---|
67 | elif name == "cylinder": |
---|
68 | """ |
---|
69 | pars = dict(scale=0.0023, radius=92.5, length=798.3, |
---|
70 | sld=.29, solvent_sld=7.105, background=5, |
---|
71 | theta=0, phi=phi, |
---|
72 | theta_pd=22.11, theta_pd_n=5, theta_pd_nsigma=3, |
---|
73 | radius_pd=.0084, radius_pd_n=10, radius_pd_nsigma=3, |
---|
74 | length_pd=0.493, length_pd_n=10, length_pd_nsigma=3, |
---|
75 | phi_pd=0, phi_pd_n=5, phi_pd_nsigma=3,) |
---|
76 | """ |
---|
77 | pars = dict( |
---|
78 | scale=.01, background=35, |
---|
79 | sld=.291, solvent_sld=5.77, |
---|
80 | radius=250, length=178, |
---|
81 | theta=90, phi=phi, |
---|
82 | radius_pd=0.1, radius_pd_n=5, radius_pd_nsigma=3, |
---|
83 | length_pd=0.1,length_pd_n=5, length_pd_nsigma=3, |
---|
84 | theta_pd=10, theta_pd_n=50, theta_pd_nsigma=3, |
---|
85 | phi_pd=0, phi_pd_n=10, phi_pd_nsigma=3) |
---|
86 | model = sas.BumpsModel(data, kernel, **pars) |
---|
87 | |
---|
88 | # SET THE FITTING PARAMETERS |
---|
89 | model.radius.range(1, 500) |
---|
90 | model.length.range(1, 5000) |
---|
91 | model.theta.range(-90,100) |
---|
92 | model.theta_pd.range(0, 30) |
---|
93 | model.theta_pd_n = model.theta_pd + 5 |
---|
94 | model.radius_pd.range(0, 1) |
---|
95 | model.length_pd.range(0, 2) |
---|
96 | model.scale.range(0, 10) |
---|
97 | model.background.range(0, 100) |
---|
98 | |
---|
99 | |
---|
100 | elif name == "core_shell_cylinder": |
---|
101 | model = sas.BumpsModel(data, kernel, |
---|
102 | scale= .031, radius=19.5, thickness=30, length=22, |
---|
103 | core_sld=7.105, shell_sld=.291, solvent_sld=7.105, |
---|
104 | background=0, theta=0, phi=phi, |
---|
105 | |
---|
106 | radius_pd=0.26, radius_pd_n=10, radius_pd_nsigma=3, |
---|
107 | length_pd=0.26, length_pd_n=10, length_pd_nsigma=3, |
---|
108 | thickness_pd=1, thickness_pd_n=1, thickness_pd_nsigma=1, |
---|
109 | theta_pd=1, theta_pd_n=10, theta_pd_nsigma=3, |
---|
110 | phi_pd=0.1, phi_pd_n=1, phi_pd_nsigma=1, |
---|
111 | ) |
---|
112 | |
---|
113 | # SET THE FITTING PARAMETERS |
---|
114 | #model.radius.range(115, 1000) |
---|
115 | #model.length.range(0, 2500) |
---|
116 | #model.thickness.range(18, 38) |
---|
117 | #model.thickness_pd.range(0, 1) |
---|
118 | #model.phi.range(0, 90) |
---|
119 | #model.radius_pd.range(0, 1) |
---|
120 | #model.length_pd.range(0, 1) |
---|
121 | #model.theta_pd.range(0, 360) |
---|
122 | #model.background.range(0,5) |
---|
123 | model.scale.range(0, 1) |
---|
124 | |
---|
125 | |
---|
126 | |
---|
127 | elif name == "capped_cylinder": |
---|
128 | model = sas.BumpsModel(data, kernel, |
---|
129 | scale=.08, radius=20, cap_radius=40, length=400, |
---|
130 | sld_capcyl=1, sld_solv=6.3, |
---|
131 | background=0, theta=0, phi=phi, |
---|
132 | radius_pd=.1, radius_pd_n=5, radius_pd_nsigma=3, |
---|
133 | cap_radius_pd=.1, cap_radius_pd_n=5, cap_radius_pd_nsigma=3, |
---|
134 | length_pd=.1, length_pd_n=1, length_pd_nsigma=0, |
---|
135 | theta_pd=.1, theta_pd_n=1, theta_pd_nsigma=0, |
---|
136 | phi_pd=.1, phi_pd_n=1, phi_pd_nsigma=0, |
---|
137 | dtype=dtype) |
---|
138 | |
---|
139 | model.scale.range(0, 1) |
---|
140 | |
---|
141 | |
---|
142 | elif name == "triaxial_ellipsoid": |
---|
143 | model = sas.BumpsModel(data, kernel, |
---|
144 | scale=0.08, req_minor=15, req_major=20, rpolar=500, |
---|
145 | sldEll=7.105, solvent_sld=.291, |
---|
146 | background=5, theta=0, phi=phi, psi=0, |
---|
147 | theta_pd=20, theta_pd_n=40, theta_pd_nsigma=3, |
---|
148 | phi_pd=.1, phi_pd_n=1, phi_pd_nsigma=0, |
---|
149 | psi_pd=30, psi_pd_n=1, psi_pd_nsigma=0, |
---|
150 | req_minor_pd=.1, req_minor_pd_n=1, req_minor_pd_nsigma=0, |
---|
151 | req_major_pd=.1, req_major_pd_n=1, req_major_pd_nsigma=0, |
---|
152 | rpolar_pd=.1, rpolar_pd_n=1, rpolar_pd_nsigma=0, dtype=dtype) |
---|
153 | |
---|
154 | # SET THE FITTING PARAMETERS |
---|
155 | model.req_minor.range(15, 1000) |
---|
156 | model.req_major.range(15, 1000) |
---|
157 | #model.rpolar.range(15, 1000) |
---|
158 | #model.background.range(0,1000) |
---|
159 | #model.theta_pd.range(0, 360) |
---|
160 | #model.phi_pd.range(0, 360) |
---|
161 | #model.psi_pd.range(0, 360) |
---|
162 | |
---|
163 | else: |
---|
164 | print "No parameters for %s"%name |
---|
165 | sys.exit(1) |
---|
166 | |
---|
167 | model.cutoff = cutoff |
---|
168 | if section == "both": |
---|
169 | tan_model = sas.BumpsModel(tan_data, model.model, model.parameters()) |
---|
170 | tan_model.phi = model.phi - 90 |
---|
171 | tan_model.cutoff = cutoff |
---|
172 | problem = FitProblem([model, tan_model]) |
---|
173 | else: |
---|
174 | problem = FitProblem(model) |
---|