Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

prod_spectra

Multiply two spectra, even if the wavelengths values differ


Description

The wavelength vectors of the two spectra are merged, and the missing spectral values are calculated by interpolation. After this, the two spectral values at each wavelength are added.

Usage

prod_spectra(
  w.length1,
  w.length2 = NULL,
  s.irrad1,
  s.irrad2,
  trim = "union",
  na.rm = FALSE
)

Arguments

w.length1

numeric vector of wavelength (nm).

w.length2

numeric vector of wavelength (nm).

s.irrad1

a numeric vector of spectral values.

s.irrad2

a numeric vector of spectral values.

trim

a character string with value "union" or "intersection".

na.rm

a logical value, if TRUE, not the default, NAs in the input are replaced with zeros.

Details

If trim=="union" spectral values are calculated for the whole range of wavelengths covered by at least one of the input spectra, and missing values are set in each input spectrum to zero before addition. If trim=="intersection" then the range of wavelengths covered by both input spectra is returned, and the non-overlapping regions discarded. If w.length2==NULL, it is assumed that both spectra are measured at the same wavelengths, and a simple addition is used, ensuring fast calculation.

Value

a dataframe with two numeric variables

w.length

A numeric vector with the wavelengths (nm) obtained by "fusing" w.length1 and w.length2. w.length contains all the unique vales, sorted in ascending order.

s.irrad

A numeric vector with the sum of the two spectral values at each wavelength.

See Also

Examples

head(sun.data)
square.sun.data <-
  with(sun.data, prod_spectra(w.length, w.length, s.e.irrad, s.e.irrad))
head(square.sun.data)
tail(square.sun.data)

photobiology

Photobiological Calculations

v0.10.10
GPL (>= 2)
Authors
Pedro J. Aphalo [aut, cre] (<https://orcid.org/0000-0003-3385-972X>), Titta K. Kotilainen [ctb] (<https://orcid.org/0000-0002-2822-9734>), Glenn Davis [ctb], Agnese Fazio [ctb]
Initial release
2022-03-24

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.