55import pandas as pd
66from scipy .interpolate import interp1d
77
8- from diffpy .utils .scattering_objects . diffraction_objects import XQUANTITIES , Diffraction_object
8+ from diffpy .utils .diffraction_objects import XQUANTITIES , DiffractionObject
99
1010RADIUS_MM = 1
1111N_POINTS_ON_DIAMETER = 300
1212TTH_GRID = np .arange (1 , 180.1 , 0.1 )
13+ TTH_GRID = np .round (TTH_GRID , 1 )
1314CVE_METHODS = ["brute_force" , "polynomial_interpolation" ]
1415
1516# pre-computed datasets for polynomial interpolation (fast calculation)
@@ -191,14 +192,14 @@ def _cve_brute_force(diffraction_data, mud):
191192 muls = np .array (muls ) / abs_correction .total_points_in_grid
192193 cve = 1 / muls
193194
194- cve_do = Diffraction_object (wavelength = diffraction_data .wavelength )
195- cve_do .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 } " ,
195+ cve_do = DiffractionObject (
196+ xarray = TTH_GRID ,
197+ yarray = cve ,
198+ xtype = "tth" ,
199+ wavelength = diffraction_data .wavelength ,
201200 scat_quantity = "cve" ,
201+ name = f"absorption correction, cve, for { diffraction_data .name } " ,
202+ metadata = diffraction_data .metadata ,
202203 )
203204 return cve_do
204205
@@ -211,22 +212,22 @@ def _cve_polynomial_interpolation(diffraction_data, mud):
211212 if mud > 6 or mud < 0.5 :
212213 raise ValueError (
213214 f"mu*D is out of the acceptable range (0.5 to 6) for polynomial interpolation. "
214- f"Please rerun with a value within this range or specifying another method from { * CVE_METHODS , } ."
215+ f"Please rerun with a value within this range or specifying another method from { * CVE_METHODS , } ."
215216 )
216217 coeff_a , coeff_b , coeff_c , coeff_d , coeff_e = [
217218 interpolation_function (mud ) for interpolation_function in INTERPOLATION_FUNCTIONS
218219 ]
219220 muls = np .array (coeff_a * MULS ** 4 + coeff_b * MULS ** 3 + coeff_c * MULS ** 2 + coeff_d * MULS + coeff_e )
220221 cve = 1 / muls
221222
222- cve_do = Diffraction_object (wavelength = diffraction_data .wavelength )
223- cve_do .insert_scattering_quantity (
224- TTH_GRID ,
225- cve ,
226- "tth" ,
227- metadata = diffraction_data .metadata ,
228- name = f"absorption correction, cve, for { diffraction_data .name } " ,
223+ cve_do = DiffractionObject (
224+ xarray = TTH_GRID ,
225+ yarray = cve ,
226+ xtype = "tth" ,
227+ wavelength = diffraction_data .wavelength ,
229228 scat_quantity = "cve" ,
229+ name = f"absorption correction, cve, for { diffraction_data .name } " ,
230+ metadata = diffraction_data .metadata ,
230231 )
231232 return cve_do
232233
@@ -257,7 +258,7 @@ def compute_cve(diffraction_data, mud, method="polynomial_interpolation", xtype=
257258 xtype str
258259 the quantity on the independent variable axis, allowed values are { * XQUANTITIES , }
259260 method str
260- the method used to calculate cve, must be one of { * CVE_METHODS , }
261+ the method used to calculate cve, must be one of { * CVE_METHODS , }
261262
262263 Returns
263264 -------
@@ -270,14 +271,14 @@ def compute_cve(diffraction_data, mud, method="polynomial_interpolation", xtype=
270271 global_xtype = cve_do_on_global_grid .on_xtype (xtype )[0 ]
271272 cve_on_global_xtype = cve_do_on_global_grid .on_xtype (xtype )[1 ]
272273 newcve = np .interp (orig_grid , global_xtype , cve_on_global_xtype )
273- cve_do = Diffraction_object (wavelength = diffraction_data .wavelength )
274- cve_do .insert_scattering_quantity (
275- orig_grid ,
276- newcve ,
277- xtype ,
278- metadata = diffraction_data .metadata ,
279- name = f"absorption correction, cve, for { diffraction_data .name } " ,
274+ cve_do = DiffractionObject (
275+ xarray = orig_grid ,
276+ yarray = newcve ,
277+ xtype = xtype ,
278+ wavelength = diffraction_data .wavelength ,
280279 scat_quantity = "cve" ,
280+ name = f"absorption correction, cve, for { diffraction_data .name } " ,
281+ metadata = diffraction_data .metadata ,
281282 )
282283 return cve_do
283284
0 commit comments