nmrglue.analysis.linesh.fit_spectrum

nmrglue.analysis.linesh.fit_spectrum(spectrum, lineshapes, params, amps, bounds, ampbounds, centers, rIDs, box_width, error_flag, verb=True, **kw)[source]

Fit a NMR spectrum by regions which contain one or more peaks.

Parameters
spectrumarray_like

NMR data. ndarray or emulated type, must be slicable.

lineshape :list

List of lineshapes by label (str) or a lineshape class. See fit_NDregion() for details.

paramslist

P-length list (P is the number of peaks in region) of N-length lists of tuples where each each tuple is the optimiztion starting parameters for a given peak and dimension lineshape.

ampslist

P-length list of amplitudes.

boundslist

List of bounds for parameter of same shape as params. If none of the parameters in a given dimension have limits None can be used, otherwise each dimension should have a list or tuple of (min,max) or None for each parameter. min or max may be None when there is no bounds in a given direction.

ampboundslist

P-length list of bounds for the amplitude with format similar to bounds.

centerslist

List of N-tuples indicating peak centers.

rIDslist

P-length list of region numbers. Peak with the same region number are fit together.

box_widthtuple

Tuple of length N indicating box width to add and subtract from peak centers to form regions around peak to fit.

error_flagbool

True to estimate errors for each lineshape parameter and amplitude.

verbbool, optional

True to print a summary of each region fit, False (the default) supresses all printing.

**kwoptional

Additional keywords passed to the scipy.optimize.leastsq function.

Returns
params_bestlist

Optimal values for lineshape parameters with same format as params input parameter.

amp_bestlist

List of optimal peak amplitudes.

param_errlist, only returned when error_flag is True

Estimated lineshape parameter errors with same format as params.

amp_errlist, only returned when error_flag is True

Estimated peak amplitude errors.

ierslist

List of interger flag from scipy.optimize.leastsq indicating if the solution was found for a given peak. 1,2,3,4 indicates that a solution was found. Other indicate an error.