Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

shiftSpectra2D

Shift the Spectra in a Spectra2D Object


Description

Shift the spectra in a Spectra2D object manually. During shifting, some rows or columns are thrown away and new rows or columns are introduced. These new entries may be filled with zeros, or noise from the original spectra.

  • (+) shiftF2 - shift right: trim right, fill left

  • (-) shiftF2 - shift left: trim left, fill right

  • (+) shiftF1 - shift up: trim top, fill bottom

  • (-) shiftF1 - shift down: trim bottom, fill top

Usage

shiftSpectra2D(
  spectra,
  which = NULL,
  shiftF2 = 0L,
  shiftF1 = 0L,
  fill = "noise"
)

Arguments

spectra

An object of S3 class Spectra2D.

which

An integer specifying which spectra to shift. May be a vector.

shiftF2

Integer. The number of data points to shift along the F2 dimension. See Details.

shiftF1

As per shiftF2, but for the F1 dimension.

fill

Aligning spectra requires that at least some spectra be shifted left/right and up/down. When a spectrum is shifted, spaces are opened that must be filled with something:

  • If fill = "zeros" the spaces are filled with zeros.

  • If fill = "noise" the spaces are filled with an estimate of the noise from the original spectrum.

Value

An object of S3 class Spectra2D.

Author(s)

Bryan A. Hanson, DePauw University.

Examples

data(MUD2)
# Show the first two spectra, overlaid

mylvls <- seq(5, 35, 5)
plotSpectra2D(MUD2,
  which = 1:2, lvls = LofL(mylvls, 2),
  cols = LofC(c("red", "black"), 2, length(mylvls), 2),
  main = "MUD2 Sample 1 (black) & Sample 2 (red)"
)

# Now shift Sample 2
MUD2s <- shiftSpectra2D(MUD2, which = 2, shiftF1 = -2)
plotSpectra2D(MUD2s,
  which = 1:2, lvls = LofL(mylvls, 2),
  cols = LofC(c("red", "black"), 2, length(mylvls), 2),
  main = "MUD2 Sample 1 (black) & Sample 2 (red)\n(samples now aligned/overlap)"
)

ChemoSpec2D

Exploratory Chemometrics for 2D Spectroscopy

v0.4.187
GPL-3
Authors
Bryan A. Hanson [aut, cre] (<https://orcid.org/0000-0003-3536-8246>)
Initial release
2021-03-15

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.