pyspectools.fast package¶
Submodules¶
pyspectools.fast.lineshapes module¶
-
pyspectools.fast.lineshapes.
first_deriv_lorentzian
()¶ Cython implementation of the first derivative lineshape of a Lorenz- tian function.
- Parameters
x (np.ndarray) – Numpy 1D array containing x values to evaluate
gamma, A (x0,) – Parameters of the first-derivative Lorentzian function
- Returns
y – Numpy 1D array containing y values for the first-derivative
- Return type
np.ndarray
-
pyspectools.fast.lineshapes.
gaussian
()¶ Cython implementation of a Gaussian line shape. This function is designed to minimize Python interpreter interaction; everything except for the x values are C types, which should hopefully make it run fast.
This function holds the advantage of static typing over the NumPy implementation in the pyspectools.lineshapes module. From rudimentary timing tests, the best improvement is seen for arrays <1000 elements, from which the NumPy version is faster.
- Parameters
x (np.ndarray) – 1D array containing x values to evaluate
A (float) – Amplitude of the Gaussian function
x0 (float) – Center value for the Gaussian function
w (float) – Sigma of the Gaussian function
- Returns
y – Numpy 1D array containing the x values.
- Return type
np.ndarray
-
pyspectools.fast.lineshapes.
lorentzian
()¶ Cython function for a Lorenztian distribution. Same as the corres- ponding Gaussian implementation, this function is written to minimize Python interpreter interaction if possible to optimize for speed.
- Parameters
x (np.ndarray) – Numpy 1D array of x values to evaluate on
gamma, A (x0,) – Parameters for the lorenztian function.
- Returns
y – Numpy 1D array with y(x|x0, gamma, A)
- Return type
np.ndarray
-
pyspectools.fast.lineshapes.
multi_gaussian
()¶ Sum of multiple Gaussian distributions written in Cython. This version of the code is written so that there should be no overhead associated with NumPy within the loop. The array access is completely within a single function, rather than repeatedly calling the gaussian function. In theory this should be a faster implementation.
- Parameters
x (array_like) – 1D Numpy array of floats corresponding to the x values to evaluate
x0, w (A,) – 1D Numpy array of floats corresponding to the amplitudes, centers, and widths of the Gaussians
- Returns
y – Numpy 1D array of Y(X|A,X0,W)
- Return type
array_like
-
pyspectools.fast.lineshapes.
pair_gaussian
()¶ Pair Gaussian function. :param x: Numpy 1D array of X values to evaluate the pair of Gaussians on :type x: array_like :param A1, A2: Amplitudes of the two Gaussians :type A1, A2: float :param x0: Center-of-mass for the two Gaussians :type x0: float :param w: Width of the two gaussians :type w: float :param xsep: Separation in units of x that pushes the two Gaussians from the center-of-mass :type xsep: float
- Returns
y – Numpy 1D array of Y values
- Return type
array_like
-
pyspectools.fast.lineshapes.
sec_deriv_lorentzian
()¶ Cython implementation of the second derivative lineshape of a Lorenz- tian function.
- Parameters
x (np.ndarray) – Numpy 1D array containing x values to evaluate
gamma, A (x0,) – Parameters of the first-derivative Lorentzian function
- Returns
y – Numpy 1D array containing y values for the second-derivative
- Return type
np.ndarray
pyspectools.fast.routines module¶
-
pyspectools.fast.routines.
isin_array
()¶ Function that will make piece-by-piece comparisons between two arrays, a and b. Every element in a will be checked for in b, and if there is an entry sufficiently close, it will return a True value for that element.
Conceptually, this function is similar to np.isin(), although it allows for two different sized arrays. The resulting array will be length equal to a, while b can be larger or smaller than a.
- Parameters
a (1D array) – Numpy 1D array to check
b (1D array) – Numpy 1D array to check for
tol (float, optional) – Tolerance for proximity to check.
- Returns
check_array – Numpy 1D array of length equal to a, with boolean values corresponding to whether element of a is in b.
- Return type
1D array