Abstract.Methods are presented for smoothing hydrographic profiles.
Smoothing hydrographic profiles with conventional time-series methods is problematic for two reasons: (a) the data are commonly not equi-spaced in depth and (b) the data seldom lack trends in depth. The issues and their solutions are illustrated without much discussion here.
library(oce) library(signal) data(ctd) S <- ctd[['salinity']] p <- ctd[['pressure']] ## must create equispaced data for filtering to make sense dp <- median(diff(p)) pp <- seq(min(p), max(p), dp) S0 <- approx(p, S, pp)$y W <- dp / 2 # critical frequency f1 <- butter(1, W) f2 <- butter(2, W) par(mfrow=c(1, 3)) ## filter raw profile plotProfile(ctd, xtype="salinity", type='l') S0f1 <- filtfilt(f1, S0) S0f2 <- filtfilt(f2, S0) lines(S0f1, pp, col='red') lines(S0f2, pp, col='blue') mtext("(a) ", side=3, adj=1, line=-5/4, cex=3/4) ## filter detrended profile plotProfile(ctd, xtype="salinity", type='l') Sd <- detrend(pp, S0) S1f1 <- filtfilt(f1, Sd$Y) + Sd$a + Sd$b * pp S1f2 <- filtfilt(f2, Sd$Y) + Sd$a + Sd$b * pp lines(S1f1, pp, col='red') lines(S1f2, pp, col='blue') mtext("(b) ", side=3, adj=1, line=-5/4, cex=3/4) ## smooth-spline raw profile spline <- smooth.spline(pp, S0, df=3/W) # suggestion: try different df values S2 <- predict(spline)$y plotProfile(ctd, xtype="salinity", type='l') lines(S2, pp, col='red') mtext("(c) ", side=3, adj=1, line=-5/4, cex=3/4)
The first order filter is less prone to isolated wiggles than the second order one, but both behave poorly near the top and bottom of the profile, unless the data are detrended. With detrending, filtered signals are similar to those calculated with the smoothing spline.
4. Discussion and conclusions
With detrending, the filtered results can be made similar to those of smoothing spline. However, splines have some practical advantages: (1) they do not require equispaced data, (2) they do not require detrending, (3) the results are inherently smooth (by construction of the spline) and (4) calculating derivatives is easy with a spline. These advantages explain why splines are used to calculate buoyancy frequency in the