The oce Package - the University of Bayreuth

The oce Package
October 21, 2007
Version 0.1.67
Date 2007-10-21
Title Analysis of Oceanographic data
Author Dan Kelley <[email protected]>
Maintainer Dan Kelley <[email protected]>
Depends R (>= 0.99)
Description Supports the analysis of Oceanographic data, including CTD measurements, sea-level
timeseries, coastline files, etc. Also includes functions for calculating seawater properties such as
density, and derived properties such as buoyancy frequency.
License GPL (>= 2)
URL http://myweb.dal.ca/kelley/pub/sof/oce/index.php
LazyLoad yes
R topics documented:
as.CTD . . . . . .
as.coastline . . . .
as.sealevel . . . . .
coastline.halifax . .
coastline.maritimes
coriolis . . . . . .
ctd . . . . . . . . .
ctd.add.column . .
ctd.decimate . . . .
ctd.raw . . . . . .
ctd.trim . . . . . .
ctd.update.header .
ctd.write . . . . . .
geod.dist . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
1
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
3
4
5
7
8
8
9
10
11
12
13
15
16
17
R topics documented:
2
gravity . . . . . . . . . .
lat.format . . . . . . . .
latlon.format . . . . . . .
lobo . . . . . . . . . . .
lon.format . . . . . . . .
magic . . . . . . . . . .
make.section . . . . . .
oce.as.POSIXlt . . . . .
plot.TS . . . . . . . . .
plot.coastline . . . . . .
plot.ctd . . . . . . . . .
plot.ctd.scan . . . . . . .
plot.lobo . . . . . . . . .
plot.profile . . . . . . . .
plot.sealevel . . . . . . .
plot.section . . . . . . .
processing.log.append . .
processing.log.summary
read.coastline . . . . . .
read.ctd . . . . . . . . .
read.lobo . . . . . . . .
read.oce . . . . . . . . .
read.sealevel . . . . . . .
sealevel . . . . . . . . .
section . . . . . . . . . .
summary.coastline . . .
summary.ctd . . . . . . .
summary.lobo . . . . . .
summary.sealevel . . . .
summary.section . . . .
sw.N2 . . . . . . . . . .
sw.S.C.T.p . . . . . . . .
sw.S.T.rho . . . . . . . .
sw.T.S.rho . . . . . . . .
sw.T.freeze . . . . . . .
sw.alpha . . . . . . . . .
sw.alpha.over.beta . . . .
sw.beta . . . . . . . . .
sw.conductivity . . . . .
sw.depth . . . . . . . . .
sw.lapse.rate . . . . . . .
sw.rho . . . . . . . . . .
sw.sigma . . . . . . . . .
sw.sigma.t . . . . . . . .
sw.sigma.theta . . . . . .
sw.sound.speed . . . . .
sw.specific.heat . . . . .
sw.spice . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
18
19
20
21
21
22
23
24
25
26
27
28
29
30
32
33
35
36
37
38
40
42
43
45
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
as.CTD
3
sw.theta . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
sw.viscosity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Index
as.CTD
72
Coerce data into CTD dataset
Description
Coerces a dataset into a CTD dataset.
Usage
thectd <- as.CTD(
S, T, p, header=NULL, filename=NA, ship=NA, scientist=NA,
institute=NA, address=NA, cruise=NA, station=NA,
date=NA, start.time=NA,
latitude=NA, longitude=NA,
recovery=NA,
water.depth=NA,
sample.interval=NA)
Arguments
S
Salinity through the water column.
T
Temperature through the water column.
p
pressure through the water column.
header
ignored, for now
filename
ignored, for now
ship
ignored, for now
scientist
ignored, for now
institute
ignored, for now
address
ignored, for now
cruise
ignored, for now
station
ignored, for now
date
ignored, for now
start.time
ignored, for now
latitude
ignored, for now
longitude
ignored, for now
recovery
ignored, for now
water.depth ignored, for now
sample.interval
ignored, for now
4
as.coastline
Details
This is helpful if data were created, not read in from a file.
Value
A ctd object.
Author(s)
Dan Kelley [email protected]
References
See Also
read.ctd reads data,
Examples
library(oce)
p <- seq(0,100,1)
T <- 10 - p / 100
S <- 35 - p / 100
ctd <- as.CTD(S, T, p)
summary(ctd)
as.coastline
Coerce data into coastline dataset
Description
Coerces a sequence of latitudes and longitudes into a coastline dataset.
Usage
as.coastline(latitude, longitude)
Arguments
latitude
the latitude in decimal degrees, positive north of the equator.
longitude
the longitude in decimal degrees, positive north of Greenwich.
Details
This may be used when read.coastline cannot read a file, or when the data have been manipulated.
as.sealevel
5
Value
A coastline object.
Author(s)
Dan Kelley [email protected]
References
See Also
read.coastline reads data plot.coastline plots it.
Examples
as.sealevel
Coerce data into sea-level dataset
Description
Coerces a dataset (minimally, a sequence of heights) into a sealevel dataset.
Usage
as.sealevel(t=NULL,
eta=NULL,
header=NULL,
station.number=NA,
station.version=NA,
station.name=NULL,
region=NA,
year=NA,
latitude=NA,
longitude=NA,
GMT.offset=NA,
decimation.method=NA,
reference.offset=NA,
reference.code=NA,
processing.log=NULL)
6
as.sealevel
Arguments
t
a list of times, in POSIXct format.
eta
a list of sea-level heights in metres, in an hourly sequence.
header
a character string as read from first line of a standard data file.
station.number
three-character string giving station number.
station.version
single character for version of station.
station.name the name of station (at most 18 characters).
region
the name of the region or country of station (at most 19 characters).
year
the year of observation.
latitude
the latitude in decimal degrees, positive north of the equator.
longitude
the longitude in decimal degrees, positive east of Greenwich.
GMT.offset
offset from GMT. (BUG: this is ignored.)
decimation.method
a coded value, with 1 meaning filtered, 2 meaning a simple average of all samples, 3 meaning spot readings, and 4 meaning some other method.
reference.offset
?
reference.code
?
processing.log
a processing log
Details
The arguments are based on the standard data format, as described at ftp://ilikai.soest.
hawaii.edu/rqds/hourly.fmt.
Value
A sealevel object.
Author(s)
Dan Kelley [email protected]
References
ftp://ilikai.soest.hawaii.edu/rqds/hourly.fmt.
See Also
read.sealevel reads data, summary.sealevel summarizes the information, while plot.sealevel
plots it.
coastline.halifax
7
Examples
library(oce)
h <- 0:(24*100) # 100 days after 911
t <- as.POSIXct("2001-09-11") + h * 3600
eta <- 1.0 * sin(2*pi*h/12.4172) + 0.8 * sin(2*pi*h/24.0)
eta <- eta + 0.1 * rnorm(length(h)) # add some noise
sl <- as.sealevel(t, eta)
summary(sl)
coastline.halifax
Sample coastline data set (Halifax Harbour)
Description
A sample coastline dataset, showing Halifax Harbour. The little island at about 44.64N is visible
outside the author’s window.
Usage
data(coastline.halifax)
Author(s)
Dan Kelley [email protected]
Source
References
http://www.ngdc.noaa.gov/mgg_coastline/
See Also
Coastlines may be read with read.coastline, or created with as.coastline. Another
sample coastline file is coastline.maritimes.
8
coriolis
coastline.maritimes
Sample coastline data set, showing Maritime provinces of Canada
Description
A sample coastline dataset, showing Nova Scotia, Prince Edward Island, and part of New Brunswick.
This is the oce author’s stomping ground, and so he feels compelled to apologize for the error at the
Strait of Canso.
Usage
data(coastline.maritimes)
Author(s)
Dan Kelley [email protected]
Source
The data were extracted from the NOAA site, specifying the Splus data type, and read with read.coastline.
References
http://www.ngdc.noaa.gov/mgg_coastline/
See Also
Coastlines may be read with read.coastline, or created with as.coastline. Another
sample coastline file is coastline.halifax.
coriolis
Coriolis parameter on rotating earth
Description
Compute f , the Coriolis parameter as a function of latitude.
Usage
f <- coriolis(lat, degrees=TRUE);
Arguments
lat
Latitude in ◦ N or radians north of the equator.
degrees
Flag indicating whether degrees are used for latitude; if set to FALSE, radians
are used.
ctd
9
Details
Value
Coriolis parameter [radian/s].
Author(s)
Dan Kelley [email protected]
References
Gill, A.E., 1982. Atmosphere-ocean Dynamics, Academic Press, New York, 662 pp.
See Also
N/A.
Examples
C <- coriolis(45) # 1e-4
ctd
Sample seawater (CTD) profile
Description
This is sample CTD profile provided for testing. It has been pruned by selecting only the portion of
the data acquired when the instrument was being lowered through the water column.
Usage
data(ctd)
Format
This file is from a Sea-Bird SBE 19 CTD instrument.
Author(s)
Dan Kelley [email protected]
Source
Peter Galbraith acquired these data during the 2002 SLEIWEX field program, part of a Dalhousie/IML
cooperative study of internal-wave mixing in the St Lawrence estuary.
10
ctd.add.column
References
The Seabird CTD instrument is described at http://www.seabird.com/products/spec_
sheets/19plusdata.htm. See linkread.ctd for the data format.
ctd.add.column
Add a column to a CTD file
Description
Add a column to a CTD file, updating the header as appropriate.
Usage
ctd.add.column(x, column=NULL, column.name="",
code="", name="", unit="", debug=FALSE)
Arguments
x
A ctd object, e.g. as read by read.ctd.
column
A column of data.
column.name
The name for this column in the dataframe; e.g. if set to hello, then the column
would be accessed later d$data$hello.
code
Item to put before the : in the header line.
name
Item to put after the :, but before the [].
unit
Item inside the [] in the header line.
debug
Set TRUE to see information about the processing.
Details
This adds a line of the form
* name N = code: name [unit]
within the header list, and also adds the data column itself. You should study an existing .cnv file
to see what sort of format to use, to avoid confusion if you share the resultant file.
Value
A new ctd object.
Author(s)
Dan Kelley [email protected]
ctd.decimate
11
References
The Seabird CTD instrument is described at http://www.seabird.com/products/spec_
sheets/19plusdata.htm.
See Also
read.ctd reads a CTD object, and write.ctd writes one.
Examples
library(oce)
data(ctd)
sigthe <- sw.sigma.theta(ctd$data$salinity,
ctd$data$temperature,
ctd$data$pressure);
ctd.new <- ctd.add.column(ctd,
sigthe, "sigmatheta",
"sigma-theta", "density, sigma-theta",
"kg/m^3");
ctd.decimate
Decimate a CTD profile
Description
Smooth and decimate a CTD profile.
Usage
ctd.decimate(x, p=NULL, method=c("boxcar","lm"), e=1)
Arguments
x
p
method
e
a ctd object, e.g. as read by read.ctd.
controls the selection of pressure levels, as follows. If NULL (the default), then
the list of pressures for the decimation is to be selected automatically, using
pretty. If a single value is supplied, then the pressure list starts at the surface
and increments with the indicated value, down to the bottom. If a list is supplied,
then this is taken to be the desired pressure list.
Method for calculating decimated values. Use "boxcar" (the default) for boxcar averaging within the pressure region. Use "lm" to use the prediction of a
linear model applied to each pressure region. (See e for an explanation of the
region.)
is an expansion coefficient used to calculate the smoothing neighbourhoods. If
e=1, then the neighbourhood for the i-th pressure extends from the (i-1)-th
pressure to the (i+1)-th pressure. (At the endpoints it is assumed that the outside
bin is of the same pressure range as the first inside bin.) For other values of e,
the neighbourhood is expanded linearly in each direction.
12
ctd.raw
Details
This function is useful for calculations that require data to be defined at a fixed set of pressure values.
Normally, the target pressures are supplied by the user (e.g. to simplify thermal-wind calculations
based on pairs of CTD profiles), but the routine can select the target pressures automatically. The
smoothing part of the algorithm is based on neighbourhoods of each target pressures.
Note that the density that results from the decimation is calculated from an average, and so it may
not match with the averaged salinity and temperature. This is a sort of numerical cabeling effect,
and if you would like to avoid this, just do as follows
xd <- ctd.decimate(x)
xd$data$sigma <- sw.sigma(xd$data$salinity, xd$data$temperature, xd$data$pressure)
Value
A new ctd object.
Author(s)
Dan Kelley [email protected]
References
See Also
A ctd object may be read with read.ctd, and ctd.trim is useful in trimming spurious data
(e.g. those obtained during the upcast).
Examples
library(oce)
data(ctd.raw)
ctd.clean <- ctd.decimate(ctd.trim(ctd.raw))
summary(ctd.clean)
ctd.raw
Sample seawater (CTD) profile, without trimming of extraneous data
Description
This is sample CTD profile provided for testing. It includes not just the (useful) portion of the
dataset during which the instrument was being lowered, but also data from the upcast and from time
spent near the surface. Spikes are also clearly evident in the pressure record. With such real-world
wrinkles, this dataset provides a good example of data that need trimming with ctd.trim.
ctd.trim
13
Usage
data(ctd.raw)
Format
Author(s)
Dan Kelley [email protected]
Source
The data were acquired near the centre of the Bedford Basin of the Halifax Harbour, during an
October 2003 field trip of Dalhousie University’s Oceanography 4120/5120 class.
References
ctd.trim
Trim start/end portions of a CTD cast
Description
Trim start/end portions of a CTD cast.
Usage
ctd.trim(x, method="downcast",parameters=NULL, verbose=FALSE)
Arguments
x
A ctd object, e.g. as read by read.ctd.
method
Various methods exist, some of which use parameters:
"downcast"
Select only data for which the CTD is descending. This is done in stages.
1. The pressure data are despiked with a smooth() filter with method "3R". This
removes wild spikes that arise from poor instrument connections, etc.
2 Any data with negative pressures are deleted. This removes in-air data.
3. The maximum pressure is determined, and data acquired subsequent to that
point are deleted. This removes the upcast and any subsequent data.
4. At this stage, most datasets consist only of the actual downcast, plus an initial
period of equilibration during which pressure is nearly constant. Trimming this
equilibration period is surprisingly difficult, and is done in two stages. First, the
first-difference of pressure is computed, along with its confidence interval. (By
default, the 0.95 confidence level is used but parameters[1] will be used if
14
ctd.trim
provided.) Points are removed if their first difference in pressure is less than this
lower limit.
5. This often leaves a handful of equilibration points that just happened to
be falling through the water column (e.g. by heaving of the vessel in surface
waves). To remove such points, a regression is done of pressure against scan
number, and the scan number at which the regression passes through zero pressure is noted. Points measured before this scan number are deleted.
"index"
Select values only in indicated list of indices, e.g. selection <- ctd.trim(ctd,
"index", seq(10,30)) selects data points 10, 11, ... 30.
"(ANYTHING ELSE)"
Select data only if the named item (e.g. scan, time, etc.) falls in the range
of values indicated by parameters. If one parameter is given, it is a lower
limit. If two parameters are given, they are a range. For example, ctd2 <ctd.trim(ctd, "scan", 5) starts at scan number 5 and continues to
the end, while ctd3 <- ctd.trim(ctd, "scan", c(5,100)) also
starts at scan 5, but extends only to scan 100.
parameters
Depends on method; see above.
verbose
If set to TRUE, some debugging information is provided.
Details
For a quick look at the data, the method="downcast" scheme is normally quite adequate. However, a wise user will seek want to exert more control over the trimming process. Visual inspection
is a good way to do this, using plot.ctd.scan() together with ctd.trim. Normally, this
involves identifying by eye an initial period in which the CTD is in the air or unequilibrated in the
water, and a final period in which the CTD is no longer descending. Quite often this final period is
easier to find by eye than with the downcast method, since the instrument operator may leave the
device in deep water for some extra time to fire off a water bottle, etc., yielding problematic CTD
data (but with some wonderful chemical or biological samples).
Value
A new ctd object.
Author(s)
Dan Kelley [email protected]
References
The Seabird CTD instrument is described at http://www.seabird.com/products/spec_
sheets/19plusdata.htm.
See Also
The ctd object may be read with read.ctd. plot.ctd.scan is very useful in providing
guidance for trimming with ctd.trim.
ctd.update.header
15
Examples
library(oce)
data(ctd)
ctd.trimmed <- ctd.trim(ctd, "pressure", c(3, 5))
summary(ctd.trimmed)
ctd.update.header
Update a CTD header
Description
Update the header of a CTD object
Usage
ctd.update.header(x, debug=FALSE)
Arguments
x
debug
A ctd object, e.g. as read by read.ctd.
Set to TRUE for debugging.
Details
Update the header of a CTD object, e.g. adjusting nvalues and the span of each column. This
is done automatically by ctd.trim, for example.
Value
A new ctd object.
Author(s)
Dan Kelley [email protected]
References
The Seabird CTD instrument is described at http://www.seabird.com/products/spec_
sheets/19plusdata.htm.
See Also
read.ctd reads a CTD object, and write.ctd writes one.
Examples
library(oce)
data(ctd)
ctd$data$p <- ctd$data$p + 3 # adjust pressures
ctd.new <- ctd.update.header(ctd)
16
ctd.write
ctd.write
Write a CTD data object as a .cnv file
Description
Write a CTD data object as a .cnv file.
Usage
ctd.write(object, file=stop("'file' must be specified"))
Arguments
object
A ctd object, e.g. as read by read.ctd.
file
Either a character string (the file name) or a connection. This is a mandatory
argument.
Details
Writes a file in a format as for reading by read.ctd.
Value
Author(s)
Dan Kelley [email protected]
References
The Seabird CTD instrument is described at http://www.seabird.com/products/spec_
sheets/19plusdata.htm.
See Also
read.ctd.
Examples
library(oce)
data(ctd)
ctd.write(ctd, "ctd.cnv")
geod.dist
geod.dist
17
Geodesic distance on earth
Description
Compute geodesic distance on surface of earth.
Usage
km <- geod.dist(lat1, lon1, lat2, lon2);
Arguments
lat1
latitude or a list of latitudes
lon1
longitude or list of longitudes
lat2
latitude or list of latitudes
lon2
longitude or list of longitudes
Details
Solution of the geodetic inverse problem after T.Vincenty modified Rainsford’s method with Helmert’s
elliptical terms effective in any azimuth and at any distance short of antipodal standpoint/forepoint
must not be the geographic pole.
If the "1" and "2" lists are of equal length, then the result is the pairwise distances. However, if the
length of "2" is shorter than the length of "1", then only the first value in the "2" list is used, repeated
over and over to match the length of "1".
A common use is for "1" to contain a vector of positions along a cruise track, and for "2" to contain a
reference point; e.g. geod.dist(lats,lons,lats[1],lons[1]) gives distance along the track starting from
zero.
Value
Distance between "1" and "2" in metres, measured along the surface of the earth. If "1" is a vector,
the returned value is a vector of the same length.
Author(s)
Dan Kelley [email protected] packaged this, based on R code sent to him by Darren Gillis,
who in 2003 had modified Fortran code written in 1974 by (according to comment cards in the
source) L. Pfeifer and J. G. Gergen.
References
18
gravity
See Also
N/A.
Examples
# There are roughly 111km per degree of latitude
km <- geod.dist(45, 100, 46, 100)/1000
gravity
Acceleration due to earth gravity
Description
Compute g, the acceleration due to gravity, as a function of latitude.
Usage
g <- gravity(lat, degrees=TRUE);
Arguments
lat
degrees
Latitude in ◦ N or radians north of the equator.
Flag indicating whether degrees are used for latitude; if set to FALSE, radians
are used.
Details
Value not verified yet, except roughly.
Value
Acceleration due to gravity [m2 /s].
Author(s)
Dan Kelley [email protected]
References
Gill, A.E., 1982. Atmosphere-ocean Dynamics, Academic Press, New York, 662 pp.
Caution: Fofonoff and Millard (1983 UNESCO) use a different formula.
See Also
N/A.
Examples
g <- gravity(45) # 9.8
lat.format
lat.format
19
Format a latitude
Description
Format a latitude, using "S" for negative latitude.
Usage
lat.label <- lat.format(lat)
Arguments
lat
latitude in ◦ N north of the equator.
Details
Value
A character string.
Author(s)
Dan Kelley [email protected]
References
See Also
lon.format and latlon.format.
Examples
20
latlon.format
latlon.format
Format a latitude-longitude pair
Description
Format a latitude-longitude pair, using "S" for negative latitudes, etc.
Usage
latlon <- latlon.format(lat, lon)
Arguments
lat
latitude in ◦ N north of the equator.
lon
longitude in ◦ N east of Greenwich.
Details
Value
A character string.
Author(s)
Dan Kelley [email protected]
References
See Also
lat.format and lon.format.
Examples
lobo
21
lobo
Sample lobo dataset
Description
This is sample lobo dataset obtained in the Northwest Arm of Halifax by Satlantic.
Usage
data(ctd)
Format
Author(s)
Dan Kelley [email protected]
Source
Satlantic.
References
http://www.satlantic.com/default.asp?mn=1.15.27.139. http://www.mbari.
org/lobo/.
lon.format
Format a longitude
Description
Format a longitude, using "W" for west longitude.
Usage
lon.label <- lon.format(lon)
Arguments
lon
Details
longitude in ◦ N east of Greenwich.
22
magic
Value
A character string.
Author(s)
Dan Kelley [email protected]
References
See Also
lat.format and latlon.format.
Examples
magic
Find the type of an oceanographic data file
Description
Find the type of an oceanographic data file, by examining the first line.
Usage
magic(file)
Arguments
file
a connection or a character string giving the name of the file to be checked.
Details
This function tries to infer the file type from the first line.
Value
A character string indicating the file type, or "unknown", if the type cannot be determined.
Author(s)
Dan Kelley [email protected]
See Also
This is used mainly by read.oce.
make.section
23
Bind CTD profiles together into a cross section
make.section
Description
Combine a series of CTD profiles together to create a section.
Usage
make.section(...)
Arguments
...
list of CTD objects, perhaps read with read.ctd().
Details
This is still in development. Decisions need to be made about whether the stations should be decimated to the same levels, whether they should be in some spatial or temporal order, etc.
Value
A section object.
Author(s)
Dan Kelley [email protected]
References
See Also
read.ctd reads CTD data.
Examples
library(oce)
data(ctd)
ctd.warmed <- ctd
ctd.warmed$data$temperature <- ctd.warmed$data$temperature + 0.5
section <- make.section(ctd, ctd.warmed)
summary(section)
plot(section, at=c(1,2), labels=c("Original","Warmed"))
24
oce.as.POSIXlt
oce.as.POSIXlt
More general form of as.POSIXlt
Description
A more general form of as.POSIXlt.
Usage
oce.as.POSIXlt(x, tz = "")
Arguments
x
a date, as for as.POSIXlt, but also including forms in which the month name
appears.
tz
the timezone, as for as.POSIXlt
Details
Used in parsing headers, this function is built on the standard as.POSIXlt function. the only
difference is that this also recognizes dates of forms such as "Aug 23 2002", "August 23
2002", "2002 Aug 23", and "2002 23 Aug". (The month may appear in abbreviated form
or written in full, and may be capitalized or not.)
Value
A POSIXlt object.
Author(s)
Dan Kelley [email protected]
References
See Also
as.POSIXlt, from which this is derived.
Examples
plot.TS
plot.TS
25
Plot temperature-salinity diagram for seawater (CTD) data
Description
Plot temperature-salinity diagram for seawater (CTD) data.
Usage
plot.TS(x,
rho.levels = 6,
grid = FALSE,
col.grid = "lightgray",
rho1000 = FALSE,
col = par("col"),
col.rho = "darkgray",
cex.rho = 0.8*par("cex"),
cex = par("cex"),
pch = 20,
...)
Arguments
x
A cdt object, e.g. as read by read.ctd.
rho.levels
Either a list of density levels for which to draw isopycnal lines, or a suggestion
for the number of levels. In the latter case, pretty() is used to select levels.
grid
a flag that can be set to TRUE to get a grid.
col.grid
color of grid.
rho1000
if TRUE, label isopycnals as e.g. 1024; if FALSE, label as e.g. 24
col
colour for symbols.
col.rho
colour for isopycnal lines.
cex.rho
size of isopycnal labels.
cex
size of symbols on graph.
pch
code for symbols on graph.
...
optional arguments passed to plotting functions.
Details
Creates a temperature-salinity plot for a CTD cast, with labeled isopycnals.
Value
None.
26
plot.coastline
Author(s)
Dan Kelley [email protected]
References
See Also
summary.ctd summarizes the information, while read.ctd scans it from a file.
Examples
## Not run:
library(oce)
profile <- read.ctd("/usr/local/lib/R/library/oce/demo/ctdprofile.cnv")
attach(profile)
plot.TS(profile)
# North Atlantic thermocline water, mixing to Antarctic Intermediate Water
# (after Defant's analysis)
N <- 10
Srange <- c(34.15, 35.94)
Trange <- c(3.3,18)
SS <- Srange[1] + (Srange[2] - Srange[1]) *(1:N)/(N-1) + 0.01*rnorm(N)
TT <- Trange[1] + (Trange[2] - Trange[1]) *(1:N)/(N-1) + 0.01*rnorm(N)
plot.TS(as.CTD(S=SS, T=TT, p=0))
## End(Not run)
plot.coastline
Plot a coastline
Description
Plot a coastline.
Usage
## S3 method for class 'coastline':
plot(x, ...)
Arguments
x
A coastline object, e.g. as read by read.coastline.
...
optional arguments passed to plotting functions.
Details
Plots a coastline.
plot.ctd
27
Value
None.
Author(s)
Dan Kelley [email protected]
References
http://www.ngdc.noaa.gov/mgg/shorelines/shorelines.html
See Also
summary.coastline summarizes the information, while read.coastline scans it from a
file.
Examples
library(oce)
data(coastline.maritimes)
plot(coastline.maritimes)
plot.ctd
Plot seawater (CTD) data
Description
Plot a summary diagram for CTD data.
Usage
## S3 method for class 'ctd':
plot(x,ref.lat=NaN, ref.lon=NaN, grid=TRUE, col.grid="lightgray", ...)
Arguments
x
A cdt object, e.g. as read by read.ctd.
ref.lat
Latitude of reference point for distance calculation
ref.lon
Longitude of reference point for distance calculation
grid
Set TRUE to get a grid on all plots.
col.grid
color of grid.
...
optional arguments passed to plotting functions. A common example is to set
df, for use in sw.N2 calculations.
28
plot.ctd.scan
Details
Creates a summary plot for a CTD cast, with a temperature-salinity diagram as well as profiles of
temperature, salinity, and density; a table of information about the cast is also plotted.
Value
None.
Author(s)
Dan Kelley [email protected]
References
See Also
summary.ctd summarizes the information, while read.ctd scans it from a file.
Examples
library(oce)
data(ctd)
plot(ctd)
plot.ctd.scan
Plot seawater (CTD) data
Description
Plot CTD data as time-series against scan number, to aide in trimming.
Usage
plot.ctd.scan(x, name = "scan",
S.col = "darkgreen", T.col= "darkred", p.col = "blue", ...)
Arguments
x
A cdt object, e.g. as read by read.ctd.
name
name of variable for x axis
S.col
colour for salinity
T.col
colour for temperature
p.col
colour for pressure
...
optional arguments passed to plotting functions.
plot.lobo
29
Details
Plots CTD data as time-series against the scan number, as an aide to trimming to downcasts, etc.
Value
None.
Author(s)
Dan Kelley [email protected]
References
See Also
summary.ctd summarizes a CTD object plot.ctd plot summary diagram of CTD object.
read.ctd scans CTD object from a file.
Examples
library(oce)
data(ctd)
plot.ctd.scan(ctd)
plot.lobo
Plot lobo data
Description
Plot a summary diagram for lobo data.
Usage
## S3 method for class 'lobo':
plot(x, ...)
Arguments
x
A lobo object, e.g. as read by read.lobo.
...
optional arguments passed to plotting functions.
Details
Creates a summary plot for a lobo dataset.
30
plot.profile
Value
None.
Author(s)
Dan Kelley [email protected]
References
http://www.satlantic.com/default.asp?mn=1.15.27.139 http://www.mbari.
org/lobo/
See Also
summary.lobo summarizes the information, while read.lobo scans it from a file.
Examples
## Not run:
uri <- paste("http://loboviz.satlantic.com/cgi-bin/nph-data.cgi?",
"min_date=20070110&max_date=20091230",
"&x=date&",
"y=current_across1,current_along1,nitrate,fluorescence,salinity,temperature&",
"data_format=text",sep="")
l <- read.lobo(uri)
plot(d)
## End(Not run)
plot.profile
Plot a CTD profile of various quantities
Description
Plot a CTD profile, in any of several common formats.
Usage
plot.profile(x,
type="S",
col.S="darkgreen",
col.t="red",
col.rho="blue",
col.N2="brown",
grid=FALSE,
col.grid="lightgray",
...)
plot.profile
31
Arguments
x
A cdt object, e.g. as read by read.ctd.
type
Type of profile to plot, from the list below.
S Profile of salinity.
T Profile of in-situ temperature.
sigmatheta Profile of density (expressed as σθ ).
S+T Profile of salinity and temperature within a single axis frame.
N2 Profile of square of buoyancy frequency N 2 , calculated with sw.N2 with
an optional argument setting of df=length(x$p)/4 to do some smoothing.
sigmatheta+N2 Profile of sigma-theta and the square of buoyancy frequency within a single
axis frame.
col.S
Color for salinity profile.
col.t
Color for temperature.
col.rho
Color for density.
col.N2
Color for square of buoyancy frequency.
grid
Set TRUE to get a grid.
col.grid
Grid colour.
...
Optional arguments passed to other functions. A common example is to set df,
for use in sw.N2 calculations.
Details
Value
None.
Author(s)
Dan Kelley [email protected]
References
See Also
read.ctd scans ctd information from a file, and plot.TS plots a temperature-salinity diagram.
32
plot.sealevel
Examples
## Not run:
library(oce)
data(ctd)
# ctd <- read.ctd("ctd.cnv")
summary(ctd)
plot(ctd)
plot.profile(ctd, type="T")
## End(Not run)
plot.sealevel
Plot sealevel data
Description
Plot a summary diagram for sealevel data.
Usage
## S3 method for class 'sealevel':
plot(x, focus.time=NULL, ...)
Arguments
x
A sealevel object, e.g. as read by read.sealevel.
focus.time
if provided, the the time interval on which to focus, each a string in a format
suitable for interpretation by as.POSIXct; see the example.
...
optional arguments passed to plotting functions.
Details
Creates a plot for a sea-level dataset, in one of two varieties.
If a focus.time is provided, then the plot is a simple time series extending between the two
times.
If a focus.time is not not provided, then a multi-panel display is drawn. The top panel shows
the entire timeseries; since this typically extends over a year, the graph mainly shows low-frequency
modulations of the tide, such as spring-neap cycles. The second panel focusses on the first month
of data, providing a quick visual signal as to the nature of the tide, e.g. mainly semidiurnal, mainly
diurnal, or mixed. In both of these panels, the sealevel is plotted as an anomaly in excess of the
mean over the whole timeseries. This mean value is indicated in the right-hand margin. If the
sealevel series contains missing values, then only these two panels are drawn. However, if it has
no missing values, then two spectral representations are also drawn. The first of these is a power
spectrum, with some common tidal constituents being indicates with lines and labels. The units
are m2 per cycle-per-day. The second, and thus the lower of the four panels, is a cumulative graph
of the square root of the power spectrum. The unit for this graph is m, so that the step for each
tidal constituent may be interpreted as the amplitude of that constituent, and the largest value on the
graph gives the standard deviation of sealevel height.
plot.section
33
Value
None.
Author(s)
Dan Kelley [email protected]
References
The example refers to Hurricane Juan, which caused a great deal of damage to Halifax in 2003.
Since this was in the era of the digital photo, a casual web search will uncover some spectacular images of damage, from both wind and storm surge. The wikipedia entry http://en.
wikipedia.org/wiki/Hurricane_Juan provides a good entry to the topic, with the Canadian Hurricane Centre’s http://www.atl.ec.gc.ca/weather/hurricane/juan/summary_
e.html filling in some more technical details.
See Also
summary.sealevel summarizes the information, while read.sealevel scans it from a file.
Examples
library(oce)
data(sealevel)
# Overall plot
plot(sealevel)
# Focus on 2003-Sep-28 to 29th, the time when Hurricane Juan caused flooding
plot(sealevel, focus.time=c("2003-09-23","2003-10-05"))
abline(v=as.POSIXct("2003-09-28 23:30:00"), col="red", lty="dotted")
mtext("Hurricane\nJuan", at=as.POSIXct("2003-09-28 23:30:00"), col="red")
plot.section
Plot a CTD section
Description
Plot a CTD section.
Usage
## S3 method for class 'section':
plot(x,
field=NULL,
at=NULL,
labels=TRUE,
grid=TRUE,
col.grid="lightgray",
coastline=NULL,
...)
34
plot.section
Arguments
x
a section object, e.g. as created by make.section.
field
is the field to plot. Common options are "temperature", "salinity",
and "density", although plot.section will accept any named field that
is present in the constituent CTD profiles. If NULL (the default) is given, then
temperature, salinity and density are graphed.
at
if NULL (the default), the x axis will indicate the distance of the stations from
the first in the section. (This may give errors in the contouring routine, if the
stations are not present in a geographical order.) If a list, then it indicates the
values at which stations will be plotted.
labels
either a logical, indicating whether to put labels on the x axis, or a vector that is
a list of labels to be placed at the x positions indicated by at.
grid
if TRUE, grid lines will be drawn on plots.
col.grid
color of grid lines.
coastline
if supplied, this is a coastline object, to be used in a station map
...
optional arguments passed to plotting functions, e.g. using labcex=1 will
increase the size of contour labels.
Details
Creates a summary plot for a CTD section. If a field is supplied, then just that single field
is contoured. If no field is supplied, then temperature, salinity, and sigma are contoured. A
location plot is also drawn if a coastline is provided; in this, the first station in the section is
indicated with a different symbol than the rest.
The y-axis for the contours is pressure, plotted in the conventional reversed form, so that the water
surface appears at the top of the plot. The x-axis is more complicated. If at is not supplied,
then the routine calculates x as the distance between the first station in the section and each of the
other stations. (This will produce an error if the stations are not ordered geographically, because
the contour routine cannot handle non-increasing axis coordinates.) If at is specified, then it is
taken to be the location, in arbitrary units, along the x-axis of labels specified by labels; the way
this works is designed to be the same as for axis.
Value
None.
Author(s)
Dan Kelley [email protected]
See Also
Sections are created with make.section, and may be summarized with summary.section.
processing.log.append
35
Examples
library(oce)
data(section)
data(coastline.halifax)
plot(section, coastline=coastline.halifax)
processing.log.append
Append item to the processing log of object
Description
Appends a time-stamped item to the processing log of an object.
Usage
processing.log.append(x, action="")
Arguments
x
An oce object.
action
A character string describing the action.
Details
This is used to add a time-stamped item to the processing log of the object.
Value
The object, with a new entry in its log.
Author(s)
Dan Kelley [email protected]
References
See Also
36
processing.log.summary
Examples
## Not run:
# This (and another typographical correction) was done in creating data(section).
stn15 <- ctd.decimate(ctd.trim(read.ctd("BED0315.CNV")),p=p)
stn15$latitude <- stn15$latitude + 1
stn15 <- processing.log.append(stn15, "DEK: add 1 to latitude, correcting a typo")
## End(Not run)
processing.log.summary
Summarize the processing log of an object
Description
Summarize the processing log of an object.
Usage
processing.log.summary(object)
Arguments
object
An oce object.
Details
Prints log entries with UTC timestamps.
Value
None.
Author(s)
Dan Kelley [email protected]
References
See Also
Examples
library(oce)
data(ctd)
processing.log.summary(ctd)
read.coastline
read.coastline
37
Scan a coastline data file
Description
Read a coastline file in mapgen, matlab, or Splus format
Usage
read.coastline(file,type=c("R","S","mapgen"),debug=FALSE)
Arguments
file
Name of file containing coastline data.
type
Type of file, one of "R", "S", or "mapgen"
debug
Set to TRUE to print information about the header, etc.
Details
The S and R formats are identical, and consist of two columns, lon and lat, with land-jump segments
separated by lines with two NAs.
The MapGen format is of the form
# -b
-16.179081
-16.244793
28.553943
28.563330
BUG: the ’arc/info ungenerate’ format is not yet understood.
Value
A coastline object containing
processing.log
A processing log.
data
a list containing longitude, in decimal degrees, positive east of Greenwich,
and latitude, in decimal degrees postive north of the equator.
Author(s)
Dan Kelley [email protected]
References
http://www.ngdc.noaa.gov/mgg/shorelines/shorelines.html
38
read.ctd
See Also
The generic function read.oce provides an alternative to this.
Coastlines may be summarized with summary.coastline and plotted with plot.coastline.
Examples
## Not run:
library(oce)
cl <- read.coastline("7404.dat")
# If no plot yet:
plot(cl)
# To add to an existing plot:
lines(cl$data$longitude, cl$data$latitude)
# Note: another trick is to do something like the following,
# to get issues of whether longitude is defined in (-180,180)
# or (0,360)
lines(cl$datas$longitude, cl$data$latitude)
lines(cl$data$longitude-360, cl$data$latitude)
## End(Not run)
read.ctd
Read a CTD data file
Description
Read a CTD data file, producing an object of type ctd.
Usage
read.ctd(file, type=NULL, debug=FALSE,
columns=NULL, check.human.headers=TRUE)
Arguments
file
a connection or a character string giving the name of the file to load.
type
if NULL, then the first line is studied, in order to determine the file type. If
type="SBE19", then a Seabird 19 (or similar) CTD format is assumed. If
type="WOCE" then a WOCE-exchange file is assumed.
debug
a flag that can be set to TRUE to turn on debugging.
if NULL, then read.ctd tries to infer column names from the header. If
a list, then it will be taken to be the list of columns. The list must include
"pressure", "temperature" and either "conductivity" or "salinity",
or else very little can be done with the file.
check.human.headers
produces warnings for missing human-written header items.
columns
read.ctd
39
Details
Oceanographers use CTD (conductivity-temperature-depth) instruments to measure key properties
of the ocean, such as water temperature, salinity, etc. This function reads CTD datasets that have
been stored in common formats, and could be extended to accommodate other formats if needed.
read.ctd does a reasonable job of inferring meta-information from file headers, but it still has
limitations. For example, in the first file tested during development, the sampling rate was written
as * sample rate = 1 scan every 0.5 seconds, while in the second test file it was
written * Real-Time Sample Interval = 0.125 seconds. Similarly, read.ctd can
be challenged in parsing latitudes and longitudes in the wide variety of ways that humans choose.
Still, such limitations are not really pressing in practice, since the ctd object is made available
for manipulation. If read.ctd cannot scan 33 and a third as a latitude, just examine the
header (stored as a list in object$header), and do something like object$latitude <33 + 1/3.
It should be noted that different file types provide different meta-information. For example, the
WOCE exchange format binds together the institute name and the initials of the chief scientist into a
single string that read.ctd cannot parse, so both object$institute and object$scientist
are left blank for WOCE files.
Value
A ctd object containing information about the station (e.g. latitude, etc.), along with vectors
containing the acquired data (e.g. S, etc.). The full header is also contained in the list. The returned
list is as follows, but the reader is cautioned that some items may be blank for some file formats.
header[]
the header itself, normally containing several dozen lines of information
filename
name of the file passed to read.ctd
filename.orig
name of the original file saved by the instrument (normally a hex file)
system.upload.time
system upload time
ship
name of the ship from which the CTD was deployed
scientist
name of the scientist taking the data
institute
name of the institute
address
the address of the institute where the scientist
cruise
name of cruise
section.id
name of section
station
station number or name
date
date of lowering of CTD into the water
latitude
latitude, in decimal degrees, positive north of equator
longitude
longitude, in decimal degrees, positive if east of Greenwich and west of dateline
recovery
date of recovery of CTD
sample.interval
time interval between samples [s]
40
read.lobo
water.depth the water depth at the site [m]
processing.log
A processing log.
data
A data table containing the profile data as vectors. The column names are discovered from the header, and may thus differ from file to file. For example, some
CTD instruments may have a fluorometer connected, others may not. The following vectors are normally present: data$pressure, data$salinity,
data$temperature, and data$sigma. Note that data$sigma is calculated from the pressure, salinity, and temperature in the file, using sw.sigma.
Author(s)
Dan Kelley [email protected]
References
The Seabird CTD instrument is described at http://www.seabird.com/products/spec_
sheets/19plusdata.htm, and the WOCE-exchange format is described at http://www.
nodc.noaa.gov/woce_V2/disk02/exchange/exchange_format_desc.htm
See Also
The generic function read.oce provides an alternative to this.
A ctd object may be summarized with summary.ctd and plotted with plot.ctd.
Examples
## Not run:
library(oce)
x <- read.ctd("/usr/local/lib/R/library/oce/demo/ctdprofile.cnv")
plot(x) # summary with TS and profiles
plot.TS(x) # just the TS
## End(Not run)
read.lobo
Read a lobo data file
Description
Read a data file created by a LOBO instrument.
Usage
read.lobo(file, cols=7)
read.lobo
41
Arguments
file
A connection or a character string giving the name of the file to load.
cols
Number of columns in dataset.
Details
This version of read.lobo is really quite crude, having been developed mainly for a “predict the
Spring bloom” contest at Dalhousie University. In particular, the function assumes that the data
columns are exactly as specified in the Examples section; if you reorder the columns or add new
ones, this function is unlikely to work correctly. Furthermore, it should be noted that the file format
was inferred simply by downloading files; the supplier makes no claims that the format will be fixed
in time.
It is also worth noting that there is no read.oce equivalent to read.lobo, because the file
format has no recognizable header.
Value
A lobo object containing:
header
The files’ header.
processing.log
The processing log.
time
Times of observations in the time series.
u
Time series of u component of velocity.
v
Time series of v component of velocity.
nitrate
Time series of nitrate concentration.
fluorescence Time series of fluorescence.
S
Time series of salinity.
T
Time series of temperature.
p
Time series of pressure.
data
The files’s data, as a simple list.
Note
The oce author was unable to find a description of the data format, and so read.lobo makes
some restrictive assumptions about the data format, expecting to find exactly 7 columns, whose
names in the header contain the words "date", "current across", "current along", "nitrate", "fluorescence", "salinity", and "temperature". If these are not found, read.lobo is likely to fail in some
way. Luckily, the code is written in a simple way, so that users should be able to alter it easily if,
for example, the names of the current components change to "current to the east", etc.
Author(s)
Dan Kelley [email protected]
42
read.oce
Source
The file was created with the lines given in the example.
References
http://www.satlantic.com/default.asp?mn=1.15.27.139 http://www.mbari.
org/lobo/
See Also
A lobo object may be summarized with summary.lobo and plotted with plot.lobo.
Examples
## Not run:
library(oce)
uri <- paste("http://loboviz.satlantic.com/cgi-bin/nph-data.cgi?",
"min_date=20070220&max_date=20070305",
"&x=date&",
"y=current_across1,current_along1,nitrate,fluorescence,salinity,temperature&",
"data_format=text",sep="")
lobo <- read.lobo(uri)
summary(lobo)
## End(Not run)
read.oce
Read an oceanographic data file
Description
Read an oceanographic data file, auto-discovering the file type from the first line of the file.
Usage
read.oce(file, ...)
Arguments
file
a connection or a character string giving the name of the file to load.
...
arguments to be handed to whichever instrument-specific reading function is
selected, based on the header.
Details
This function tries to infer the file type from the first line, using magic. If it can be discovered,
then an instrument-specific file reading function is called, with the file and with any additional
arguments being supplied.
read.sealevel
43
Value
On success, an oce object of type ctd, sealevel, coastline, or lobo. On failure, an error
occurs.
Author(s)
Dan Kelley [email protected]
See Also
The file type is determined by magic. If the file type can be determined, then one of the following
is called: read.ctd, read.coastline read.lobo, or read.sealevel.
Examples
## Not run:
library(oce)
x <- read.oce("/usr/local/lib/R/library/oce/demo/ctdprofile.cnv")
plot(x) # summary with TS and profiles
plot.TS(x) # just the TS
## End(Not run)
read.sealevel
Read a sea-level data file
Description
Read a data file holding sea level data. BUG: the time vector assumes GMT, regardless of the
GMT.offset value.
Usage
read.sealevel(file, debug=FALSE)
Arguments
file
A connection or a character string giving the name of the file to load.
debug
Set to TRUE to get debugging information during processing.
Details
This function starts by scanning the first line of the file, from which it determines whether the file is
in one of two known formats: the tabular format used at the Hawaii archive centre, or the commaseparated-value format used by the Marine Environmental Data Service. If the file is in neither of
these known formats, the user might wish to scan the data by some other means, and then to use
as.sealevel to create the sealevel object.
44
read.sealevel
Value
A sealevel object containing
header
The header line (helpful if detail extraction failed)
station.number
identifier for the station.
station.version
see online docs at site mentioned in References.
station.name name of station
region
a region code.
year
year in which the observations were made.
latitude
latitude, decimal degrees, positive north of equator.
longitude
longitude, decimal degrees, positive east of Greenwich.
GMT.offset
offset from GMT time.
decimation.method
see online docs at site mentioned in References.
reference.offset
a reference offset; see online docs at site mentioned in References.
reference.code
a reference code; see online docs at site mentioned in References.
units
unit of observations (normally "MM")
n
number of observations
a list containing t, times of observations and eta, the sealevel observations, in
units units (normally, mm)
processing.log
a processing log.
data
Author(s)
Dan Kelley [email protected]
References
The Hawaii archive site at http://ilikai.soest.hawaii.edu/uhslc/datai.html
provides a graphical interface for downloading sealevel data; the format is described at ftp://
ilikai.soest.hawaii.edu/rqds/hourly.fmt. The MEDS data are at http://www.
meds-sdmm.dfo-mpo.gc.ca/meds/Databases/TWL/TWL_inventory_e.htm.
See Also
The generic function read.oce provides an alternative to this. A sealevel object may be
summarized with summary.sealevel and plotted with plot.sealevel.
A sealevel object can also be constructed with as.sealevel.
sealevel
45
Examples
## Not run:
library(oce)
h <- read.sealevel("ftp://ilikai.soest.hawaii.edu/rqds/pacific/monthly/m652a.dat")
summary(h)
plot(h)
## End(Not run)
sealevel
Sample sea-level data set
Description
This sample sea-level dataset is the 2003 record from Halifax Harbour in Nova Scotia, Canada.
Note that Hurricane Juan hit Halifax on September 28th of 2003, causing a strong storm surge.
Usage
data(sealevel)
Author(s)
Dan Kelley [email protected]
Source
The data were downloaded from MEDS and then read with read.sealevel.
References
The MEDS archive is at http://www.meds-sdmm.dfo-mpo.gc.ca/meds/Databases/
TWL/TWL_inventory_e.htm. An entry to the literature about Hurricane Juan is at http:
//www.atl.ec.gc.ca/weather/hurricane/juan/.
section
Sample seawater (CTD) section
Description
This is sample CTD section provided for testing.
Usage
data(section)
46
summary.coastline
Format
The individual stations are availabe as section$stations[[1]] through to section$stations[[7]],
each of which is an object of type ctd.
Author(s)
Dan Kelley [email protected]
Source
This section is based on measurements made during October of 2003 in Halifax Harbour by students
in the Introduction to Physical Oceanography class at Dalhousie University, taught by Dan Kelley;
supervision at sea was provided by teaching assistant Natacha Bernier, at the time a PhD student
at Dalhousie. Note the alteration of two station locations, to correct typographical errors that were
made at sea, perhaps by someone who was distracted by the boat motion.
library(oce)
p <- seq(0, 30, 2)
stn08 <- ctd.decimate(ctd.trim(read.ctd("BED0308.CNV")),p=p)
stn09 <- ctd.decimate(ctd.trim(read.ctd("BED0309.CNV")),p=p)
stn10 <- ctd.decimate(ctd.trim(read.ctd("BED0310.CNV")),p=p)
stn01 <- ctd.decimate(ctd.trim(read.ctd("BED0301.CNV")),p=p)
stn11 <- ctd.decimate(ctd.trim(read.ctd("BED0311.CNV")),p=p)
stn12 <- ctd.decimate(ctd.trim(read.ctd("BED0312.CNV")),p=p)
stn12$latitude <- 44 + 39.894 / 60
stn12 <- processing.log.append(stn12, "DEK change lat minutes from 39.394 to 39.894
stn13 <- ctd.decimate(ctd.trim(read.ctd("BED0313.CNV")),p=p)
stn15 <- ctd.decimate(ctd.trim(read.ctd("BED0315.CNV")),p=p)
stn15$latitude <- stn15$latitude + 1
stn15 <- processing.log.append(stn15, "DEK add 1 to latitude, correcting a typo")
section <- make.section(stn08, stn09, stn10, stn01, stn11, stn12, stn13, stn15)
The stations cover a 14 km region running from station 308, near the Sackville River, seaward to
station 315, at the entrance to the general Harbour, offshore of the lovely Point Pleasant Park.
References
A summary of the stations can be obtained from summary.section, and a plot can be created
with plot.section.
summary.coastline
Summarize a coastline data object
Description
Summarizes coastline length, bounding box, etc.
summary.ctd
47
Usage
## S3 method for class 'coastline':
summary(object, ...)
Arguments
object
A coastline object, e.g. as read by read.coastline.
...
Passed to children.
Details
Value
Author(s)
Dan Kelley [email protected]
References
http://www.ngdc.noaa.gov/mgg/shorelines/shorelines.html
See Also
The coastline object may be read with read.coastline and plotted with plot.coastline.
Examples
## Not run:
library(oce)
cl <- read.coastline("7404.dat")
plot(cl)
## End(Not run)
summary.ctd
Summarize a seawater (CTD) data object
Description
Summarizes some of the data in a CTD object.
Usage
## S3 method for class 'ctd':
summary(object, ...)
48
summary.lobo
Arguments
object
A ctd object, e.g. as read by read.ctd.
...
Passed to children.
Details
Pertinent summary information is presented, including the sampling location, data ranges, etc.
Value
(fill in later)
Author(s)
Dan Kelley [email protected]
References
The Seabird CTD instrument is described at http://www.seabird.com/products/spec_
sheets/19plusdata.htm.
See Also
The ctd object may be read with read.ctd.
Examples
## Not run:
library(oce)
profile <- read.ctd("/usr/local/lib/R/library/oce/demo/ctdprofile.cnv")
summary.ctd(profile)
summary(profile)
## End(Not run)
summary.lobo
Summarize a lobo data object
Description
Summarizes some of the data in a lobo object.
Usage
## S3 method for class 'lobo':
summary(object, ...)
summary.sealevel
49
Arguments
object
A lobo object, e.g. as read by read.lobo.
...
Passed to children.
Details
Pertinent summary information is presented, including the sampling interval, data ranges, etc.
Value
Author(s)
Dan Kelley [email protected]
References
http://www.satlantic.com/default.asp?mn=1.15.27.139 http://www.mbari.
org/lobo/
See Also
The lobo object may be read with read.ctd.
Examples
## Not run:
library(oce)
uri <- paste("http://loboviz.satlantic.com/cgi-bin/nph-data.cgi?",
"min_date=20070110&max_date=20091230",
"&x=date&",
"y=current_across1,current_along1,nitrate,fluorescence,salinity,temperature&",
"data_format=text",sep="")
l <- read.lobo(uri)
summary(l)
## End(Not run)
summary.sealevel
Summarize a sealevel data object
Description
Summarizes some of the data in a sealevel object.
Usage
## S3 method for class 'sealevel':
summary(object, ...)
50
summary.section
Arguments
object
A sealevel object, e.g. as read by read.sealevel.
...
Passed to children.
Details
Pertinent summary information is presented.
Value
No value is returned.
Author(s)
Dan Kelley [email protected]
References
ftp://ilikai.soest.hawaii.edu/rqds/hourly.fmt.
See Also
read.sealevel reads the information, while plot.sealevel plots it.
Examples
library(oce)
data(sealevel)
summary(sealevel)
summary.section
Summarize a CTD section
Description
Summarize a CTD section.
Usage
## S3 method for class 'section':
summary(object, quiet, ...)
Arguments
object
a section object, e.g. as read by make.section.
quiet
set TRUE to prevent this from printing anything, e.g. if the goal is just to get the
return value.
...
passed to children.
sw.N2
51
Details
Pertinent summary information is presented about the stations in the section.
Value
Returns (invisibly) a data frame with elements filename, the original name of CTD file for a
given station, and the station coordinates stored in latitude (decimal degrees, positive north of
the equator), and longitude (in decimal degrees, positive east of Greenwich).
Author(s)
Dan Kelley [email protected]
See Also
A section object may be created with make.section.
Examples
library(oce)
data(section)
summary(section)
sw.N2
Seawater square of buoyancy frequency
Description
Compute N 2 , the square of the buoyancy frequency for a seawater profile.
Usage
buoy.freq.2 <- sw.N2(p, sigma.theta, ...)
Arguments
p
sigma.theta
...
in-situ pressure [dbar]
Surface-referenced potential density minus 1000 [kg/m3 ]
Extra arguments that will be passed to smooth.spline if supplied. A common example is to set df, the degrees of freedom for the spline fit; if not set,
this will be set to the value length(p)/4.
Details
The result is calculated from the derivative of a smoothing cubic spline fitted to the density profile
using smooth.spline. Optional arguments in . . . are passed to this routine, and this gives the
user a great deal of control over the smoothing technique; see the documentation on smooth.spline
for details. For example, plot.profile uses df=length(x$p)/4 as an optional argument
to N2 to do some smoothing of the density profile.
52
sw.S.C.T.p
Value
Square of buoyancy frequency [radian/s].
Author(s)
Dan Kelley [email protected]
References
See Also
Examples
library(oce)
data(ctd)
p <- ctd$data$pressure
sigthe <- sw.sigma.theta(ctd$data$temperature, ctd$data$salinity, ctd$data$pressure)
par(mfcol=c(3,1))
plot(sigthe, -p)
lines(sigthe, -p)
plot(sw.N2(p,sigthe), -p)
lines(sw.N2(p,sigthe), -p)
abline(v=0)
# Demonstrate the effect of the df parameter in smooth.spline()
lines(sw.N2(p,sigthe,df=length(p)/4), -p)
abline(v=0)
sw.S.C.T.p
Seawater salinity from conductivity ratio, temperature and pressure
Description
Compute salinity, given conductivity ratio, temperature, and pressure.
Usage
S <- sw.S.C.T.p(C, t, p);
Arguments
C
conductivity ratio [unitless]
t
in-situ temperature [◦ C]
p
pressure [dbar]
sw.S.T.rho
53
Details
Calculate S from what is actually measured by the CTD, i.e. the conductivity ratio C, the in-situ
temperature T, and the pressure p. Often this is done by the CTD processing software, but sometimes
it is helpful to do this directly, e.g. when there is a concern about mismatches in sensor response
times. S is calculated using the UNESCO algorithm described by Fofonoff and Millard (1983).
Value
Salinity [PSU].
Author(s)
Dan Kelley [email protected]
References
Fofonoff, P. and R. C. Millard Jr, 1983. Algorithms for computation of fundamental properties of
seawater. Unesco Technical Papers in Marine Science, 44, 53 pp
See Also
sw.conductivity
Examples
print(sw.S.C.T.p(1,15,2000))
# 34.25045
print(sw.S.C.T.p(1.2,20,2000)) # 37.24563
print(sw.S.C.T.p(0.65,5,1500)) # 27.99535
sw.S.T.rho
Seawater salinity from temperature and density
Description
Compute in-situ salinity, given temperature, density, and pressure.
Usage
S <- sw.S.T.rho(t, sig, p);
Arguments
t
in-situ temperature [◦ C]
sig
in-situ density or sigma value [kg/m3 ]
p
in-situ pressure [dbar]
54
sw.T.S.rho
Details
Finds the salinity that yields the given density, with the given temperature and pressure. The method
is a bisection search with a salinity tolerance of 0.001. The isopycnal lines on temperature-salinity
diagrams (plot.TS) are computed with this function.
Value
In-situ salinity [PSU].
Author(s)
Dan Kelley [email protected]
References
Fofonoff, P. and R. C. Millard Jr, 1983. Algorithms for computation of fundamental properties of
seawater. Unesco Technical Papers in Marine Science, 44, 53 pp
Gill, A.E., 1982. Atmosphere-ocean Dynamics, Academic Press, New York, 662 pp.
See Also
sw.T.S.rho
Examples
S <- sw.S.T.rho(10, 22, 0) # 28.651
sw.T.S.rho
Seawater temperature from salinity and density
Description
Compute in-situ temperature, given salinity, density, and pressure.
Usage
temperature <- sw.T.S.rho(S, sig, p);
Arguments
S
in-situ salinity [PSU]
sig
in-situ density or sigma value [kg/m3 ]
p
in-situ pressure [dbar]
Details
Finds the temperature that yields the given density, with the given salinity and pressure. The method
is a bisection search with temperature tolerance 0.001 ◦ C.
sw.T.freeze
55
Value
In-situ temperature [◦ C].
Author(s)
Dan Kelley [email protected]
References
Fofonoff, P. and R. C. Millard Jr, 1983. Algorithms for computation of fundamental properties of
seawater. Unesco Technical Papers in Marine Science, 44, 53 pp
Gill, A.E., 1982. Atmosphere-ocean Dynamics, Academic Press, New York, 662 pp.
See Also
sw.S.T.rho
Examples
temperature <- sw.T.S.rho(35, 23, 0)
sw.T.freeze
Seawater freezing temperature
Description
Compute freezing temperature of seawater.
Usage
T.freeze <- sw.T.freeze(S, p);
Arguments
S
in-situ salinity [PSU]
p
in-situ pressure [dbar]
Details
Value
Temperature [◦ C]
Author(s)
Dan Kelley [email protected]
56
sw.alpha
References
UNESCO tech. papers in the marine science no. 28. 1978 eighth report JPOTS Annex 6 freezing
point of seawater F.J. Millero pp.29-35.
See Also
N/A.
Examples
T.freeze <-
sw.alpha
sw.T.freeze(40, 500) # -2.588567 degC
Seawater thermal expansion coefficient
Description
Compute α, the seawater thermal expansion coefficient, as the product of α/β and β, each calculated from McDougall’s (1987) algorithm.
Usage
a <- sw.alpha(S, t, p, is.theta=FALSE);
Arguments
S
salinity [PSU]
t
Temperature or potential temperature [◦ C], according to is.theta
p
pressure [dbar]
is.theta
Set TRUE if t is theta or FALSE if t is in-situ
Details
McDougall (1987). Note the use of potential temperature, not temperature.
Value
Value in 1/degC.
Author(s)
Dan Kelley [email protected]
References
McDougall, T.J. 1987. "Neutral Surfaces" Journal of Physical Oceanography vol 17 pages 19501964
sw.alpha.over.beta
57
See Also
N/A.
Examples
# 2.5060e-4 (inferred from p1964 of McDougall 1987)
a <- sw.alpha(40, 10, 4000)
sw.alpha.over.beta Ratio of seawater thermal expansion coefficient to haline contraction
coefficient
Description
Compute α/β using McDougall’s (1987) algorithm.
Usage
ab <- sw.alpha.over.beta(S, t, p, is.theta=FALSE);
Arguments
S
salinity [PSU]
t
Temperature or potential temperature [◦ C], according to is.theta
p
pressure [dbar]
is.theta
Set TRUE if t is theta or FALSE if t is in-situ
Details
McDougall (1987). Note the use of potential temperature, not temperature.
Value
Value in psu/degC.
Author(s)
Dan Kelley [email protected]
References
McDougall, T.J. 1987. "Neutral Surfaces" Journal of Physical Oceanography vol 17 pages 19501964
See Also
N/A.
58
sw.beta
Examples
# 0.3476 (from p1964 of McDougall 1987)
ab <- sw.alpha.over.beta(40, 10, 4000, is.theta=TRUE)
sw.beta
Seawater haline contraction coefficient
Description
Compute β using McDougall’s (1987) algorithm. NOTE: this conflicts with base::beta, so be sure
to prefix as sw.beta().
Usage
b <- sw.beta(S, t, p, is.theta=FALSE);
Arguments
S
t
p
is.theta
salinity [PSU]
Temperature or potential temperature [◦ C], according to is.theta
pressure [dbar]
Set TRUE if t is theta or FALSE if t is in-situ
Details
McDougall (1987). Note the use of potential temperature, not temperature.
Value
Value in 1/psu.
Author(s)
Dan Kelley [email protected]
References
McDougall, T.J. 1987. "Neutral Surfaces" Journal of Physical Oceanography vol 17 pages 19501964
See Also
N/A.
Examples
# 0.72088e-3 (from p1964 of McDougall 1987)
b <- sw.beta(40, 10, 4000, is.theta=TRUE)
sw.conductivity
59
sw.conductivity
Seawater conductivity
Description
Compute seawater conductivity, in W m−1◦ C −1
Usage
c <- sw.conductivity(S, t, p);
Arguments
S
salinity [PSU]
t
in-situ temperature [◦ C]
p
pressure [db]
Details
(To do: Fill in a summary of Caldwell’s technique.) Caution. The results differ from Fofonoff’s
(1962) table 5 by 0.1 percent at 35PSU, and by under 1 percent for fresh water. (To do: Compare
this with Caldwell’s stated uncertainty.)
Value
Conductivity of seawater in W m−1 ◦ C −1 . To calculate thermal diffusivity in m2 /s, divide by the
product of density and specific heat, as in the example.
Author(s)
Dan Kelley [email protected]
References
Caldwell, Douglas R., 1974. Thermal conductivity of seawater, Deep-sea Research, 21, 131-137.
Fofonoff, N. P., 1962. Physical properties of sea-water, The Sea, 1, 3-30.
See Also
N/A.
Examples
library(oce)
cond <- sw.conductivity(10,35,100); # 0.618569
diffusivity <- cond / (sw.rho(10,35,100) * sw.specific.heat(10,35,100))
60
sw.depth
sw.depth
Water depth
Description
Compute depth from pressure and latitude.
Usage
d <- sw.depth(p, lat, degrees=TRUE);
Arguments
p
lat
degrees
Pressure [dbar].
Latitude in ◦ N or radians north of the equator.
Flag indicating whether degrees are used for latitude; if set to FALSE, radians
are used.
Details
The information given below is adapted from the fortran code at
http://sam.ucsd.edu/sio210/propseawater/ppsw_fortran/ppsw.f,
which is where this R code came from.
Depth in meters from pressure in decibars using Saunders and Fofonoff’s method, with the formula
refitted for 1980 equation of state
Checkvalue: depth = 9712.653 m for p=10000 decibars, latitude=30 deg above for standard ocean:
t=0 deg. celsuis ; s=35 (ipss-78)
Value
Depth [m].
Author(s)
Dan Kelley [email protected]
References
(authors), 1976, (title), Deep-Sea Res., 23, 109-111.
See Also
N/A.
Examples
d <- sw.depth(10, 45);
sw.lapse.rate
61
Seawater lapse rate
sw.lapse.rate
Description
Compute adiabatic lapse rate
Usage
lr <- sw.lapse.rate(S, t, p);
Arguments
S
salinity [PSU]
t
in-situ temperature [◦ C]
p
pressure [dbar]
Details
Compute lapse rate using Fofonoff and Millard’s (1983) formula.
Value
Lapse rate [degC/m].
Author(s)
Dan Kelley [email protected]
References
Fofonoff, P. and R. C. Millard Jr, 1983. Algorithms for computation of fundamental properties of
seawater. Unesco Technical Papers in Marine Science, 44, 53 pp. (Section 7, pages 38-40)
See Also
N/A.
Examples
lr <- sw.lapse.rate(40, 40, 10000) # 3.255976e-4
62
sw.rho
Seawater density
sw.rho
Description
Compute, ρ, the in-situ density of seawater.
Usage
rho <- sw.rho(S, t, p);
Arguments
S
in-situ salinity [PSU]
t
in-situ temperature [◦ C]
p
in-situ pressure [dbar]
Details
The density is calculated using the UNESCO equation of state for seawater, assuming that input
variables are defined according to modern calibrations. In conventional Oceanographic notation,
the calculated quantity is ρ(S, t, p)
Value
In-situ density [kg/m3 ].
Author(s)
Dan Kelley [email protected]
References
Fofonoff, P. and R. C. Millard Jr, 1983. Algorithms for computation of fundamental properties of
seawater. Unesco Technical Papers in Marine Science, 44, 53 pp
Gill, A.E., 1982. Atmosphere-ocean Dynamics, Academic Press, New York, 662 pp.
See Also
Related density routines include sw.sigma, sw.sigma.t, and sw.sigma.theta.
Examples
rho <- sw.rho(35, 13, 1000) # 1030.818
sw.sigma
sw.sigma
63
Seawater density anomaly
Description
Compute σ, the in-situ density of seawater, minus 1000 kg/m3 .
Usage
sig <- sw.sigma(S, t, p);
Arguments
S
in-situ salinity [PSU]
t
in-situ temperature [◦ C]
p
in-situ pressure [dbar]
Details
Definition: ρ(S, t, p) - 1000 kg/m3 .
Value
In-situ density anomaly [kg/m3 ].
Author(s)
Dan Kelley [email protected]
References
Fofonoff, P. and R. C. Millard Jr, 1983. Algorithms for computation of fundamental properties of
seawater. Unesco Technical Papers in Marine Science, 44, 53 pp
Gill, A.E., 1982. Atmosphere-ocean Dynamics, Academic Press, New York, 662 pp.
See Also
Related density routines include: link{sw.rho}, link{sw.sigma.t}, and link{sw.sigma.theta}.
Examples
sig <- sw.sigma(35, 13, 1000)
# 30.818
64
sw.sigma.t
sw.sigma.t
Seawater quasi-potential density anomaly
Description
Compute σt , a quasi-potential density of seawater, minus 1000 kg/m3 .
Usage
sigma.t <- sw.sigma.t(S, t, p);
Arguments
S
in-situ salinity [PSU]
t
in-situ temperature [◦ C]
p
in-situ pressure [dbar]
Details
Definition: σt = ρ(S, t, 0) - 1000 kg/m3 .
Value
Quasi-potential density anomaly [kg/m3 ].
Author(s)
Dan Kelley [email protected]
References
Fofonoff, P. and R. C. Millard Jr, 1983. Algorithms for computation of fundamental properties of
seawater. Unesco Technical Papers in Marine Science, 44, 53 pp
Gill, A.E., 1982. Atmosphere-ocean Dynamics, Academic Press, New York, 662 pp.
See Also
Related density routines include: link{sw.rho}, link{sw.sigma}, and link{sw.sigma.theta}.
Examples
sigma.t <- sw.sigma.t(35, 13, 1000) #
sw.sigma.theta
sw.sigma.theta
65
Seawater potential density anomaly
Description
Compute σθ , the potential density of seawater, minus 1000 kg/m3 .
Usage
sigma.theta <- sw.sigma.theta(S, t, p);
Arguments
S
in-situ salinity [PSU]
t
in-situ temperature [◦ C]
p
in-situ pressure [dbar]
Details
Definition: σθ = ρ(S, θ(S, t, p), 0 - 1000 kg/m3 .
Value
Potential density anomaly [kg/m3 ].
Author(s)
Dan Kelley [email protected]
References
Fofonoff, P. and R. C. Millard Jr, 1983. Algorithms for computation of fundamental properties of
seawater. Unesco Technical Papers in Marine Science, 44, 53 pp
Gill, A.E., 1982. Atmosphere-ocean Dynamics, Academic Press, New York, 662 pp.
See Also
Related density routines include: link{sw.rho}, link{sw.sigma}, and link{sw.sigma.t}.
Examples
sigma.theta <- sw.sigma.theta(35, 13, 1000) #
66
sw.sound.speed
sw.sound.speed
Seawater sound speed
Description
Compute the seawater speed of sound.
Usage
speed <- sw.sound.speed(S, t, p);
Arguments
S
in-situ salinity [PSU]
t
in-situ temperature [◦ C]
p
in-situ pressure [dbar]
Details
The sound speed is calculated using the formulation in section 9 of Fofonoff and Millard (1983).
Value
Sound speed [m/s].
Author(s)
Dan Kelley [email protected]
References
Fofonoff, P. and R. C. Millard Jr, 1983. Algorithms for computation of fundamental properties of
seawater. Unesco Technical Papers in Marine Science, 44, 53 pp. (See section 9.)
See Also
N/A.
Examples
s <- sw.sound.speed(40, 40, 10000) # 1731.995 (p48 of Fofonoff + Millard 1983)
sw.specific.heat
67
sw.specific.heat
Seawater specific heat
Description
Compute specific heat of seawater.
Usage
C.P <- sw.specific.heat(S, t, p);
Arguments
S
in-situ salinity [PSU]
t
in-situ temperature [◦ C]
p
in-situ pressure [dbar]
Details
Based on matlab code on ftp://acourstics.whoi.edu/pub/Matlab/oceans, which
was in turn based on Millero et al (1973, 1981).
Value
Specific heat Jkg −1 ◦ C −1
Author(s)
Dan Kelley [email protected]
References
Millero et. al., J. Geophys. Res. 78 (1973), 4499-4507
Millero et. al., UNESCO report 38 (1981), 99-188.
See Also
Examples
C.P <- sw.specific.heat(40, 40, 10000) # 3949.500
68
sw.spice
sw.spice
Seawater spiciness
Description
Compute seawater "spice" (a variable orthogonal to density in TS space)
Usage
spice <- sw.spice(S, t, p);
Arguments
S
in-situ salinity [PSU]
t
in-situ temperature [◦ C]
p
in-situ pressure [dbar]
Details
Roughly speaking, seawater with a high spiciness is relatively warm and salty compared with less
spicy water. Another interpretation is that spice is a variable measuring distance orthogonal to
isopycnal lines on TS diagrams (if the diagrams are scaled to make the isopycnals run at 45 degres).
The definition used here is that of Pierre Flament. (Other formulations exist.) Note that pressure is
ignored in the definition. Spiceness is sometimes denoted π(S, t, p).
Value
Spice [kg/m3 ].
Author(s)
Dan Kelley [email protected]
References
P. Flament, 2002. A state variable for characterizing water masses and their diffusive stability:
spiciness. Progr. Oceanog., 54, 493-501.
See Also
N/A.
Examples
spice <- sw.spice(35, 10, 0) # 1.1 by eye, from Flament's fig2
sw.theta
sw.theta
69
Seawater potential temperature
Description
Compute θ, the potential temperature of seawater.
Usage
t.potential <- sw.theta(S, t, p, pref=0,
method=c("UNESCO1983","Bryden1973"));
Arguments
S
t
p
pref
method
in-situ salinity [PSU]
in-situ temperature [◦ C]
in-situ pressure [dbar]
reference pressure [dbar]
algorithm to be used (see details)
Details
The potential temperature is defined to be the temperature that a water parcel of salinity S, in-situ
temperature t and pressure p would have if were to be moved adiabatically to a location with
pressure pref. This quantity is commonly denoted θ(S, t, p, pref ) in the oceanographic literature.
The "Bryden1973" method does not use the reference pressure, since it is set up to approximate
potential temperature referenced to the surface.
For general use, the "UNESCO1983" method is preferable, since it permits calculation for arbitrary
reference pressure. The UNESCO formula is derived from Bryden’s earlier method, as Fofonoff et
al. (1983) explain.
This is not the place to discuss the two methods in detail, but users may note from the example that
the two typically yield values that agree to a few millidegrees.
Value
Potential temperature [◦ C] of seawater.
Author(s)
Dan Kelley [email protected]
References
Bryden, H. L., 1973. New polynomials for thermal expansion, adiabatic temperature gradient and
potential temperature of seawater, Deep-Sea Res., 20, 401-408.
Fofonoff, P. and R. C. Millard Jr, 1983. Algorithms for computation of fundamental properties of
seawater. Unesco Technical Papers in Marine Science, 44, 53 pp.
70
sw.viscosity
See Also
N/A.
Examples
library(oce)
print(sw.theta(35, 13, 1000)) # 12.858
print(sw.theta(40,40,10000,0,"UNESCO1983")) # 36.89073 (Fofonoff et al., 1983)
# Demonstrate that the methods agree to a couple of
# millidegrees over a typical span of values
S <- c(30,30,38,38)
T <- c(-2,-2,30,30)
p <- rep(1000,4)
print(max(abs(sw.theta(S,T,p) - sw.theta(S,T,p,0,"UNESCO1983"))))
Seawater viscosity
sw.viscosity
Description
Compute viscosity of seawater, in P a · s
Usage
v <- sw.viscosity(S, t);
Arguments
S
in-situ salinity [PSU]
t
in-situ temperature [◦ C]
Details
Derived from a curve fit to table 87 of Dorsey (1940). The fit matches the table to within 0.2 percent
at worst, and with average absolute error of 0.07 percent. The maximum deviation from the table is
one unit in the last decimal place.
No pressure dependence was reported by Dorsey (1940).
It would be a good idea to look for other values to check those used here, and of course to get an
idea of pressure dependence. Therefore, this subroutine is provisional.
– Dan Kelley 2006-01-21.
Value
Viscosity of seawater in P a · s. Divide by density to get kinematic viscosity in m2 /s.
sw.viscosity
71
Author(s)
Dan Kelley [email protected]
References
N. Ernest Dorsey (1940), Properties of ordinary Water-substance, American Chemical Society
Monograph Series. Reinhold Publishing.
See Also
N/A.
Examples
v <- sw.viscosity(30,10); # 0.001383779
Index
∗Topic misc
as.coastline, 3
as.CTD, 1
as.sealevel, 4
coastline.halifax, 6
coastline.maritimes, 6
coriolis, 7
ctd, 8
ctd.add.column, 8
ctd.decimate, 10
ctd.raw, 11
ctd.trim, 12
ctd.update.header, 13
ctd.write, 14
geod.dist, 15
gravity, 16
lat.format, 17
latlon.format, 18
lobo, 19
lon.format, 20
magic, 21
make.section, 21
oce.as.POSIXlt, 22
plot.coastline, 25
plot.ctd, 26
plot.ctd.scan, 27
plot.lobo, 28
plot.profile, 29
plot.sealevel, 30
plot.section, 32
plot.TS, 23
processing.log.append, 33
processing.log.summary, 34
read.coastline, 35
read.ctd, 36
read.lobo, 39
read.oce, 40
read.sealevel, 41
sealevel, 43
section, 44
summary.coastline, 45
summary.ctd, 46
summary.lobo, 47
summary.sealevel, 48
summary.section, 49
sw.alpha, 55
sw.alpha.over.beta, 56
sw.beta, 57
sw.conductivity, 58
sw.depth, 59
sw.lapse.rate, 60
sw.N2, 50
sw.rho, 61
sw.S.C.T.p, 51
sw.S.T.rho, 52
sw.sigma, 62
sw.sigma.t, 63
sw.sigma.theta, 64
sw.sound.speed, 65
sw.specific.heat, 66
sw.spice, 67
sw.T.freeze, 54
sw.T.S.rho, 53
sw.theta, 68
sw.viscosity, 69
as.coastline, 3, 6, 7
as.CTD, 1
as.POSIXct, 30
as.POSIXlt, 23
as.sealevel, 4, 42, 43
axis, 33
coastline.halifax, 6, 7
coastline.maritimes, 6, 6
contour, 33
coriolis, 7
ctd, 8
ctd.add.column, 8
72
INDEX
ctd.decimate, 10
ctd.raw, 11
ctd.trim, 11, 12
ctd.update.header, 13
ctd.write, 14
geod.dist, 15
gravity, 16
lat.format, 17, 19, 20
latlon.format, 18, 18, 20
lobo, 19
lon.format, 18, 19, 20
magic, 21, 41
make.section, 21, 32, 33, 49
oce.as.POSIXlt, 22
plot.coastline, 4, 25, 36, 45
plot.ctd, 26, 27, 38
plot.ctd.scan, 13, 27
plot.lobo, 28, 40
plot.profile, 29, 50
plot.sealevel, 5, 30, 43, 48
plot.section, 32, 45
plot.TS, 23, 30, 52
pretty, 10
processing.log.append, 33
processing.log.summary, 34
read.coastline, 3, 4, 6, 7, 25, 35, 41, 45
read.ctd, 3, 9–15, 22, 24, 26, 27, 29, 30,
36, 41, 46, 47
read.lobo, 28, 39, 41, 47
read.oce, 21, 36, 38, 39, 40, 43
read.sealevel, 5, 30, 31, 41, 41, 43, 48
sealevel, 43
section, 44
summary.coastline, 25, 36, 45
summary.ctd, 24, 26, 27, 38, 46
summary.lobo, 28, 40, 47
summary.sealevel, 5, 31, 43, 48
summary.section, 33, 45, 49
sw.alpha, 55
sw.alpha.over.beta, 56
sw.beta, 57
sw.conductivity, 52, 58
sw.depth, 59
73
sw.lapse.rate, 60
sw.N2, 26, 29, 50
sw.rho, 61
sw.S.C.T.p, 51
sw.S.T.rho, 52, 54
sw.sigma, 38, 61, 62
sw.sigma.t, 61, 63
sw.sigma.theta, 61, 64
sw.sound.speed, 65
sw.specific.heat, 66
sw.spice, 67
sw.T.freeze, 54
sw.T.S.rho, 53, 53
sw.theta, 68
sw.viscosity, 69