oceancube architecture and contracts
Source:vignettes/oceancube-architecture.Rmd
oceancube-architecture.RmdPublic contract
The public ocean_cube contract consists of coordinate
vectors, variables, scientific metadata, and a logical five-dimensional
shape ordered as
[longitude, latitude, depth, time, variable]. Coordinates
are preserved in their stored order. Public selection functions return
independent memory cubes; table extractors return self-contained data
frames.
Backend boundary
The memory backend owns an R array. The NetCDF backend owns only a serializable descriptor for a local file and is read-only. Internal read operations validate the cube, plan five-axis indices, and dispatch to the backend. Scientific functions do not access physical storage directly. This separation gives memory and NetCDF inputs the same logical results while allowing block-level file reads.
cube_collect() is the explicit materialization boundary.
A collected, sliced, cropped, or masked result is independent of the
original NetCDF file. A deferred descriptor correctly fails if its
source disappears or changes.
Classes and metadata
The principal S3 classes are ocean_cube,
ocean_clim, and ocean_mask. Temporal summaries
and inherited compatibility functions may add result classes without
changing the cube header. Units and provenance follow operations when
scientifically meaningful; derived components that can no longer be
aligned are dropped explicitly and recorded.
Stability
The 0.3.0 API is frozen at 49 exports. Constructor, local deferred reading, collection, selection, extraction, masks, compatibility helpers, CF/time and vertical engines, six core visualizations, and grid geometry retain their documented contracts. Specialized D3 visualization is not implemented. No current core API performs trend significance or structural-change inference.