5
5
import pandas as pd
6
6
from scipy .interpolate import interp1d
7
7
8
- from diffpy .utils .scattering_objects . diffraction_objects import XQUANTITIES , Diffraction_object
8
+ from diffpy .utils .diffraction_objects import XQUANTITIES , DiffractionObject
9
9
10
10
RADIUS_MM = 1
11
11
N_POINTS_ON_DIAMETER = 300
12
12
TTH_GRID = np .arange (1 , 180.1 , 0.1 )
13
+ TTH_GRID = np .round (TTH_GRID , 1 )
13
14
CVE_METHODS = ["brute_force" , "polynomial_interpolation" ]
14
15
15
16
# pre-computed datasets for polynomial interpolation (fast calculation)
@@ -191,14 +192,14 @@ def _cve_brute_force(diffraction_data, mud):
191
192
muls = np .array (muls ) / abs_correction .total_points_in_grid
192
193
cve = 1 / muls
193
194
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 ,
201
200
scat_quantity = "cve" ,
201
+ name = f"absorption correction, cve, for { diffraction_data .name } " ,
202
+ metadata = diffraction_data .metadata ,
202
203
)
203
204
return cve_do
204
205
@@ -211,22 +212,22 @@ def _cve_polynomial_interpolation(diffraction_data, mud):
211
212
if mud > 6 or mud < 0.5 :
212
213
raise ValueError (
213
214
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 , } ."
215
216
)
216
217
coeff_a , coeff_b , coeff_c , coeff_d , coeff_e = [
217
218
interpolation_function (mud ) for interpolation_function in INTERPOLATION_FUNCTIONS
218
219
]
219
220
muls = np .array (coeff_a * MULS ** 4 + coeff_b * MULS ** 3 + coeff_c * MULS ** 2 + coeff_d * MULS + coeff_e )
220
221
cve = 1 / muls
221
222
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 ,
229
228
scat_quantity = "cve" ,
229
+ name = f"absorption correction, cve, for { diffraction_data .name } " ,
230
+ metadata = diffraction_data .metadata ,
230
231
)
231
232
return cve_do
232
233
@@ -257,7 +258,7 @@ def compute_cve(diffraction_data, mud, method="polynomial_interpolation", xtype=
257
258
xtype str
258
259
the quantity on the independent variable axis, allowed values are { * XQUANTITIES , }
259
260
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 , }
261
262
262
263
Returns
263
264
-------
@@ -270,14 +271,14 @@ def compute_cve(diffraction_data, mud, method="polynomial_interpolation", xtype=
270
271
global_xtype = cve_do_on_global_grid .on_xtype (xtype )[0 ]
271
272
cve_on_global_xtype = cve_do_on_global_grid .on_xtype (xtype )[1 ]
272
273
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 ,
280
279
scat_quantity = "cve" ,
280
+ name = f"absorption correction, cve, for { diffraction_data .name } " ,
281
+ metadata = diffraction_data .metadata ,
281
282
)
282
283
return cve_do
283
284
0 commit comments