spectral
This module offers utilities for processing data cubes and related operations.
Module Overview
- wizard._processing.spectral.smooth_savgol(spectrum, window_length=11, polyorder=2)[source]
Apply a Savitzky-Golay filter to smooth a given spectrum.
- Parameters:
spectrum (numpy.ndarray) – Input spectrum to be smoothed.
window_length (int, optional) – Length of the filter window, must be a positive odd integer.
polyorder (int, optional) – Order of the polynomial used to fit the samples.
- Returns:
Smoothed spectrum.
- Return type:
numpy.ndarray
- wizard._processing.spectral.smooth_moving_average(spectrum, window_size=5)[source]
Apply a moving average filter to smooth a given spectrum.
- Parameters:
spectrum (numpy.ndarray) – Input spectrum to be smoothed.
window_size (int, optional) – Size of the moving window.
- Returns:
Smoothed spectrum.
- Return type:
numpy.ndarray
- wizard._processing.spectral.smooth_butter_lowpass(spectrum, cutoff=0.1, fs=1.0, order=5)[source]
Apply a Butterworth low-pass filter to the input spectrum.
- Parameters:
spectrum (numpy.ndarray) – Input spectrum to be filtered.
cutoff (float, optional) – Cutoff frequency of the filter.
fs (float, optional) – Sampling frequency of the input signal.
order (int, optional) – Order of the filter.
- Returns:
Filtered spectrum.
- Return type:
numpy.ndarray
- wizard._processing.spectral.spec_baseline_als(spectrum, lam, p, niter=10)[source]
Perform baseline correction using Asymmetric Least Squares Smoothing.
- Parameters:
spectrum (numpy.ndarray) – Input spectrum to be smoothed.
lam (float) – Smoothness parameter, typically between 10^2 and 10^9.
p (float) – Asymmetry parameter, usually between 0.001 and 0.1.
niter (int, optional) – Number of iterations.
- Returns:
Smoothed baseline.
- Return type:
numpy.ndarray
- wizard._processing.spectral.calculate_modified_z_score(spectrum)[source]
Calculate the modified z-score of a data cube by computing the difference in intensity along the first axis.
- Parameters:
spectrum (numpy.ndarray) – spectrum
- Returns:
Modified z-score representing the difference in intensity along the first axis.
- Return type:
numpy.ndarray
- wizard._processing.spectral.get_ratio_two_specs(spectrum, waves, wave_1, wave_2)[source]
Calculate the ratio between two selected wavelengths in the spectrum.
- Parameters:
spectrum (numpy.ndarray) – Main spectrum from which the wavelengths will be selected.
waves (numpy.ndarray) – Array of wavelengths for the given spectrum.
wave_1 (int) – First selected wavelength.
wave_2 (int) – Second selected wavelength.
- Returns:
Ratio of the two selected wavelengths.
- Return type:
numpy.ndarray
- wizard._processing.spectral.get_sub_tow_specs(spectrum, waves, wave_1, wave_2)[source]
Subtract two selected wavelengths from a spectrum.
- Parameters:
spectrum (numpy.ndarray) – Main spectrum from which the wavelengths will be selected.
waves (numpy.ndarray) – Array of wavelengths for the given spectrum.
wave_1 (int) – First selected wavelength.
wave_2 (int) – Second selected wavelength.
- Returns:
Difference of the two selected wavelengths.
- Return type:
numpy.ndarray
- wizard._processing.spectral.signal_to_noise(spectrum)[source]
Calculate the signal-to-noise ratio (SNR) of a given spectrum.
- Parameters:
spectrum (numpy.ndarray) – 1D array representing the intensity values of the spectrum.
- Returns:
Signal-to-noise ratio (SNR) value in decibels (dB).
- Return type:
float
- wizard._processing.spectral.del_leading_zeros(spectrum, idx=-1, auto_offset=5)[source]
Remove leading zeros from a spectrum array.
- Parameters:
spectrum (numpy.ndarray) – Input spectrum array.
idx (int, optional) – Index value for cutting.
auto_offset (int, optional) – Number of values to be deleted in auto mode (idx + auto_offset).
- Returns:
Spectrum array with leading zeros removed.
- Return type:
numpy.ndarray
- wizard._processing.spectral.del_last_zeros(spectrum, idx=-1, auto_offset=5)[source]
Remove trailing zeros from a spectrum array.
- Parameters:
spectrum (numpy.ndarray) – Input spectrum array.
idx (int, optional) – Index value for cutting.
auto_offset (int, optional) – Number of values to be deleted in auto mode (idx + auto_offset).
- Returns:
Spectrum array with trailing zeros removed.
- Return type:
numpy.ndarray