MyNixOS website logo
Description

R Functions to Model CDOM Spectra.

Wrapper functions to model and extract various quantitative information from absorption spectra of chromophoric dissolved organic matter (CDOM).

cdom Travis-CI Build Status AppVeyor Build Status Package-License

The cdom package implements various functions used to model and calculate metrics from absorption spectra of chromophotic dissolved organic matter (CDOM).

This package provides:

  1. Simple wrappers to calculate common metrics found in the literature.

    • The spectral curve (Loiselle et al. 2009).
    • The slope ratio (Sr) (Helms et al. 2008).
    • The spectral slope (S) (Jerlov 1968; Lundgren 1976; Bricaud, Morel, and Prieur 1981).
  2. The function to use the Gaussian decomposition approach proposed in Massicotte and Markager, (2015).

The package can be installed using the following command.

devtools::install_github("PMassicotte/cdom")

Please note that this is a developing version of the package for testing only. Please fill an issue when you find bugs.

All functions from the package start with the cdom_ prefix.

library(cdom)
ls("package:cdom")
## [1] "cdom_fit_exponential" "cdom_slope_ratio"     "cdom_spectral_curve" 
## [4] "spectra"

Examples

The spectral slope (S)

The cdom_fit_exponential() function fits an exponential curve to CDOM data using the simple model proposed by Jerlov (1968), Lundgren (1976), Bricaud, Morel, and Prieur (1981).

a(\lambda) = a(\lambda0)e^{-S(\lambda - \lambda0)} + K
library(ggplot2)
library(cdom)
data("spectra")

fit <- cdom_fit_exponential(wl = spectra$wavelength,
                       absorbance = spectra$spc3,
                       wl0 = 350,
                       startwl = 190,
                       endwl = 900)

ggplot(spectra, aes(x = wavelength, y = spc3)) +
  geom_point() +
  geom_line(aes(y = fit$data$.fitted), col = "red") +
  xlab("Wavelength (nm)") +
  ylab(expression(paste("Absorption (", m ^ {-1}, ")")))

The slope ratio (SR)

The cdom_slope_ratio() function calculates the slope ratio (SR) which is defined as: S275-295/S350-400. See Helms et al. (2008) for detailed information.

library(cdom)
data("spectra")

cdom_slope_ratio(spectra$wavelength, spectra$spc1)
## [1] 1.325082

The spectral curve

The cdom_spectral_curve() function generates the spectral curve using the slope of the linear regression between the natural log absorption spectrum and wavelengths over a sliding window of 21 nm interval (default) at 1 nm resolution. See Loiselle et al. (2009) for detailed information.

library(cdom)
data("spectra")

res <-  cdom_spectral_curve(wl = spectra$wavelength,
                       absorbance = spectra$spc10,
                       interval = 21,
                       r2threshold = 0.98) # Maybe to restrictive...

ggplot(res, aes(x = wl, y = s)) +
  geom_point() +
  geom_line() +
  xlab("Wavelength (nm)") +
  ylab(expression(paste("Spectral slope (", nm ^ {-1}, ")")))

Data

A total 25 absorption spectra are provided in the package.

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) +
  xlab("Wavelength (nm)") +
  ylab(expression(paste("Absorption (", m ^ {-1}, ")")))

How to cite the package

citation("cdom")
## 
## To cite cdom in publications use:
## 
##   Massicotte, P., and Markager, S. (2016). Using a Gaussian
##   decomposition approach to model absorption spectra of
##   chromophoric dissolved organic matter. Mar. Chem. 180, 24-32.
##   doi:10.1016/j.marchem.2016.01.008.
## 
## A BibTeX entry for LaTeX users is
## 
##   @Article{,
##     title = {Using a Gaussian decomposition approach to model absorption spectra of chromophoric dissolved organic matter},
##     author = {Philippe Massicotte and Stiig Markager},
##     journal = {Marine Chemistry},
##     year = {2016},
##     volume = {180},
##     pages = {24--32},
##     url = {http://linkinghub.elsevier.com/retrieve/pii/S0304420316300081},
##   }

References

Bricaud, Annick, André Morel, and Louis Prieur. 1981. “Absorption by dissolved organic matter of the sea (yellow substance) in the UV and visible domains.” Limnology and Oceanography 26 (1): 43–53. doi:10.4319/lo.1981.26.1.0043.

Helms, John R., Aron Stubbins, Jason D. Ritchie, Elizabeth C. Minor, David J. Kieber, and Kenneth Mopper. 2008. “Absorption spectral slopes and slope ratios as indicators of molecular weight, source, and photobleaching of chromophoric dissolved organic matter.” Limnology and Oceanography 53 (3): 955–69. doi:10.4319/lo.2008.53.3.0955.

Jerlov, N.G. 1968. Optical oceanography. New York: Elsevier Publishing Company.

Loiselle, Steven A., Luca Bracchini, Arduino M. Dattilo, Maso Ricci, Antonio Tognazzi, Andres Cézar, and Claudio Rossi. 2009. “The optical characterization of chromophoric dissolved organic matter using wavelength distribution of absorption spectral slopes.” Limnology and Oceanography 54 (2): 590–97. doi:10.4319/lo.2009.54.2.0590.

Lundgren, Bo. 1976. “Spectral transmittance measurements in the Baltic.” Copenhagen: Institute Physical Oceanography University of Copenhagen.

Metadata

Version

0.1.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows