| Title: | Continuous Wavelet Transformation for Spectroscopy |
|---|---|
| Description: | Fast application of Continuous Wavelet Transformation ('CWT') on time series with special attention to spectroscopy. It is written using data.table and 'C++' language and in some functions it is possible to use parallel processing to speed-up the computation over samples. Currently, only the second derivative of a Gaussian wavelet function is implemented. |
| Authors: | J. Antonio Guzmán Q. [cre, aut, cph] (ORCID: <https://orcid.org/0000-0002-0721-148X>) |
| Maintainer: | J. Antonio Guzmán Q. <antguz06@gmail.com> |
| License: | GPL (>= 3) |
| Version: | 0.2.3 |
| Built: | 2026-10-06 11:55:29 UTC |
| Source: | https://github.com/antguz/cwt |
Fast application of Continuous Wavelet Transformation on time series with special attention to spectroscopy. It is written using 'data.table' and 'C++' language and in some functions it is possible to use parallel processing to speed-up the computation over samples.
Maintainer: J. Antonio Guzmán Q. antguz06@gmail.com (ORCID) [copyright holder]
Authors:
J. Antonio Guzmán Q. antguz06@gmail.com (ORCID) [copyright holder]
Useful links:
Compute a 1D continuous wavelet transformation using 2st order derivative Gaussian wavelet.
cwt(t, scales, variance = 1, summed_wavelet = FALSE, threads = 1L)cwt(t, scales, variance = 1, summed_wavelet = FALSE, threads = 1L)
t |
A |
scales |
A positive |
variance |
A positive |
summed_wavelet |
If |
threads |
An |
If summed_wavelet = TRUE, it returns a data.table where
columns are the sum of wavelet scales. If summed_wavelet = FALSE, it
returns an array (i.e., time, samples, and scales).
J. Antonio Guzmán Q.
time_series <- sin(seq(0, 20 * pi, length.out = 100)) # Using a numeric vector cwt(t = time_series, scales = c(1, 2, 3, 4, 5), summed_wavelet = FALSE) cwt(t = time_series, scales = c(1, 2, 3, 4, 5), summed_wavelet = TRUE) # Using a matrix times <- 100 frame <- matrix(rep(time_series, times), nrow = times, byrow = TRUE) cwt(t = frame, scales = c(1, 2, 3, 4, 5), summed_wavelet = FALSE) cwt(t = frame, scales = c(1, 2, 3, 4, 5), summed_wavelet = TRUE)time_series <- sin(seq(0, 20 * pi, length.out = 100)) # Using a numeric vector cwt(t = time_series, scales = c(1, 2, 3, 4, 5), summed_wavelet = FALSE) cwt(t = time_series, scales = c(1, 2, 3, 4, 5), summed_wavelet = TRUE) # Using a matrix times <- 100 frame <- matrix(rep(time_series, times), nrow = times, byrow = TRUE) cwt(t = frame, scales = c(1, 2, 3, 4, 5), summed_wavelet = FALSE) cwt(t = frame, scales = c(1, 2, 3, 4, 5), summed_wavelet = TRUE)
It resample spectra data using Full Width Half Maximum (FWHM).
resampling_FWHM(spectra, wavelengths, new_wavelengths, FWHM, threads = 1L)resampling_FWHM(spectra, wavelengths, new_wavelengths, FWHM, threads = 1L)
spectra |
A |
wavelengths |
A |
new_wavelengths |
A |
FWHM |
A |
threads |
An |
It returns a data.table with the resampled spectra, where columns
are the new bands and rows are samples. New bands whose FWHM window falls
partially outside the range of wavelengths are returned as NA.
J. Antonio Guzmán Q.
mean <- 50 sd1 <- 5 sd2 <- 10 n <- 100 test <- matrix(c(dnorm(1:n, mean = mean, sd = sd1), dnorm(1:n, mean = mean, sd = sd2)), nrow = 2, byrow = TRUE) current_bands <- 1:n new_bands <- seq(10, 90, by = 5) FHWM <- rep(5, length(new_bands)) resampling_FWHM(spectra = test, wavelengths = current_bands, new_wavelengths = new_bands, FWHM = FHWM)mean <- 50 sd1 <- 5 sd2 <- 10 n <- 100 test <- matrix(c(dnorm(1:n, mean = mean, sd = sd1), dnorm(1:n, mean = mean, sd = sd2)), nrow = 2, byrow = TRUE) current_bands <- 1:n new_bands <- seq(10, 90, by = 5) FHWM <- rep(5, length(new_bands)) resampling_FWHM(spectra = test, wavelengths = current_bands, new_wavelengths = new_bands, FWHM = FHWM)