55import pandas as pd
66from scipy .interpolate import interp1d
77
8- from diffpy .utils .scattering_objects .diffraction_objects import Diffraction_object
8+ from diffpy .utils .scattering_objects .diffraction_objects import XQUANTITIES , Diffraction_object
99
1010RADIUS_MM = 1
1111N_POINTS_ON_DIAMETER = 300
@@ -198,7 +198,6 @@ def _cve_brute_force(diffraction_data, mud):
198198 "tth" ,
199199 metadata = diffraction_data .metadata ,
200200 name = f"absorption correction, cve, for { diffraction_data .name } " ,
201- wavelength = diffraction_data .wavelength ,
202201 scat_quantity = "cve" ,
203202 )
204203 return cve_do
@@ -227,7 +226,6 @@ def _cve_polynomial_interpolation(diffraction_data, mud):
227226 "tth" ,
228227 metadata = diffraction_data .metadata ,
229228 name = f"absorption correction, cve, for { diffraction_data .name } " ,
230- wavelength = diffraction_data .wavelength ,
231229 scat_quantity = "cve" ,
232230 )
233231 return cve_do
@@ -246,15 +244,18 @@ def _cve_method(method):
246244 return methods [method ]
247245
248246
249- def compute_cve (diffraction_data , mud , method = "polynomial_interpolation" ):
247+ def compute_cve (diffraction_data , mud , method = "polynomial_interpolation" , xtype = "tth" ):
250248 f"""
251249 compute and interpolate the cve for the given diffraction data and mud using the selected method
250+
252251 Parameters
253252 ----------
254253 diffraction_data Diffraction_object
255254 the diffraction pattern
256255 mud float
257256 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 , }
258259 method str
259260 the method used to calculate cve, must be one of { * CVE_METHODS , }
260261
@@ -264,22 +265,20 @@ def compute_cve(diffraction_data, mud, method="polynomial_interpolation"):
264265 """
265266
266267 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 )
272273 cve_do = Diffraction_object (wavelength = diffraction_data .wavelength )
273274 cve_do .insert_scattering_quantity (
274275 orig_grid ,
275276 newcve ,
276- "tth" ,
277+ xtype ,
277278 metadata = diffraction_data .metadata ,
278279 name = f"absorption correction, cve, for { diffraction_data .name } " ,
279- wavelength = diffraction_data .wavelength ,
280280 scat_quantity = "cve" ,
281281 )
282-
283282 return cve_do
284283
285284
0 commit comments