Reduce the resolution of Spectra

reduce_resolution(x, ...)

# S3 method for collection
reduce_resolution(x, k, ...)

Arguments

x

Acollection object to normalize

...

further arguments passed to or from other methods(not currently used).

k

an integer expressing the reduction in resolution. For example k=2will keep every second point, k=3 every third.

Note

Reducing resolution of the spectra before computation intensive steps like AI binning can significantly improve their speed, while minimally affecting the output.

You should however be careful with the choice of k and in the caase of subsequent binning make sure to remove the outter limits of the returned results as these will not match the outter limits of the full resolution spectra.

Examples

library(tidySpectR) # Speeding up AI binning reduced <- reduce_resolution(fa_nmr, k=2) binned <- bucket_aibin(extract(reduced,0.5, 7.2), 0.5, mask(reduced, -Inf, 8)) breaks <- pull_breaks(binned) # last break does not match spectra limit, leaving it so would create # a bin at the ends of the spectra breaks[1]
#> [1] 0.5039788
breaks[length(breaks)]
#> [1] 7.203979
pull_limits(extract(fa_nmr, 0.5, 7.2))
#> [1] 0.4999788 7.2039788
breaks <- breaks[-1] # remove first break breaks <- breaks[-length(breaks)] # remove last break processed <- bucket_from_breaks(extract(fa_nmr, 0.5, 7.2), breaks) # Full resolution bucketted spectra processed
#> Spectra collection containing 6 entries. #> Number of bins: 80 #> Limits: 0.4999788 7.203979 #> Labels: conventional organic #> #> Processing: #> Step 1 / 2 : extract #> Step 2 / 2 : cutsom_bucketting