| vol_field | R Documentation |
Builds the object every other function in the package takes: a scalar field on a regular longitude, latitude and depth grid, with the coordinate vectors, the units and the provenance carried alongside the values.
vol_field(
values,
lon,
lat,
depth,
name = "value",
unit = "",
mask = NULL,
source = NULL,
geographic = TRUE
)
values |
Numeric array of dimension |
lon |
Numeric vector of |
lat |
Numeric vector of |
depth |
Numeric vector of |
name |
Short name of the quantity, used in labels. |
unit |
Unit of the quantity, used in labels. |
mask |
Optional logical matrix of dimension |
source |
Optional named list of provenance strings, carried into the payload manifest. |
geographic |
Logical. |
Wrap a gridded three-dimensional field
The index order is fixed and is not a matter of taste. A browser
payload is one image per depth level, and an image is a matrix of rows by
columns, so a level of the field has to be contiguous as values[k, , ]
with latitude down the rows and longitude across the columns. Row one of a
level is the southernmost latitude and column one the westernmost
longitude, which is the orientation the renderer assumes and the manifest
records.
The constructor checks that the three coordinate vectors match the three
dimensions of values, that each is numeric, complete and strictly
increasing, and that mask, when given, matches the horizontal grid. It
does not require the depth axis to be
uniform: vol_resample() does that, and the browser payload needs it
because the GPU samples a texture on a regular grid.
The value range may be anything the transfer of vol_encode() can carry.
For a strictly positive and strongly skewed field, the square-root transfer
spends its 254 codes where the data are.
An object of class vol_field: a list with the elements values,
lon, lat, depth, name, unit, mask, source and geographic.
print.vol_field(), summary.vol_field() and plot.vol_field()
for the methods,
vol_resample() to put the depth axis on a uniform grid, vol_encode()
for the transfer into 8 bits, vol_payload() to write the browser payload,
vol_read_npy() and vol_read_netcdf() to read a field from a file.
v <- array(NA_real_, c(4, 20, 30))
for (k in 1:4) v[k, , ] <- outer(1:20, 1:30, function(i, j) exp(-k / 3) * (i + j))
f <- vol_field(v, lon = seq(10, 12.9, by = 0.1), lat = seq(40, 41.9, by = 0.1),
depth = c(0, 10, 25, 50), name = "Tracer", unit = "mg/l")
f
summary(f)
plot(f)
plot(f, type = "profile")
plot(f, type = "coverage")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.