@@ -173,7 +173,7 @@ def get_path_length(self, grid_point, angle):
173
173
return total_distance , primary_distance , secondary_distance
174
174
175
175
176
- def _cve_brute_force (mud ):
176
+ def _cve_brute_force (diffraction_data , mud ):
177
177
"""
178
178
compute cve for the given mud on a global grid using the brute-force method
179
179
assume mu=mud/2, given that the same mu*D yields the same cve and D/2=1
@@ -190,10 +190,21 @@ def _cve_brute_force(mud):
190
190
distances = np .array (distances ) / abs_correction .total_points_in_grid
191
191
muls = np .array (muls ) / abs_correction .total_points_in_grid
192
192
cve = 1 / muls
193
- return cve
193
+
194
+ abdo = Diffraction_object (wavelength = diffraction_data .wavelength )
195
+ abdo .insert_scattering_quantity (
196
+ TTH_GRID ,
197
+ cve ,
198
+ "tth" ,
199
+ metadata = diffraction_data .metadata ,
200
+ name = f"absorption correction, cve, for { diffraction_data .name } " ,
201
+ wavelength = diffraction_data .wavelength ,
202
+ scat_quantity = "cve" ,
203
+ )
204
+ return abdo
194
205
195
206
196
- def _cve_polynomial_interpolation (mud ):
207
+ def _cve_polynomial_interpolation (diffraction_data , mud ):
197
208
"""
198
209
compute cve using polynomial interpolation method, raise an error if mu*D is out of the range (0.5 to 6)
199
210
"""
@@ -208,7 +219,18 @@ def _cve_polynomial_interpolation(mud):
208
219
]
209
220
muls = np .array (coeff_a * MULS ** 4 + coeff_b * MULS ** 3 + coeff_c * MULS ** 2 + coeff_d * MULS + coeff_e )
210
221
cve = 1 / muls
211
- return cve
222
+
223
+ abdo = Diffraction_object (wavelength = diffraction_data .wavelength )
224
+ abdo .insert_scattering_quantity (
225
+ TTH_GRID ,
226
+ cve ,
227
+ "tth" ,
228
+ metadata = diffraction_data .metadata ,
229
+ name = f"absorption correction, cve, for { diffraction_data .name } " ,
230
+ wavelength = diffraction_data .wavelength ,
231
+ scat_quantity = "cve" ,
232
+ )
233
+ return abdo
212
234
213
235
214
236
def _cve_method (method ):
@@ -224,18 +246,16 @@ def _cve_method(method):
224
246
return methods [method ]
225
247
226
248
227
- def compute_cve (diffraction_data , mud , wavelength , method = "polynomial_interpolation" ):
249
+ def compute_cve (diffraction_data , mud , method = "polynomial_interpolation" ):
228
250
"""
229
- compute and interpolate the cve for the given diffraction data, mud, and wavelength, using the selected method
251
+ compute and interpolate the cve for the given diffraction data and mud using the selected method
230
252
231
253
Parameters
232
254
----------
233
255
diffraction_data Diffraction_object
234
256
the diffraction pattern
235
257
mud float
236
258
the mu*D of the diffraction object, where D is the diameter of the circle
237
- wavelength float
238
- the wavelength of the diffraction object
239
259
method str
240
260
the method used to calculate cve
241
261
@@ -246,10 +266,12 @@ def compute_cve(diffraction_data, mud, wavelength, method="polynomial_interpolat
246
266
"""
247
267
248
268
cve_function = _cve_method (method )
249
- cve = cve_function (mud )
269
+ abdo_on_global_tth = cve_function (diffraction_data , mud )
270
+ global_tth = abdo_on_global_tth .on_tth [0 ]
271
+ cve_on_global_tth = abdo_on_global_tth .on_tth [1 ]
250
272
orig_grid = diffraction_data .on_tth [0 ]
251
- newcve = np .interp (orig_grid , TTH_GRID , cve )
252
- abdo = Diffraction_object (wavelength = wavelength )
273
+ newcve = np .interp (orig_grid , global_tth , cve_on_global_tth )
274
+ abdo = Diffraction_object (wavelength = diffraction_data . wavelength )
253
275
abdo .insert_scattering_quantity (
254
276
orig_grid ,
255
277
newcve ,
0 commit comments