baselines: Polynomial Baseline Fitting These functions fit polynomal...

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Both functions fit polynomials to be used as baselines. If apply.to is NULL, a hyperSpec object with the polynomial coefficients is returned, otherwise the polynomials are evaluated on the spectral range of apply.to.

spc.fit.poly.below tries to fit the baseline on appropriate spectral ranges of the spectra in fit.to. For details, see the vignette ("baseline").

Usage

1
2
3
4
5
6
spc.fit.poly(fit.to, apply.to = NULL, poly.order = 1,
  offset.wl = !(is.null(apply.to)))

spc.fit.poly.below(fit.to, apply.to = fit.to, poly.order = 1,
  npts.min = max(round(nwl(fit.to) * 0.05), 3 * (poly.order + 1)),
  noise = 0, offset.wl = FALSE, debuglevel = hy.getOption("debuglevel"))

Arguments

fit.to

hyperSpec object on which the baselines are fitted

apply.to

hyperSpec object on which the baselines are evaluted If NULL, a hyperSpec object containing the polynomial coefficients rather than evaluted baselines is returned.

poly.order

order of the polynomial to be used

offset.wl

should the wavelength range be mapped to -> [0, delta wl]? This enhances numerical stability.

npts.min

minimal number of points used for fitting the polynomial

noise

noise level to be considered during the fit. It may be given as one value for all the spectra, or for each spectrum separately.

debuglevel

additional output: 1 show npts.min, 2 plots support points for 1st spectrum, 3 plots support points for all spectra.

Details

spc.fit.poly calculates the least squares fit of order poly.order to the complete spectra given in fit.to. Thus fit.to needs to be cut appropriately.

Value

hyperspec object containing the baselines in the spectra matrix, either as polynomial coefficients or as polynomials evaluted on the spectral range of apply.to

Author(s)

C. Beleites

See Also

vignette ("baseline", package = "hyperSpec")

see options for more on debuglevel

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: vignette ("baseline", package = "hyperSpec")

spc <- chondro [1 : 10]
baselines <- spc.fit.poly(spc [,, c (625 ~ 640, 1785 ~ 1800)], spc)
plot(spc - baselines)


baselines <- spc.fit.poly.below (spc)
plot (spc - baselines)

spc.fit.poly.below(chondro [1:3], debuglevel = 1)
spc.fit.poly.below(chondro [1:3], debuglevel = 2)
spc.fit.poly.below(chondro [1:3], debuglevel = 3, noise = sqrt (rowMeans (chondro [[1:3]])))

GegznaV/hyperSpec2 documentation built on Dec. 27, 2019, 9:43 a.m.