spectra_to_spectrace: Convert spectrum to Spectrace-like spectrum

View source: R/spectra_to_spectrace.R

spectra_to_spectraceR Documentation

Convert spectrum to Spectrace-like spectrum

Description

This function converts a spectrum to the normalized spectrum as Spectrace would "see" it. For this, the original spectrum is convolved with the Spectrace response curves of each channel and then normalized. By default the resulting spectrum is interpolated back to the original spectrum's resolution, but a custom resolution or no interpolation can be selected as well.

Usage

spectra_to_spectrace(
  spectralData,
  output_resolution = c("original", "spectrace", "1nm", "5nm"),
  interp_method = c("pchip", "linear"),
  normalize = TRUE
)

Arguments

spectralData

Data frame containing the spectral data in reach row with wavelength as column names (e.g. "380nm", "385nm", ..., "780nm"). The wavelengths must be between 380-780nm in either 1nm or 5nm resolution. Additional variables are allowed.

output_resolution

String specifying the resolution of the output spectrum. Can be one of ("original", "spectrace", "1nm", "5mm")). Default is the resolution of the original spectrum. If "spectrace" is specified, no interpolation will be performed.

interp_method

The interpolation method. Can be either "pchip" (default) or "linear". Pchip (piecewise cubic hermetic interpolation) results in a smooth spectrum while preserving the source values as local minima/maxima. Will be ignored if output_resolution is "spectrace".

normalize

Logical. Normalize the resulting spectrum to peak = 1? Default is TRUE.

Value

The original data frame with the spectral data replaced by the new spectral data (normalized).


steffenhartmeyer/spectrace documentation built on Dec. 4, 2024, 4:13 p.m.