nmrglue.analysis.linesh.fit_NDregion

nmrglue.analysis.linesh.fit_NDregion(region, lineshapes, params, amps, bounds=None, ampbounds=None, wmask=None, error_flag=False, **kw)[source]

Fit a N-dimensional region.

Parameters :

region : ndarray

Region of a NMR data to fit.

lineshape :list :

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

params : list

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.

amps : list

P-length list of amplitudes.

bounds : list

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.

ampbounds : list

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

wmask : ndarray, optional

Array with same shape as region which is used to weight points in the error calculation, typically a boolean array is used to exclude certain points in the region. Default of None will include all points in the region equally in the error calculation.

centers : list

List of N-tuples indicating peak centers.

error_flag : bool

True to estimate errors for each lineshape parameter and amplitude.

**kw : optional

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

Returns :

params_best : list

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

amp_best : list

List of optimal peak amplitudes.

param_err : list, only returned when error_flag is True

Estimated lineshape parameter errors with same format as params.

amp_err : list, only returned when error_flag is True

Estimated peak amplitude errors.

iers : list

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.

Notes

The lineshape parameter:

Elements of the lineshape parameter list can be string indicating the lineshape of given dimension or an instance of a lineshape class which provide a sim method which takes two arguments, the first being the length of the lineshape the second being a list of lineshape parameters, and returns a simulated lineshape as well as a nparam method which when given the length of lineshape returns the number of parameters needed to describe the lineshape. Currently the following strings are allowed:

  • ‘g’ or ‘gauss’ Gaussian (normal) lineshape.
  • ‘l’ or ‘lorentz’ Lorentzian lineshape.
  • ‘v’ or ‘voigt’ Voigt lineshape.
  • ‘pv’ or ‘pvoight’ Pseudo Voigt lineshape
  • ‘s’ or ‘scale’ Scaled lineshape.

The first four lineshapes (Gaussian, Lorentzian, Voigt and Pseudo Voigt) all take a FWHM scale parameter.

The following are all valid lineshapes parameters for a 2D Gaussian peak:

  • [‘g’,’g’]
  • [‘gauss’,’gauss’]
  • [ng.lineshapes1d.gauss(),ng.lineshapes1d.gauss()]

Previous topic

nmrglue.analysis.linesh.fit_spectrum

Next topic

nmrglue.analysis.linesh.sim_NDregion

This Page