hexrd.fitting.fitpeak module
- hexrd.fitting.fitpeak.calc_pk_integrated_intensities(p, x, pktype, num_pks)[source]
Calculate the area under the curve (integrated intensities) for fit peaks.
Parameters
- parray_like
(m x u + v) peak parameters for u peaks, m is the number of parameters per peak:
“gaussian” and “lorentzian” = 3; “pvoigt” = 4; “split_pvoigt” = 5.
v is the number of parameters for chosen bgtype
- xarray_like
(n, ) ndarray of abcissa coordinates.
- pktypestr
type of analytic function that will be used to fit the data; current options are “gaussian”, “gaussian_rot” (gaussian with arbitrary axes) and “split_pvoigt_rot” (split psuedo voigt with arbitrary axes).
- num_pksint
the number of peaks in the specified interval.
Returns
- intsarray_like
(m, ) array of integrated intensity values.
- hexrd.fitting.fitpeak.direct_pk_analysis(x, f, remove_bg=True, low_int=1.0, edge_pts=3, pts_per_meas=100)[source]
Analyze a single peak that is not well matched to any analytic functions
Parameters
- xarray_like
(n, ) ndarray of coordinate positions.
- farrauy_like
(n, ) ndarray of intensity measurements at coordinate positions x.
- remove_bgbool, optional
flag for linear background subtraction. The default is True.
- low_intfloat, optional
Value for area under a peak that defines a lower bound on S/N. The default is 1..
- edge_ptsint, optional
number of points at the edges of the data to use to calculated background. The default is 3.
- pts_per_measint, optional
number of interpolated points to place between measurement values. The default is 100.
Returns
- parray_like
array of values containing the integrated intensity, center of mass, and FWHM of the peak.
- hexrd.fitting.fitpeak.estimate_mpk_parms_1d(pk_pos_0, x, f, pktype='pvoigt', bgtype='linear', fwhm_guess=None, center_bnd=0.02, amp_lim_mult=[0.1, 10.0], fwhm_lim_mult=[0.5, 2.0])[source]
Generate function-specific estimate for multi-peak parameters.
Parameters
- pk_pos_0TYPE
DESCRIPTION.
- xTYPE
DESCRIPTION.
- fTYPE
DESCRIPTION.
- pktypeTYPE, optional
DESCRIPTION. The default is ‘pvoigt’.
- bgtypeTYPE, optional
DESCRIPTION. The default is ‘linear’.
- fwhm_guessTYPE, optional
DESCRIPTION. The default is 0.07.
- center_bndTYPE, optional
DESCRIPTION. The default is 0.02.
- amp_lim_multTYPE, optional
Multiplier for bounds for AMP fitting [LB, UB]. The default is [0.1, 10.0].
- fwhm_lim_multTYPE, optional
Multiplier for bounds for FWHM fitting [LB, UB]. The default is [0.5, 2.0].
Returns
- p0TYPE
DESCRIPTION.
- bndsTYPE
DESCRIPTION.
- hexrd.fitting.fitpeak.estimate_pk_parms_1d(x, f, pktype='pvoigt')[source]
Gives initial guess of parameters for analytic fit of one dimensional peak data.
Required Arguments: x – (n) ndarray of coordinate positions f – (n) ndarray of intensity measurements at coordinate positions x pktype – string, type of analytic function that will be used to fit the data, current options are “gaussian”, “lorentzian”, “pvoigt” (psuedo voigt), and “split_pvoigt” (split psuedo voigt)
Outputs: p – (m) ndarray containing initial guesses for parameters for the input peaktype (see peak function help for what each parameters corresponds to)
Notes
!!! LINEAR BACKGROUND ONLY !!! ASSUMES ANGULAR SPECTRA IN RADIANS (DCS PARAMS)
- hexrd.fitting.fitpeak.estimate_pk_parms_2d(x, y, f, pktype)[source]
Calculate initial parameter values for 2-dimensional peak fitting.
Parameters
- xarray_like
(n, ) ndarray of coordinate positions for dimension 1 (numpy.meshgrid formatting).
- yarray_like
(n, ) ndarray of coordinate positions for dimension 2 (numpy.meshgrid formatting).
- farray_like
(n, ) ndarray of intensity measurements at coordinate positions x and y.
- pktypestr
type of analytic function that will be used to fit the data; current options are “gaussian”, “gaussian_rot” (gaussian with arbitrary axes) and “split_pvoigt_rot” (split psuedo voigt with arbitrary axes).
Returns
p – (m) ndarray containing initial guesses for parameters for the input peak type (see peakfunction help for more information).
- hexrd.fitting.fitpeak.fit_mpk_parms_1d(p0, x, f0, pktype, num_pks, bgtype=None, bnds=None)[source]
Fit MULTIPLE 1d analytic functions to diffraction data.
Parameters
- p0array_like (m x u + v, )
list of peak parameters for number of peaks where m is the number of parameters per peak (“gaussian” and “lorentzian” - 3, “pvoigt” - 4, “split_pvoigt” - 5), v is the number of parameters for chosen bgtype.
- xarray_like
(n, ) ndarray of evaluation coordinate positions.
- f0TYPE
DESCRIPTION.
- pktypeTYPE
DESCRIPTION.
- num_pksint
The number of peaks in the interval defined by x.
- bgtypestring, optional
bBckground function flag. Available options are “constant”, “linear”, and “quadratic”. The default is None.
- bndsarray_like, optional
DESCRIPTION. The default is None.
Returns
- array
(m x u, ) fit peak parameters where m is the number of parameters per peak (“gaussian” and “lorentzian” - 3, “pvoigt” - 4, “split_pvoigt” - 5).
- hexrd.fitting.fitpeak.fit_pk_obj_1d(p, x, f0, pktype)[source]
Return residual between specified peak function and data.
Parameters
- pTYPE
DESCRIPTION.
- xTYPE
DESCRIPTION.
- f0TYPE
DESCRIPTION.
- pktypeTYPE
DESCRIPTION.
Returns
- resdTYPE
DESCRIPTION.
Notes
- !!! These objective functions all have a linear background added in their
definition in peakfuncs
- hexrd.fitting.fitpeak.fit_pk_parms_1d(p0, x, f, pktype='pvoigt')[source]
Performs least squares fit to find parameters for 1d analytic functions fit to diffraction data
Required Arguments: p0 – (m) ndarray containing initial guesses for parameters
for the input peaktype
x – (n) ndarray of coordinate positions f – (n) ndarray of intensity measurements at coordinate positions x pktype – string, type of analytic function that will be used to
fit the data,
current options are “gaussian”,”lorentzian”,”pvoigt” (psuedo voigt), and “split_pvoigt” (split psuedo voigt)
Outputs: p – (m) ndarray containing fit parameters for the input peaktype (see peak function help for what each parameters corresponds to)
Notes: 1. Currently no checks are in place to make sure that the guess of parameters has a consistent number of parameters with the requested peak type
- hexrd.fitting.fitpeak.fit_pk_parms_2d(p0, x, y, f, pktype)[source]
Do least squares fit for 2-d profile functions.
Parameters
- p0array_like
(m, ) ndarray containing initial guesses for parameters for the input peak type.
- xarray_like
(n, ) ndarray of coordinate positions for dimension 1 (numpy.meshgrid formatting).
- yarray_like
(n, ) ndarray of coordinate positions for dimension 2 (numpy.meshgrid formatting).
- farray_like
(n, ) ndarray of intensity measurements at coordinate positions x and y.
- pktypestr
type of analytic function that will be used to fit the data; current options are “gaussian”, “gaussian_rot” (gaussian with arbitrary axes) and “split_pvoigt_rot” (split psuedo voigt with arbitrary axes).
Returns
- parray_like
(m, ) ndarray containing optimal parameters for the input peak type.
Notes
See peak function help for what each parameter corresponds to.
!!! Currently no checks are in place to make sure that the guess of !!! parameters has a consisten number of parameters with the requested !!! peak type
- hexrd.fitting.fitpeak.goodness_of_fit(f, f0)[source]
Calculate two scalar measures of goodness of fit.
Parameters
- farray_like
(n, ) ndarray of intensity measurements at coordinate positions.
- f0array_like
(n,) ndarray of fit intensity values at coordinate positions.
Returns
- Rfloat
goodness of fit measure which is sum(error^2)/sum(meas^2).
- Rwfloat
goodness of fit measure weighted by intensity sum(meas*error^2)/sum(meas^3).