interpolate_wl: Map spectra to new wavelength values.

View source: R/spct.integrate.r

interpolate_wlR Documentation

Map spectra to new wavelength values.

Description

This function returns the result of interpolating spectral data from the original set of wavelengths to a new one.

Usage

interpolate_wl(x, w.length.out, fill, length.out, ...)

## Default S3 method:
interpolate_wl(x, w.length.out, fill, length.out, ...)

## S3 method for class 'generic_spct'
interpolate_wl(x, w.length.out = NULL, fill = NA, length.out = NULL, ...)

## S3 method for class 'generic_mspct'
interpolate_wl(
  x,
  w.length.out = NULL,
  fill = NA,
  length.out = NULL,
  ...,
  .parallel = FALSE,
  .paropts = NULL
)

Arguments

x

an R object

w.length.out

numeric vector of wavelengths (nm)

fill

a value to be assigned to out of range wavelengths

length.out

numeric value

...

not used

.parallel

if TRUE, apply function in parallel, using parallel backend provided by foreach

.paropts

a list of additional options passed into the foreach function when parallel computation is enabled. This is important if (for example) your code relies on external data or packages: use the .export and .packages arguments to supply them so that all cluster nodes have the correct environment set up for computing.

Details

If length.out it is a numeric value, then gives the number of rows in the output, if it is NULL, the values in the numeric vector w.length.out are used. If both are not NULL then the range of w.length.out and length.out are used to generate a vector of wavelength. A value of NULL for fill prevents extrapolation.

Value

A new spectral object of the same class as argument spct.

Methods (by class)

  • interpolate_wl(default): Default for generic function

  • interpolate_wl(generic_spct): Interpolate wavelength in an object of class "generic_spct" or derived.

  • interpolate_wl(generic_mspct): Interpolate wavelength in an object of class "generic_mspct" or derived.

Note

The default fill = NA fills extrapolated values with NA. Giving NULL as argument for fill deletes wavelengths outside the input data range from the returned spectrum. A numerical value can be also be provided as fill. This function calls interpolate_spectrum for each non-wavelength column in the input spectra object.

Examples

interpolate_wl(sun.spct, 400:500, NA)
interpolate_wl(sun.spct, 400:500, NULL)
interpolate_wl(sun.spct, seq(200, 1000, by=0.1), 0)
interpolate_wl(sun.spct, c(400,500), length.out=201)


photobiology documentation built on Oct. 21, 2023, 1:06 a.m.