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.


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.


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.


P-length list of amplitudes.


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.


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


List of N-tuples indicating peak centers.


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


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


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.


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


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


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.


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.