Learn R Programming

oce (version 0.9-13)

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, ...)

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
optional argument, passed to smooth.spline if this function is used for smoothing.
...
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.

The core of the method involves differentiating density 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.

Given the derivative, the square of the buoyancy frequency is calculated as $10^{-4}g^2d\sigma_\theta/dp$.

Examples

Run this code
library(oce)
data(ctd)
# Illustrate effect of changing df
p <- pressure(ctd)
plot(swN2(ctd), p, ylim=rev(range(p)), xlab="N2",ylab="p", type='l')
lines(swN2(ctd, df=3), p, col="blue")
grid()

Run the code above in your browser using DataLab