| Type: | Package | 
| Title: | R Functions to Model CDOM Spectra | 
| Version: | 0.1.0 | 
| Date: | 2016-02-22 | 
| Description: | Wrapper functions to model and extract various quantitative information from absorption spectra of chromophoric dissolved organic matter (CDOM). | 
| BugReports: | https://github.com/PMassicotte/cdom/issues | 
| URL: | https://github.com/PMassicotte/cdom | 
| License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] | 
| Depends: | R (≥ 3.0) | 
| LazyData: | TRUE | 
| Imports: | minpack.lm, ggplot2, tidyr, broom | 
| RoxygenNote: | 5.0.1 | 
| Suggests: | eemR | 
| NeedsCompilation: | no | 
| Packaged: | 2016-03-04 07:16:53 UTC; persican | 
| Author: | Philippe Massicotte [aut, cre] | 
| Maintainer: | Philippe Massicotte <pm@bios.au.dk> | 
| Repository: | CRAN | 
| Date/Publication: | 2016-03-04 08:39:29 | 
Fit an exponential model to CDOM data.
Description
Fit an exponential model to CDOM data.
Usage
cdom_fit_exponential(wl, absorbance, wl0 = 350, startwl, endwl)
Arguments
| wl | The wavelength vector. | 
| absorbance | The absorbance vector. | 
| wl0 | The reference wavelength (ex.: 350). | 
| startwl | The starting wavelength (ex.: 240). | 
| endwl | The ending wavelength (ex.: 600). | 
Details
y = a0 + e^{(-S(x - \lambda_0))} + K
Value
A list containing:
- params
- A data frame with values of fitted parameters. 
- r2
- R2 of the nls model. 
- data
- A data frame with fitted (predicted) values of the model. 
The function will return NULL if the model did not converged.
Examples
# Fit an exponential model using the reference wavelength 350 between 190 and 900 nm.
data(spectra)
fit <- cdom_fit_exponential(spectra$wavelength, spectra$spc1, 350, 190, 900)
str(fit)
plot(spectra$wavelength, spectra$spc1)
lines(spectra$wavelength, fit$data$.fitted, col = "red")
Calculate the slope ratio (SR) from an absorption spectra.
Description
Calculate the slope ratio (SR) from an absorption spectra.
Usage
cdom_slope_ratio(wl, absorbance)
Arguments
| wl | The wavelength vector. | 
| absorbance | The absorbance vector. | 
Details
Calculate the slope ratio (SR) as defined by Helms et al. (2008).
SR = \frac{S_{275-295}}{S_{350-400}}
Value
The value of the slope ratio.
References
http://www.aslo.org/lo/toc/vol_53/issue_3/0955.html
Examples
data("spectra")
cdom_slope_ratio(spectra$wavelength, spectra$spc1)
Calculate the spectral curve of CDOM spectra.
Description
Calculate the spectral curve of CDOM spectra has proposed by Loiselle et al. 2009.
Usage
cdom_spectral_curve(wl, absorbance, interval = 21, r2threshold = 0.8)
Arguments
| wl | The wavelength vector. | 
| absorbance | The absorbance vector. | 
| interval | The interval used to claculate each slope (default = 21 nm). | 
| r2threshold | The r2 threshold that determines if a slope is "valide". The default value is 0.8 meaning that the determination coefficient of the regression between log-transformed data and wavelength should be >= 0.8. | 
Value
A dataframe containing the centered wavelength, the calculated slope and the determination coefficient of the linear regression used to claculate the slope.
References
http://doi.wiley.com/10.4319/lo.2009.54.2.0590
Examples
data(spectra)
res <- cdom_spectral_curve(spectra$wavelength, spectra$spc2)
plot(res$wl, res$s, type = "l")
CDOM absorption data.
Description
Simple absorption spectra used to test package's functions.
Usage
data(spectra)
Format
A data frame with 711 rows and 26 variables
Details
- wavelength. Wavelengths used for measurements (190-900 nm.) 
- Absorption 
Examples
library(ggplot2)
library(tidyr)
data("spectra")
spectra <- gather(spectra, sample, absorption, -wavelength)
ggplot(spectra, aes(x = wavelength, y = absorption, group = sample)) +
 geom_line(size = 0.1)