Presets¶
This module provides several preset functions that can be used to create model components and fit your data.
-
presets.calibratedD2O(x, q, volFraction, temp, amplitude=1.0)¶ Lineshape for D2O where the Lorentzian width was obtained from a measurement on IN6 at the ILL.
Parameters: - q (np.array or list) – Array of momentum transfer q values
- volFraction (float in [0, 1]) – Volume fraction of the D2O in the sample.
- temp (float) – Sample temperature used for the experiment.
- amplitude (float) – Amplitude of the D2O signal. The parameter to be fitted.
-
presets.conv_delta(x, comp1, comp2, params1, params2, **kwargs)¶ Convolution between a Lorentzian and a Gaussian
Parameters: - x (np.ndarray) – x-axis values
- comp1 (
Component) – First component to be used for the convolution. - comp2 (
Component) – Second component to be used for the convolution. - params1 (
Parameters) – Parameters for comp1. - params2 (
Parameters) – Parameters for comp2. - kwargs (dict) – Additional keyword arguments to pass to the method
processFuncArgs()for comp1 and comp2.
-
presets.conv_gaussian_gaussian(x, comp1, comp2, params1, params2, **kwargs)¶ Convolution between two Gaussians
Parameters: - x (np.ndarray) – x-axis values
- comp1 (
Component) – First component to be used for the convolution. - comp2 (
Component) – Second component to be used for the convolution. - params1 (
Parameters) – Parameters for comp1. - params2 (
Parameters) – Parameters for comp2. - kwargs (dict) – Additional keyword arguments to pass to the method
processFuncArgs()for comp1 and comp2.
-
presets.conv_linear(x, comp1, comp2, params1, params2, **kwargs)¶ Convolution with a linear model.
The linear model is assumed to be used for a background and is thus not convolved. The function returns simply the linear model. If comp2 is also a linear model, the two models are simply added.
Parameters: - x (np.ndarray) – x-axis values
- comp1 (
Component) – First component to be used for the convolution. - comp2 (
Component) – Second component to be used for the convolution. - params1 (
Parameters) – Parameters for comp1. - params2 (
Parameters) – Parameters for comp2. - kwargs (dict) – Additional keyword arguments to pass to the method
processFuncArgs()for comp1 and comp2.
-
presets.conv_lorentzian_gaussian(x, comp1, comp2, params1, params2, **kwargs)¶ Convolution between a Lorentzian and a Gaussian
Parameters: - x (np.ndarray) – x-axis values
- comp1 (
Component) – First component to be used for the convolution. - comp2 (
Component) – Second component to be used for the convolution. - params1 (
Parameters) – Parameters for comp1. - params2 (
Parameters) – Parameters for comp2. - kwargs (dict) – Additional keyword arguments to pass to the method
processFuncArgs()for comp1 and comp2.
-
presets.conv_lorentzian_lorentzian(x, comp1, comp2, params1, params2, **kwargs)¶ Convolution between two Lorentzians
Parameters: - x (np.ndarray) – x-axis values
- comp1 (
Component) – First component to be used for the convolution. - comp2 (
Component) – Second component to be used for the convolution. - params1 (
Parameters) – Parameters for comp1. - params2 (
Parameters) – Parameters for comp2. - kwargs (dict) – Additional keyword arguments to pass to the method
processFuncArgs()for comp1 and comp2.
-
presets.conv_lorentzian_rotations(x, comp1, comp2, params1, params2, **kwargs)¶ Convolution between a Lorentzian and rotationLorentzians
Parameters: - x (np.ndarray) – x-axis values
- comp1 (
Component) – First component to be used for the convolution. - comp2 (
Component) – Second component to be used for the convolution. - params1 (
Parameters) – Parameters for comp1. - params2 (
Parameters) – Parameters for comp2. - kwargs (dict) – Additional keyword arguments to pass to the method
processFuncArgs()for comp1 and comp2.
-
presets.conv_rotations_gaussian(x, comp1, comp2, params1, params2, **kwargs)¶ Convolution between a Lorentzian and a Gaussian
Parameters: - x (np.ndarray) – x-axis values
- comp1 (
Component) – First component to be used for the convolution. - comp2 (
Component) – Second component to be used for the convolution. - params1 (
Parameters) – Parameters for comp1. - params2 (
Parameters) – Parameters for comp2. - kwargs (dict) – Additional keyword arguments to pass to the method
processFuncArgs()for comp1 and comp2.
-
presets.delta(x, scale=1, center=0)¶ A Dirac delta centered on center
Parameters: - x (np.ndarray) – x-axis values, can be an array of any shape
- scale (int, float, np.ndarray) – scale factor for the normalized function
- center (int, float, np.ndarray) – position of the Dirac Delta in energy
-
presets.gaussian(x, scale=1, width=1, center=0)¶ A normalized Gaussian function
Parameters: - x (np.ndarray) – x-axis values, can be an array of any shape
- scale (int, float, np.ndarray) – scale factor for the normalized function
- width (int, np.ndarray) – width of the lineshape
- center (int, float, np.ndarray) – center from the zero-centered lineshape
-
presets.generalizedLorentzian(x, scale=1, alpha=1, tau=1, center=0)¶ A generalized Lorentzian function.
This is the Fourier transform of the Mittag-Leffler function. See [1].
References
[1] https://doi.org/10.1063/1.5121703
-
presets.kww(x, scale=1, beta=2, tau=1, center=0)¶ The Fourier transform of the stretched exponential function.
Parameters: - x (np.ndarray) – Values for the x-axis, can be an array of any shape
- scale (int, float, np.ndarray) – Scale factor for the normalized function
- beta (int, float) – Value for power of the exponential
- tau (int, float, np.ndarray) – Characteristic relaxation time.
- center (int, float, np.ndarray) – Center from the zero-centered lineshape
-
presets.linear(x, a=0.0, b=1.0)¶ A linear model of the form \(a x + b\)
-
presets.lorentzian(x, scale=1, width=1, center=0)¶ A normalized Lorentzian function.
Parameters: - x (np.ndarray) – x-axis values, can be an array of any shape
- scale (int, float, np.ndarray) – scale factor for the normalized function
- width (int, np.ndarray) – width of the lineshape
- center (int, float, np.ndarray) – center from the zero-centered lineshape
-
presets.rotations(x, q, scale=1, width=1, center=0)¶ A sum of normalized Lorentzian functions for rotations.
Parameters: - x (np.ndarray) – x-axis values, can be an array of any shape
- q (np.ndarray) – Values for the momentum transfers q
- scale (int, float, np.ndarray) – scale factor for the normalized function
- width (int, np.ndarray) – width of the lineshape
- center (int, float, np.ndarray) – center from the zero-centered lineshape
-
presets.voigt(x, scale=1, sigma=1, gamma=1, center=0)¶ A normalized Voigt profile.
Parameters: - x (np.ndarray) – Values for the x-axis, can be an array of any shape
- scale (int, float, np.ndarray) – Scale factor for the normalized function
- sigma (int, float, np.ndarray) – Line width of the Gaussian component.
- gamma (int, float, np.ndarray) – Line width of the Lorentzian component.
- center (int, float, np.ndarray) – Center from the zero-centered lineshape