interpolate_spectra: Interpolates a dataframe of spectra with a wavelength column.

View source: R/lighting_values.R

interpolate_spectraR Documentation

Interpolates a dataframe of spectra with a wavelength column.

Description

This function provides the all recommended interpolation method for spectra. This includes linear, spline and sprague interpolation.

Usage

interpolate_spectra(
  spectra,
  wl_out = seq(380, 780, 5),
  method = "linear",
  str_wavelength = NULL,
  tolerance = 1e-14
)

Arguments

spectra

is a dataframe of spectra in wide table format including a wavelength column in nm.

wl_out

defines the output wavelength range and interval in nm for interpolation. Default: wl_out = seq(380, 780, 5)

method

specifies the interpolation method of the functions approx and spline. Default: "linear". Spline interpolation: "fmm", "periodic", "natural", "monoH.FC" and "hyman". Sprague interpolation after \insertCiteWestland2015lighting: "sprague"

str_wavelength

Define name of wavelength column in spectra dataframe. Default: str_wavelength = NULL. If entry is NULL, then the name of the first column from dataframe spectra will chosen as str_wavelength.

tolerance

used for sprague interpolation wrapper to correct numerical differentiation errors. Important to calculate the interpolation factor f. Default: 1e-14.

Details

In Details - Not tested for wavelength interval < 1 nm. Linear interpolating: extrapolation results into 0 values.

Value

returns a dataframe of interpolated spectra in wide table format specified by wl_out.

Author(s)

Dr. William Truong

Examples

# Create spectrum planckian radiator using black body temperature in K
wavelength <- seq(380, 780, 5)
planck2700 <- planck_law(seq(380, 780, 5), 2700)
planck5000 <- planck_law(seq(380, 780, 5), 5000)

spectra <- tibble::tibble(wavelength, planck2700, planck5000)
interpolate_spectra(spectra, seq(380, 780, 1), method = "linear")
interpolate_spectra(spectra, seq(380, 780, 1), method = "fmm")
interpolate_spectra(spectra, seq(400, 700, 1), method = "sprague")

Wei-Lim/lighting documentation built on Oct. 17, 2023, 3:20 p.m.