Skip to contents

Reads selected NetCDF variables and standardizes them as a 5D [lon, lat, depth, time, var] array.

Usage

read_nc(
  file,
  vars = NULL,
  lon_name = NULL,
  lat_name = NULL,
  depth_name = NULL,
  time_name = NULL,
  source = "netcdf",
  dataset_id = NULL
)

Arguments

file

NetCDF file path.

vars

Character vector of variable names. If NULL, all non-coordinate variables are read.

lon_name

Optional longitude dimension name.

lat_name

Optional latitude dimension name.

depth_name

Optional depth dimension name.

time_name

Optional time dimension name.

source

Optional source label.

dataset_id

Optional dataset identifier.

Value

An <ocean_cube> object. Exactly representable Gregorian-family CF time remains UTC POSIXct; supported non-Gregorian or mixed-calendar values use the internal plain-R oceancube_cf_time representation. The reader attaches the versioned source model at x$metadata$cf before supported metadata are interpreted for cube construction.

Details

CF units in seconds, minutes, hours, days, UDUNITS months, or UDUNITS years since a calendar-valid origin are supported, including explicit Z and numeric UTC offsets. Calendars standard/gregorian, proleptic_gregorian, julian, 365_day/noleap, 366_day/all_leap, and 360_day are implemented. Missing calendar metadata defaults to standard. A UDUNITS year is exactly 365.242198781 days and a UDUNITS month is one twelfth of that; neither performs civil-calendar advancement. UTC/TAI, none, and custom-calendar arithmetic remain explicitly unsupported.