Learn R Programming

oce (version 0.9-18)

swN2: Squared buoyancy frequency for seawater

Description

Compute $N^2$, the square of the buoyancy frequency for a seawater profile.

Usage

swN2(pressure, sigmaTheta=NULL, derivs, df, eos=getOption("oceEOS", default="gsw"), ...)

Arguments

pressure
either pressure [dbar] (in which case sigmaTheta must be provided) or an object of class ctd object (in which case sigmaTheta is inferred from the object.
sigmaTheta
Surface-referenced potential density minus 1000 [kg/m$^3$]
derivs
optional argument to control how the derivative $d\sigma_\theta/dp$ is calculated. This may be a character string or a function of two arguments. See Details.
df
argument passed to smooth.spline if this function is used for smoothing; set to NA to prevent smoothing.
eos
equation of state, either "unesco" or "gsw".
...
additional argument, passed to smooth.spline, in the case that derivs="smoothing". See Details.

Value

  • Square of buoyancy frequency [$radian^2/s^2$].

Details

If the first argument is a ctd object, then density is is inferred from it, and the sigmaTheta argument is ignored.

Smoothing is often useful prior to computing buoyancy frequency, and so this may optionally be done with smooth.spline, unless df=NA, in which case raw data are used. If df is not provided, a possibly reasonable value computed from an analysis of the profile, based on the number of pressure levels.

If eos="gsw", then the first argument must be a ctd object, and processing is done with gsw_Nsquared, based on extracted values of Absolute Salinity and Conservative Temperature (possibly smoothed, depending on df).

If eos="unesco", then the processing is as follows. The core of the method involves differentiating potential density (referenced to median pressure) with respect to pressure, and the derivs argument is used to control how this is done, as follows.

  • ifderivsis not supplied, the action is as though it were given as the string"smoothing"
  • ifderivsequals"simple", then the derivative of density with respect to pressure is calculated as the ratio of first-order derivatives of density and pressure, each calculated usingdiff. (A zero is appended at the top level.)
  • ifderivsequals"smoothing", then the processing depends on the number of data in the profile, and on whetherdfis given as an optional argument. When the number of points exceeds 4, and whendfexceeds 1,smooth.splineis used to calculate smoothing spline representation the variation of density as a function of pressure, and derivatives are extracted from the spline usingpredict. Otherwise, density is smoothed usingsmooth, and derivatives are calculated as with the"simple"method.
  • ifderivsis a function taking two arguments (first pressure, then density) then that function is called directly to calculate the derivative, and no smoothing is done before or after that call.

For deep-sea work, the eos="gsw" option is the best scheme, because it uses derivatives of density computed with local reference pressure. For precise work, it makes sense to skip swN2 entirely, choosing whether, what, and how to smooth based on an understanding of fundamental principles as well as data practicalities.

Examples

Run this code
library(oce)
data(ctd)
# Illustrate difference between UNESCO and GSW
p <- pressure(ctd)
ylim <- rev(range(p))
par(mfrow=c(1,3), mar=c(3, 3, 1, 1), mgp=c(2, 0.7, 0))
plot(ctd[["sigmaTheta"]], p, ylim=ylim, type='l', xlab=expression(sigma[theta]))
N2u <- swN2(ctd, eos="unesco")
N2g <- swN2(ctd, eos="gsw")
plot(N2u, p, ylim=ylim, xlab="N2 Unesco", ylab="p", type="l")
d <- 100 * (N2u - N2g) / N2g
plot(d, p, ylim=ylim, xlab="N2 UNESCO-GSW diff. [%]", ylab="p", type="l")
abline(v=0)

Run the code above in your browser using DataLab