Skip to contents

This function returns a glider object that holds data as provided in the data argument, with units as provided by the units argument. The units argument is optional, making the function easy to use in interactive sessions, but production code ought to be written with units fully specified.

Usage

as.glider(type, data, units)

Arguments

type

Character value giving the type of glider, e.g. be either seaexplorer or slocum.

data

A data frame containing the data. This is copied straight into the payload1 item in the data slot of the returned value, without name translation. For most functions in this package to work, data ought to have items named longitude, latitude, salinity, temperature and pressure.

units

A list holding units, with names corresponding to the names in the data. See the example for the format to be used for units, but note that there are several items in this dataset that are not given units, in this example.

Author

Dan Kelley

Examples

library(oceglider)
directory <- system.file("extdata/sea_explorer/delayed_raw", package = "oceglider")
g <- read.glider.seaexplorer.delayed(directory)
data <- g[["payload"]]
units <- list(
    temperature = list(unit = expression(degree * C), scale = "ITS-90"),
    salinity = list(unit = expression(), scale = "PSS-78"),
    pressure = list(unit = expression(dbar), scale = ""),
    longitude = list(unit = expression(degree * E), scale = ""),
    latitude = list(unit = expression(degree * N), scale = "")
)
gg <- as.glider("seaexplorer", data, units)
par(mfrow = c(2, 1))
plot(g, which = "p")
#> [1] "2019-07-19 15:12:15 UTC" "2019-07-19 18:02:07 UTC"
#> w: 2549
#> t[w]: 2019-07-19 18:02:07.28
#> p[w]: 3.54
plot(gg, which = "p")
#> [1] "2019-07-19 15:12:15 UTC" "2019-07-19 18:02:07 UTC"
#> w: 2549
#> t[w]: 2019-07-19 18:02:07.28
#> p[w]: 3.54