Compute \(N^2\), the square of the buoyancy frequency for a seawater profile.
swN2( pressure, sigmaTheta = NULL, derivs, df, debug = getOption("oceDebug"), ... )
either pressure (dbar) (in which case
be provided) or an object of class
ctd object (in which case
sigmaTheta is inferred from the object.
Surface-referenced potential density minus 1000 (kg/m\(^3\)).
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”.
argument passed to
smooth.spline() if this function is
used for smoothing; set to
NA to prevent smoothing.
an integer specifying whether debugging information is
to be printed during the processing. This is a general parameter that
is used by many
oce functions. Generally, setting
turns off the printing, while higher values suggest that more information
be printed. If one function calls another, it usually reduces the value of
debug first, so that a user can often obtain deeper debugging
by specifying higher
additional argument, passed to
the case that
derivs="smoothing". See “Details”.
Square of buoyancy frequency (\(radian^2/s^2\)).
Smoothing is often useful prior to computing buoyancy frequency, and so this
may optionally be done with
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.
The core of the method involves computing potential density referenced to median
pressure, using the UNESCO-style swSigmaTheta function, and then differentiating
this with respect to pressure. The
derivs argument is used
to control how this is done, as follows.
derivs is not supplied, the action is as though it were
given as the string
"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 using
diff(). (A zero is appended at the top level.)
"smoothing", then the processing
depends on the number of data in the profile, and on whether
given as an optional argument. When the number of points exceeds 4, and
df exceeds 1,
smooth.spline() is used to calculate
smoothing spline representation the variation of density as a function of
pressure, and derivatives are extracted from the spline using
predict. Otherwise, density is smoothed using
and derivatives are calculated as with the
derivs is 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 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.
Until 2019 April 11,
swN2 had an argument named
this did not work as stated, unless the first argument was a
object. Besides, the argument name was inherently deceptive, because the UNESCO
scheme does not specify how N2 is to be calculated.
Nothing is really lost by making this change, because the new default is the
same as was previously available with the
setup, and the gsw-formulated estimate of N2 is provided
gsw::gsw_Nsquared() in the gsw package.
gsw::gsw_Nsquared() function of the gsw
provides an alternative to this, as formulated in the GSW system. It
has a more sophisticated treatment of potential density, but it is based
on simple first-difference derivatives, so its results may require
smoothing, depending on the dataset and purpose of the analysis.
Other functions that calculate seawater properties:
library(oce) data(ctd) # Left panel: density p <- ctd[["pressure"]] ylim <- rev(range(p)) par(mfrow=c(1, 2), mar=c(3, 3, 1, 1), mgp=c(2, 0.7, 0)) plot(ctd[["sigmaTheta"]], p, ylim=ylim, type='l', xlab=expression(sigma[theta])) # Right panel: N2, with default settings (black) and with df=2 (red) N2 <- swN2(ctd) plot(N2, p, ylim=ylim, xlab="N2 [1/s^2]", ylab="p", type="l") lines(swN2(ctd, df=3), p, col=2)