5
5
import pandas as pd
6
6
from scipy .interpolate import interp1d
7
7
8
- from diffpy .utils .scattering_objects .diffraction_objects import Diffraction_object
8
+ from diffpy .utils .scattering_objects .diffraction_objects import XQUANTITIES , Diffraction_object
9
9
10
10
RADIUS_MM = 1
11
11
N_POINTS_ON_DIAMETER = 300
@@ -198,7 +198,6 @@ def _cve_brute_force(diffraction_data, mud):
198
198
"tth" ,
199
199
metadata = diffraction_data .metadata ,
200
200
name = f"absorption correction, cve, for { diffraction_data .name } " ,
201
- wavelength = diffraction_data .wavelength ,
202
201
scat_quantity = "cve" ,
203
202
)
204
203
return cve_do
@@ -227,7 +226,6 @@ def _cve_polynomial_interpolation(diffraction_data, mud):
227
226
"tth" ,
228
227
metadata = diffraction_data .metadata ,
229
228
name = f"absorption correction, cve, for { diffraction_data .name } " ,
230
- wavelength = diffraction_data .wavelength ,
231
229
scat_quantity = "cve" ,
232
230
)
233
231
return cve_do
@@ -246,15 +244,18 @@ def _cve_method(method):
246
244
return methods [method ]
247
245
248
246
249
- def compute_cve (diffraction_data , mud , method = "polynomial_interpolation" ):
247
+ def compute_cve (diffraction_data , mud , method = "polynomial_interpolation" , xtype = "tth" ):
250
248
f"""
251
249
compute and interpolate the cve for the given diffraction data and mud using the selected method
250
+
252
251
Parameters
253
252
----------
254
253
diffraction_data Diffraction_object
255
254
the diffraction pattern
256
255
mud float
257
256
the mu*D of the diffraction object, where D is the diameter of the circle
257
+ xtype str
258
+ the quantity on the independent variable axis, allowed values are { * XQUANTITIES , }
258
259
method str
259
260
the method used to calculate cve, must be one of { * CVE_METHODS , }
260
261
@@ -264,22 +265,20 @@ def compute_cve(diffraction_data, mud, method="polynomial_interpolation"):
264
265
"""
265
266
266
267
cve_function = _cve_method (method )
267
- abdo_on_global_tth = cve_function (diffraction_data , mud )
268
- global_tth = abdo_on_global_tth . on_tth [0 ]
269
- cve_on_global_tth = abdo_on_global_tth . on_tth [ 1 ]
270
- orig_grid = diffraction_data . on_tth [ 0 ]
271
- newcve = np .interp (orig_grid , global_tth , cve_on_global_tth )
268
+ cve_do_on_global_grid = cve_function (diffraction_data , mud )
269
+ orig_grid = diffraction_data . on_xtype ( xtype ) [0 ]
270
+ global_xtype = cve_do_on_global_grid . on_xtype ( xtype )[ 0 ]
271
+ cve_on_global_xtype = cve_do_on_global_grid . on_xtype ( xtype )[ 1 ]
272
+ newcve = np .interp (orig_grid , global_xtype , cve_on_global_xtype )
272
273
cve_do = Diffraction_object (wavelength = diffraction_data .wavelength )
273
274
cve_do .insert_scattering_quantity (
274
275
orig_grid ,
275
276
newcve ,
276
- "tth" ,
277
+ xtype ,
277
278
metadata = diffraction_data .metadata ,
278
279
name = f"absorption correction, cve, for { diffraction_data .name } " ,
279
- wavelength = diffraction_data .wavelength ,
280
280
scat_quantity = "cve" ,
281
281
)
282
-
283
282
return cve_do
284
283
285
284
0 commit comments