Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Derivatives

This package contains two common algorithms for calculating derivatives in spectroscopy:

Savitzky-Golay derivative

Savitzky-Golay derivative is a preprocessing technique in spectroscopy that calculates the derivative of a spectrum by fitting a polynomial to a window of adjacent points and calculating the derivative of the polynomial.

Arguments:

Argument Description Type Default
window_size The length of the window. Must be an odd integer number. int 5
polynomial_order The order of the polynomial used to fit the samples. Must be less than window_size. int 2
derivative_order The order of the derivative to compute. int 1
mode The mode of the boundary. Options are 'nearest', 'constant', 'reflect', 'wrap', 'mirror', 'interp'. See the scipy.savgol_filter for more information. str 'nearest'

Usage example:

from chemotools.derivative import SavitzkyGolay

sg = SavitzkyGolay(window_size=15, polynomial_order=2, derivate_order=1)
spectra_derivative = sg.fit_transform(spectra)

Plotting example:

William Norris derivative

William Norris derivative is a preprocessing technique in spectroscopy that calculates the derivative of a spectrum using finite differences.

Arguments:

Argument Description Type Default
window_size The length of the window. Must be an odd integer number. int 5
gap_size The number of points between the first and second points of the window. int 3
derivative_order The order of the derivative to compute. int 1
mode The mode of the boundary. Options are 'nearest', 'constant', 'reflect', 'wrap', 'mirror', 'interp'. See the scipy.ndimage.convolve for more information. str 'nearest'

Usage example:

from chemotools.derivative import NorrisWilliams

nw = NorrisWilliams(window_size=15, gap_size=3, derivative_order=1)
spectra_derivative =   nw.fit_transform(spectra)

Plotting example: