% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/sw.R
\name{swRrho}
\alias{swRrho}
\title{Density Ratio}
\usage{
swRrho(
  ctd,
  sense = c("diffusive", "finger"),
  smoothingLength = 10,
  df,
  eos = getOption("oceEOS", default = "gsw"),
  debug = getOption("oceDebug")
)
}
\arguments{
\item{ctd}{an \linkS4class{oce} object that holds \code{salinity}, \code{temperature}, and
\code{pressure}.  If \code{eos} is \code{"gsw"}, then it must also hold \code{longitude} and
\code{latitude}.}

\item{sense}{an indication of the sense of double diffusion under study and
therefore of the definition of Rrho; see \dQuote{Details}}

\item{smoothingLength}{ignored if \code{df} supplied, but otherwise the
latter is calculated as the number of data points, divided by the number
within a depth interval of \code{smoothingLength} metres.}

\item{df}{if given, this is provided to \code{\link[=smooth.spline]{smooth.spline()}}.}

\item{eos}{equation of state, either \code{"unesco"} or \code{"gsw"}.}

\item{debug}{an integer specifying whether debugging information is
to be printed during the processing. This is a general parameter that
is used by many \code{oce} functions. Generally, setting \code{debug=0}
turns off the printing, while higher values suggest that more information
be printed. If one function calls another, it usually reduces the value of
\code{debug} first, so that a user can often obtain deeper debugging
by specifying higher \code{debug} values.}
}
\value{
Density ratio defined in either the \code{"diffusive"} or
\code{"finger"} sense.
}
\description{
Compute density ratio for a \code{ctd} object.  An error (perhaps with some hints)
is issued for any other type of object.
}
\details{
If \code{eos="unesco"}, the work is done by calculating salinity and
potential-temperature derivatives from smoothing splines whose properties
are governed by \code{smoothingLength} or \code{df}.  If
\code{sense="diffusive"} the definition is
\eqn{(beta*dS/dz)/(alpha*d(theta)/dz)}{(beta*dS/dz)/(alpha*d(theta)/dz)} and
the reciprocal for \code{"finger"}.

If \code{eos="gsw"}, the work is done by extracting absolute salinity and
conservative temperature, smoothing with a smoothing spline as in the
\code{"unesco"} case, and then calling \code{\link[gsw:gsw_Turner_Rsubrho]{gsw::gsw_Turner_Rsubrho()}}
on these smoothed fields. Since the gsw function works on mid-point
pressures, \code{\link[=approx]{approx()}} is used to interpolate back to the original
pressures.

If the default arguments are acceptable, \code{ctd[["Rrho"]]} may be used
instead of \code{swRrho(ctd)}.
}
\examples{
library(oce)
data(ctd)
u <- swRrho(ctd, eos = "unesco")
g <- swRrho(ctd, eos = "gsw")
p <- ctd[["p"]]
plot(u, p, ylim = rev(range(p)), type = "l", xlab = expression(R[rho]))
lines(g, p, lty = 2, col = "red")
legend("topright", lty = 1:2, legend = c("unesco", "gsw"), col = c("black", "red"))

}
\seealso{
Other functions that calculate seawater properties: 
\code{\link{T68fromT90}()},
\code{\link{T90fromT48}()},
\code{\link{T90fromT68}()},
\code{\link{computableWaterProperties}()},
\code{\link{locationForGsw}()},
\code{\link{swAbsoluteSalinity}()},
\code{\link{swAlpha}()},
\code{\link{swAlphaOverBeta}()},
\code{\link{swBeta}()},
\code{\link{swCSTp}()},
\code{\link{swConservativeTemperature}()},
\code{\link{swDepth}()},
\code{\link{swDynamicHeight}()},
\code{\link{swLapseRate}()},
\code{\link{swN2}()},
\code{\link{swPressure}()},
\code{\link{swRho}()},
\code{\link{swSCTp}()},
\code{\link{swSR}()},
\code{\link{swSTrho}()},
\code{\link{swSigma}()},
\code{\link{swSigma0}()},
\code{\link{swSigma1}()},
\code{\link{swSigma2}()},
\code{\link{swSigma3}()},
\code{\link{swSigma4}()},
\code{\link{swSigmaT}()},
\code{\link{swSigmaTheta}()},
\code{\link{swSoundAbsorption}()},
\code{\link{swSoundSpeed}()},
\code{\link{swSpecificHeat}()},
\code{\link{swSpice}()},
\code{\link{swSpiciness0}()},
\code{\link{swSpiciness1}()},
\code{\link{swSpiciness2}()},
\code{\link{swSstar}()},
\code{\link{swTFreeze}()},
\code{\link{swTSrho}()},
\code{\link{swThermalConductivity}()},
\code{\link{swTheta}()},
\code{\link{swViscosity}()},
\code{\link{swZ}()}
}
\author{
Dan Kelley and Chantelle Layton
}
\concept{functions that calculate seawater properties}
