wl() returns the wavelength axis, wl<- sets it.

wl(x)

wl(x, label = NULL, digits = 6) <- value

Arguments

x

hyperSpec object

label

The label for the new wavelength axis. See initialize for details.

digits

handed to base::signif(). See details.

value

either a numeric containing the new wavelength vector, or a list with value$wl containing the new wavelength vector and value$label holding the corresponding label.

Value

a numeric vector hyperSpec object

Details

The wavelength axis of a hyperSpec object can be retrieved and replaced with wl() and wl<-, respectively.

When the wavelength axis is replaced, the colnames of x@data$spc are replaced by the rounded new wavelengths. digits specifies the how many significant digits should be used.

There are two ways to set the label of the new wavelength axis, see the examples. If no label is given, a warning will be issued.

Note

wl<- always sets the complete wavelength axis, without changing the columns of the spectra matrix. If you rather want to cut the spectral range, use extraction operator, for interpolation along the spectral axis see spc_loess() and for spectral binning use spc_bin().

See also

base::signif()

cutting the spectral range: 'Extract and replace'

interpolation along the spectral axis: spc_loess()

spectral binning: spc_bin()

Author

C. Beleites

Examples


wl(laser)
#>  [1] 404.5828 404.6181 404.6534 404.6887 404.7240 404.7592 404.7945 404.8298
#>  [9] 404.8651 404.9004 404.9357 404.9710 405.0063 405.0416 405.0768 405.1121
#> [17] 405.1474 405.1827 405.2180 405.2532 405.2885 405.3238 405.3591 405.3944
#> [25] 405.4296 405.4649 405.5002 405.5355 405.5707 405.6060 405.6413 405.6765
#> [33] 405.7118 405.7471 405.7823 405.8176
# convert from wavelength to frequency
plot(laser)

wl(laser, "f / Hz") <- 2.998e8 * wl(laser) * 1e9
plot(laser)


# convert from Raman shift to wavelength
# excitation was at 785 nm
plot(faux_cell[1])

wl(faux_cell) <- list(
  wl = 1e7 / (1e7 / 785 - wl(faux_cell)),
  label = expression(lambda / nm)
)
plot(faux_cell[1])