Coverage for /Users/Newville/Codes/xraylarch/larch/xrd/xrd_bgr.py: 25%

8 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2023-11-09 10:08 -0600

1""" 

2Methods for fitting background x-ray diffraction data 

3 

4""" 

5from ..xray import XrayBackground 

6 

7def xrd_background(xdata, ydata, width=4, compress=5, exponent=2, slope=None): 

8 """fit background for XRF spectra. Arguments: 

9 

10 xrd_background(xdata, ydata, group=None, width=4, 

11 compress=2, exponent=2, slope=None) 

12 

13 Arguments 

14 --------- 

15 xdata array of q values (or 2th, d?) 

16 

17 ydata associated array of I values 

18 

19 group group for outputs 

20 

21 width full width of the concave down polynomials 

22 for when its full width is 100 counts. 

23 

24 compress compression factor to apply to spectra. 

25 

26 exponent power of polynomial used. Should be even. 

27 

28 slope channel to energy conversion, from energy calibration 

29 (default == None --> found from input energy array) 

30 

31 Returns 

32 ------- 

33 bgr background array 

34 """ 

35 

36 if slope is None: 

37 slope = (xdata[-1] - xdata[0])/len(xdata) 

38 bgr = ydata*1.0 

39 

40 xb = XrayBackground(ydata, width=width, compress=compress, 

41 exponent=exponent, slope=slope, tangent=True) 

42 bgr[:len(xb.bgr)] = xb.bgr 

43 return bgr