R/get.O2Sat.R

#'@title
#'@description
#' @importFrom seacarb rho
# NULL
#'@usage
#'@param
#'@param
#'@return
#'@note
#'@references Garcia and Gordon. 1992. Limnol. Oceanogr. 37(6): 307-1312
#'@author Gordon W. Holtgrieve (gholt@uw.edu)
#'@examples
#'@export
#'

get.O2Sat <-	function(temperature, salinity=0, pressure = 1){

  A <- c(5.80818, 3.20684, 4.11890, 4.93845, 1.01567, 1.41575)      #O2, umol/kg Garcia and Gordon. 1992. Limnol. Oceanogr. 37(6): 307-1312
  B <- c(-7.01211e-3, -7.25958e-3, -7.93334e-3, -5.54491e-3)
  C <- -1.32412e-7

  #Garcia and Gordon 1992 equation
  Ts <- log((298.15 - temperature) / (273.15 + temperature))
  lnConc <-  A[1] + A[2] * Ts + A[3] * Ts^2 + A[4] * Ts^3 + A[5] * Ts^4 + A[6] * Ts^5 + salinity * (B[1] + B[2] * Ts + B[3] * Ts^2 + B[4] * Ts^3) + C * salinity^2
  O2Sat_umolperkg <- exp(lnConc)

  rho <- seacarb::rho(S = salinity, T = temperature, P = 0) # Density in kg/m3
  O2Sat_umolperL <- O2Sat_umolperkg * rho  / 1000 # Convert from kg water to L

  return(O2Sat_umolperL)
}
gholtgrieve/gassyPants documentation built on May 9, 2019, 5:02 a.m.