|
32 | 32 | The objective is to accurately refine the crystal structure of PbSO4.""" |
33 | 33 |
|
34 | 34 | # Save the initial project specifying the directory path |
35 | | -project.save_as("examples/pbso4_joint") |
| 35 | +project.save_as("examples/projects/pbso4_joint") |
36 | 36 |
|
37 | 37 | # Show project metadata |
38 | 38 | project.info.show_as_cif() |
|
104 | 104 |
|
105 | 105 | print(ed.chapter('Step 3: Add Experiments (Instrument models and measured data)')) |
106 | 106 |
|
107 | | -print(ed.section('Add experiments')) |
108 | | - |
109 | | -# Add two experiments |
110 | 107 | project.experiments.add(id="npd", |
111 | | - diffr_mode="powder", |
112 | | - expt_mode="constant_wavelength", |
| 108 | + sample_form="powder", |
| 109 | + beam_mode="constant wavelength", |
113 | 110 | radiation_probe="neutron", |
114 | 111 | data_path="examples/data/pbso4_powder_neutron_cw.dat") |
115 | 112 | project.experiments.add(id="xrd", |
116 | | - diffr_mode="powder", |
117 | | - expt_mode="constant_wavelength", |
| 113 | + sample_form="powder", |
| 114 | + beam_mode="constant wavelength", |
118 | 115 | radiation_probe="xray", |
119 | 116 | data_path="examples/data/pbso4_powder_xray.dat") |
120 | 117 |
|
|
126 | 123 | project.experiments['xrd'].show_meas_chart(x_min=26, x_max=28) |
127 | 124 |
|
128 | 125 | # Modify experimental parameters |
129 | | -project.experiments['npd'].instr_setup.wavelength = 1.91 |
130 | | -project.experiments["npd"].instr_calib.twotheta_offset = -0.1406 |
131 | | -project.experiments["npd"].peak_broad.gauss_u = 0.139 |
132 | | -project.experiments["npd"].peak_broad.gauss_v = -0.412 |
133 | | -project.experiments["npd"].peak_broad.gauss_w = 0.386 |
134 | | -project.experiments["npd"].peak_broad.lorentz_x = 0 |
135 | | -project.experiments["npd"].peak_broad.lorentz_y = 0.088 |
136 | | - |
137 | | -project.experiments['xrd'].instr_setup.wavelength = 1.540567 |
138 | | -project.experiments["xrd"].instr_calib.twotheta_offset = -0.05181 |
139 | | -project.experiments["xrd"].peak_broad.gauss_u = 0.304138 |
140 | | -project.experiments["xrd"].peak_broad.gauss_v = -0.112622 |
141 | | -project.experiments["xrd"].peak_broad.gauss_w = 0.021272 |
142 | | -project.experiments["xrd"].peak_broad.lorentz_x = 0 |
143 | | -project.experiments["xrd"].peak_broad.lorentz_y = 0.057691 |
| 126 | +project.experiments['npd'].instrument.setup_wavelength = 1.91 |
| 127 | +project.experiments["npd"].instrument.calib_twotheta_offset = -0.1406 |
| 128 | + |
| 129 | +project.experiments["npd"].show_supported_peak_profile_types() |
| 130 | +project.experiments["npd"].peak_profile_type = "ikeda-carpenter" |
| 131 | +project.experiments["npd"].show_current_peak_profile_type() |
| 132 | +project.experiments["npd"].peak_profile_type = "split pseudo-voigt" |
| 133 | +project.experiments["npd"].peak_profile_type = "pseudo-voigt" |
| 134 | +project.experiments["npd"].peak.broad_gauss_u = 0.139 |
| 135 | +project.experiments["npd"].peak.broad_gauss_v = -0.412 |
| 136 | +project.experiments["npd"].peak.broad_gauss_w = 0.386 |
| 137 | +project.experiments["npd"].peak.broad_lorentz_x = 0 |
| 138 | +project.experiments["npd"].peak.broad_lorentz_y = 0.088 |
| 139 | + |
| 140 | +project.experiments['xrd'].instrument.setup_wavelength = 1.540567 |
| 141 | +project.experiments["xrd"].instrument.calib_twotheta_offset = -0.05181 |
| 142 | +project.experiments["xrd"].peak.broad_gauss_u = 0.304138 |
| 143 | +project.experiments["xrd"].peak.broad_gauss_v = -0.112622 |
| 144 | +project.experiments["xrd"].peak.broad_gauss_w = 0.021272 |
| 145 | +project.experiments["xrd"].peak.broad_lorentz_x = 0 |
| 146 | +project.experiments["xrd"].peak.broad_lorentz_y = 0.057691 |
144 | 147 |
|
145 | 148 | # Link sample model to experiments |
146 | 149 | project.experiments['npd'].linked_phases.add(id='pbso4', scale=1.0) |
147 | | -project.experiments['xrd'].linked_phases.add(id='pbso4', scale=0.005) |
| 150 | +project.experiments['xrd'].linked_phases.add(id='pbso4', scale=0.002) |
148 | 151 |
|
149 | 152 | # Show experiments as CIF |
150 | 153 | project.experiments["npd"].show_as_cif() |
|
161 | 164 | print(ed.chapter('Step 4: Analysis')) |
162 | 165 |
|
163 | 166 | print(ed.section('Set calculator')) |
164 | | -project.analysis.show_available_calculators() |
| 167 | +project.analysis.show_supported_calculators() |
165 | 168 | project.analysis.show_current_calculator() |
166 | 169 | project.analysis.current_calculator = 'crysfml' |
167 | 170 |
|
|
175 | 178 |
|
176 | 179 | # The following background points represent the baseline noise in the diffraction data. |
177 | 180 | print(ed.section('Add background')) |
| 181 | +project.experiments["npd"].background_type = "point" |
| 182 | +project.experiments["npd"].show_supported_background_types() |
| 183 | +project.experiments["npd"].show_current_background_type() |
178 | 184 | project.experiments["npd"].background.add(x=11.0, y=206.1624) |
179 | 185 | project.experiments["npd"].background.add(x=15.0, y=194.75) |
180 | 186 | project.experiments["npd"].background.add(x=20.0, y=194.505) |
|
185 | 191 | project.experiments["npd"].background.add(x=153.0, y=226.0595) |
186 | 192 | project.experiments["npd"].background.show() |
187 | 193 |
|
188 | | -project.experiments["xrd"].background.add(x=11.0, y=141.8516) |
189 | | -project.experiments["xrd"].background.add(x=13.0, y=102.8838) |
190 | | -project.experiments["xrd"].background.add(x=16.0, y=78.0551) |
191 | | -project.experiments["xrd"].background.add(x=20.0, y=124.0121) |
192 | | -project.experiments["xrd"].background.add(x=30.0, y=123.7123) |
193 | | -project.experiments["xrd"].background.add(x=50.0, y=120.8266) |
194 | | -project.experiments["xrd"].background.add(x=90.0, y=113.7473) |
195 | | -project.experiments["xrd"].background.add(x=110.0, y=132.4643) |
| 194 | +project.experiments["xrd"].background_type = "chebyshev polynomial" |
| 195 | +project.experiments["xrd"].background.add(order=0, coef=119.195) |
| 196 | +project.experiments["xrd"].background.add(order=1, coef=6.221) |
| 197 | +project.experiments["xrd"].background.add(order=2, coef=-45.725) |
| 198 | +project.experiments["xrd"].background.add(order=3, coef=8.119) |
| 199 | +project.experiments["xrd"].background.add(order=4, coef=54.552) |
| 200 | +project.experiments["xrd"].background.add(order=5, coef=-20.661) |
196 | 201 | project.experiments["xrd"].background.show() |
197 | 202 |
|
198 | 203 | print(ed.section('Show experiments as CIF. Now the background points are included')) |
|
221 | 226 |
|
222 | 227 | project.analysis.show_free_params() |
223 | 228 |
|
224 | | -print(ed.section('Set refinement strategy')) |
225 | | -project.analysis.show_available_refinement_strategies() |
226 | | -project.analysis.show_current_refinement_strategy() |
227 | | -#project.analysis.refinement_strategy = 'single' |
| 229 | +print(ed.section('Set fit mode')) |
| 230 | +project.analysis.show_available_fit_modes() |
| 231 | +project.analysis.show_current_fit_mode() |
| 232 | +#project.analysis.fit_mode = 'single' |
228 | 233 |
|
229 | 234 | print(ed.section('Set fitting engine')) |
230 | 235 | project.analysis.show_available_minimizers() |
|
250 | 255 | project.analysis.show_meas_vs_calc_chart(expt_id="xrd", x_min=26, x_max=28, show_residual=True) |
251 | 256 |
|
252 | 257 | print(ed.section('Change calculator')) |
253 | | -project.analysis.show_available_calculators() |
| 258 | +project.analysis.show_supported_calculators() |
254 | 259 | project.analysis.current_calculator = 'cryspy' |
255 | 260 |
|
256 | 261 | print(ed.section('Start 3rd fitting')) |
|
260 | 265 | project.analysis.show_meas_vs_calc_chart(expt_id="npd", x_min=62, x_max=66, show_residual=True) |
261 | 266 | project.analysis.show_meas_vs_calc_chart(expt_id="xrd", x_min=26, x_max=28, show_residual=True) |
262 | 267 |
|
263 | | -print(ed.section('Change refinement strategy')) |
264 | | -project.analysis.show_available_refinement_strategies() |
265 | | -project.analysis.show_current_refinement_strategy() |
266 | | -project.analysis.refinement_strategy = 'combined' |
| 268 | +print(ed.section('Change fit mode')) |
| 269 | +project.analysis.show_available_fit_modes() |
| 270 | +project.analysis.show_current_fit_mode() |
| 271 | +project.analysis.fit_mode = 'joint' |
267 | 272 |
|
268 | 273 | print(ed.section('Change calculator')) |
269 | | -project.analysis.show_available_calculators() |
| 274 | +project.analysis.show_supported_calculators() |
270 | 275 | project.analysis.show_current_calculator() |
271 | 276 | project.analysis.current_calculator = 'crysfml' |
272 | 277 |
|
|
277 | 282 | project.analysis.show_meas_vs_calc_chart(expt_id="npd", x_min=62, x_max=66, show_residual=True) |
278 | 283 | project.analysis.show_meas_vs_calc_chart(expt_id="xrd", x_min=26, x_max=28, show_residual=True) |
279 | 284 |
|
| 285 | +# Show analysis as CIF |
| 286 | +project.analysis.show_as_cif() |
| 287 | + |
280 | 288 | # Save the project state after analysis |
281 | 289 | project.save() |
282 | 290 |
|
|
0 commit comments