### Improved output format, and added corresponding arg.

parent 14624927
 ... ... @@ -10,6 +10,7 @@ #' @param thresh The threshold for the difference between top and bottom temperature to infer stratification. #' @param therm.dz Representative thickness of the thermocline layer. 1 m works well from experience. #' @param min.hmix I can't really remember what this is for. #' @param var Which metric should be returned? One of "hmix", "htherm", "both" for mixed layer depth, thermocline depth, or both, respectively. #' @param min.gradient Not used. #' @param ... Arguments passed to plot(), when plot=TRUE. #' ... ... @@ -55,7 +56,7 @@ h3mix <- function(T, z, plot=FALSE, thresh = 1, therm.dz = 1, min.hmix = 1.5, min.gradient = 0.3, ...) { therm.dz = 1, min.hmix = 1.5, var="hmix", min.gradient = 0.3, ...) { if(sum(!is.na(T))>3) { dTdz <- diff(T) / diff(z) d2Tdz2 <- diff(T,1,2) / diff(z,2)^2 ... ... @@ -123,8 +124,16 @@ h3mix <- function(T, z, plot=FALSE, thresh = 1, h <- NA warning("Warning:need more than 3 temperature values") } out <- c(h, mean(z[c(i1,i1+1)])) names(out) <- c("hmix","htherm") if(var=="hmix") { out <- as.numeric(h) } else if(var=="htherm") { out <- mean(z[c(i1,i1+1)]) } else if(var=="both") { out <- c(h, mean(z[c(i1,i1+1)])) names(out) <- c("hmix","htherm") } else { stop("var must be one of 'hmix','htherm','both'") } return(out) } ... ...
 ... ... @@ -11,26 +11,29 @@ h3mix( thresh = 1, therm.dz = 1, min.hmix = 1.5, var = "hmix", min.gradient = 0.3, ... ) } \arguments{ \item{T}{Temperature profile} \item{T}{Temperature profile as numeric vector.} \item{z}{The depths corresponding to the temperature profile} \item{z}{The depths corresponding to the temperature profile, as a numeric vector.} \item{plot}{Should a plot of the profile showing the estimates be shown? (logical)} \item{plot}{Should a plot of the profile showing the estimates be shown? (logical).} \item{thresh}{The threshold for the difference between top and bottom temperature to infer stratification} \item{thresh}{The threshold for the difference between top and bottom temperature to infer stratification.} \item{therm.dz}{Representative thickness of the thermocline layer. 1 m works well from experience.} \item{min.hmix}{I can't really remember what this is for.} \item{min.gradient}{Not used} \item{var}{Which metric should be returned? One of \code{"hmix"}, \code{"htherm"}, \code{"both"} for mixed layer depth, thermocline depth, or both, respectively.} \item{...}{Arguments passed to \code{plot()}, when \code{plot=TRUE}} \item{min.gradient}{Not used.} \item{...}{Arguments passed to \code{plot()}, when \code{plot=TRUE}.} } \value{ A vector of length 2 with the mixed layer depth \code{hmix} and the thermocline depth \code{htherm} ... ... @@ -42,8 +45,8 @@ temperature data. } \details{ This function estimates the mixed depth and the thermocline depth. It uses regressions to locate the kink in the profile at the bottom of the mixed layer as the mixed layer, and the maximum gradient as the thermocline. It uses regressions to locate the depth of the kink in the temperature profile as the mixed layer depth, and the maximum gradient as the thermocline. It is better suited to irregular, esp manually measured profile data. It first finds the minimum curvature in the profile (maximum for winter stratification) as the initial guess of the ... ... @@ -51,8 +54,9 @@ border of the surface mixed layer. Then it finds the thermocline as the depth of maximum T-gradient. It estimates the mixed layer depth as the depth where the regression line through the surface layer temperatures intersects with the regression line through the thermocline temperatures. It performs some other checks, like whether stratification exists surface-bottom temperature difference > \code{thresh}, and whether the thermocline thermocline temperatures, extended by a window of thickness \code{therm.dz}. It performs some other checks, like whether stratification exists according to whether the surface-bottom temperature difference > \code{thresh}, and whether the thermocline is above the surface layer, or whether the lake is completely isothermal and there is no intersection (and returns \code{NA}). If mixed, it assumes the mixed layer depth is the maximum depth. It also plots the profile if desired ... ...
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment