## do not run this in checks, because it will fail unless TEOS-10 is installed
library(oce)
data(ctd)
sp <- ctd[["salinity"]]
temperature <- ctd[["temperature"]]
n <- length(sp)
p <- ctd[["pressure"]]
lat <- rep(ctd[["latitude"]], n)
lon <- rep(ctd[["longitude"]], n)
sa <- teos("gsw_sa_from_sp", sp, p, lon, lat)
par(mfrow=c(1,2))
plot(ctd, which="salinity")
lines(sa, p, col='red')
plot(ctd, which="density")
rhopot <- teos("gsw_pot_rho_t_exact", sa, temperature, p, rep(0,length(p)))
lines(rhopot - 1000, p, col='red')
## The following demonstrations are from test values from the TEOS-10 supplied
## program "gsw_check_functions.c". (These, with more digits, are part of the
## test sequence that is run when Oce is built; see the tests/eos.R in the source
## code.)
# Absolute salinity is sa=35.671 g/kg, for practical salinity 35.5 PSU, pressure
# 300 dbar, long 300 degE, and lat 16 degN.
teos("gsw_sa_from_sp", 35.5, 300, 260, 16)
# Conservative temperature is ct=14.930, for abs sal=35.7 g/kg, in-situ temp 15
# degC, and press 300 dbar.
teos("gsw_ct_from_t", 35.7, 15, 300)
# Density is 1026.456 kg/m^3 for sa=35.7 g/kg, ct = 20 degC and p=300
teos("gsw_rho", 35.7, 20, 300)
Run the code above in your browser using DataLab