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.
if derivs
is not supplied, the action is as though it were
given as the string "smoothing"
if derivs
equals "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.)
if derivs
equals "smoothing"
, then the processing
depends on the number of data in the profile, and on whether df
is
given as an optional argument. When the number of points exceeds 4, and
when 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 smooth
,
and derivatives are calculated as with the "simple"
method.
if 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 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.