View source: R/spectral_integration.R
spectral_integration | R Documentation |
Integrates over a given spectrum, optionally over only a portion of the spectrum, optionally with a weighing function. Can be used to calculate spectral contributions in certain wavelength ranges, or to calculate (alphaopically equivalent daylight) illuminance.
spectral_integration(
spectrum,
wavelength.range = NULL,
action.spectrum = NULL,
general.weight = 1
)
spectrum |
Tibble with spectral data (1st col: wavelength, 2nd col: SPD values) |
wavelength.range |
Optional integration bounds (length-2 numeric) |
action.spectrum |
Either:
|
general.weight |
Scalar multiplier or "auto" for built-in efficacies |
The function uses trapezoidal integration and recognizes differing
step-widths in the spectrum. If an action spectrum is used, values of the
action spectrum at the spectral wavelenghts are interpolated with
stats::approx()
.
The used efficacies for for the auto-weighting are:
photopic: 683.0015478
melanopic: 1/0.0013262
rhodopic: 1/0.0014497
l_cone_opic: 1/0.0016289
m_cone_opic: 1/0.0014558
s_cone_opic: 1/0.0008173
This requires input values in W/(m^2) for the spectrum. If it is provided in other units, the result has to be rescaled afterwards.
Numeric integrated value
Other Spectrum:
normalize_counts()
,
spectral_reconstruction()
# creating an equal energy spectrum of value 1
spd <- data.frame(wl = 380:780, values = 1)
#integrating over the full spectrum
spectral_integration(spd)
#integrating over wavelengths 400-500 nm
spectral_integration(spd, wavelength.range = c(400, 500))
#calculating the photopic illuminance of an equal energy spectrum with 1 W/(m^2*nm)
spectral_integration(spd, action.spectrum = "photopic", general.weight = "auto")
#calculating the melanopic EDI of an equal energy spectrum with 1 W/(m^2*nm)
spectral_integration(spd, action.spectrum = "melanopic", general.weight = "auto")
# Custom action spectrum
custom_act <- data.frame(wavelength = 400:700, weight = 0.5)
spectral_integration(spd, wavelength.range = c(400,700),
action.spectrum = custom_act, general.weight = 2)
#using a spectrum that is broader then the action spectrum will not change the
#output, as the action spectrum will use zeros beyond its range
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.