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