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
« 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
4"""
5from ..xray import XrayBackground
7def xrd_background(xdata, ydata, width=4, compress=5, exponent=2, slope=None):
8 """fit background for XRF spectra. Arguments:
10 xrd_background(xdata, ydata, group=None, width=4,
11 compress=2, exponent=2, slope=None)
13 Arguments
14 ---------
15 xdata array of q values (or 2th, d?)
17 ydata associated array of I values
19 group group for outputs
21 width full width of the concave down polynomials
22 for when its full width is 100 counts.
24 compress compression factor to apply to spectra.
26 exponent power of polynomial used. Should be even.
28 slope channel to energy conversion, from energy calibration
29 (default == None --> found from input energy array)
31 Returns
32 -------
33 bgr background array
34 """
36 if slope is None:
37 slope = (xdata[-1] - xdata[0])/len(xdata)
38 bgr = ydata*1.0
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