Skip to contents

oceancube uses a canonical five-dimensional contract ordered as longitude, latitude, depth, time, and variable. Start by validating and inspecting a tiny offline cube, then select, visualize, and apply the canonical temporal engines.

library(oceancube)

time <- as.Date("2020-01-01") + 0:119
x <- ocean_cube(
  lon = c(-80, -79), lat = c(-12, -11), depth = 5,
  time = time,
  data = array(seq_len(2 * 2 * 1 * 120), c(2, 2, 1, 120, 1)),
  vars = "temperature", units = "degC"
)

validation <- cube_validate(x)
inspection <- cube_inspect(x, missing = "none")
selected <- cube_crop(x, longitude = c(-80, -79), latitude = c(-12, -11))
map <- viz.map(selected, "temperature", time = time[1], depth = 5)

monthly <- cube_aggregate_time(selected, by = "month")
clim <- cube_climatology(monthly, by = "month")
## Warning: Climatology inner-period means use equal observation weighting;
## irregular or gapped sampling can differ from duration-weighted means.
anom <- cube_anomaly(monthly, clim, type = "difference")
trend <- cube_trend(monthly)

stopifnot(
  nrow(validation) > 0L,
  inherits(inspection, "ocean_cube_inspection"),
  inherits(map, "ggplot"),
  inherits(anom, "ocean_cube"),
  inherits(trend, "ocean_cube")
)

The other static ggplot helpers are viz.section(), viz.profile(), viz.transect(), and viz.timeseries(). A climatology has recurring pseudo-time and must not be passed to cube_trend(); raw, aggregated, and anomaly cubes retain historical time.

Continue with the introduction, then read the architecture and geometry and weights articles.