Skip to contents

viz.profile() selects one variable at exactly one longitude, latitude, and time through cube_extract(), then draws the stored value-by-depth profile without interpolation or aggregation. NetCDF inputs read only the selected profile rather than materializing the complete cube.

Usage

viz.profile(
  x,
  variable,
  longitude = NULL,
  latitude = NULL,
  time = NULL,
  depth = NULL,
  limits = NULL,
  na.rm = TRUE,
  reverse_depth = TRUE,
  points = TRUE,
  title = NULL,
  subtitle = NULL,
  caption = NULL
)

Arguments

x

A valid <ocean_cube>.

variable

A single non-missing variable name present in x.

longitude

A single stored longitude. May be NULL only when the cube contains one longitude.

latitude

A single stored latitude. May be NULL only when the cube contains one latitude.

time

A single stored Date or POSIXct value. May be NULL only when the cube contains one time value.

depth

Optional finite, unique stored depth values. NULL retains all depths. At least two levels must remain after selection.

limits

NULL or two finite numeric limits for the value axis in increasing order. Values outside the limits are squished to the scale boundary without removing rows.

na.rm

A single non-missing logical value. If TRUE, missing values are removed before plotting; they are never replaced with zero.

reverse_depth

A single non-missing logical value. If TRUE, smaller depth values appear at the top of the plot.

points

A single non-missing logical value. If TRUE, points are drawn over the profile line.

title, subtitle, caption

Optional character scalars used as plot labels.

Value

A ggplot object with the selected variable, longitude, latitude, time, depth range, and backend recorded in oceancube_* attributes.

Details

Longitude, latitude, time, variable, and optional depth selectors use exact stored-value matching. A surface cube or a selection with fewer than two distinct finite depth levels is rejected. Duplicate extracted depths are rejected rather than combined. The input cube is not modified.

Examples

if (requireNamespace("ggplot2", quietly = TRUE)) {
  values <- array(c(18, 16, 13, 9), dim = c(1, 1, 4, 1, 1))
  cube <- ocean_cube(
    lon = -79, lat = -11, depth = c(0, 25, 50, 100),
    time = as.Date("2020-01-01"), data = values,
    vars = "temperature", units = "degC"
  )
  viz.profile(cube, "temperature")
}