Inquire About a NetCDF Type
Inquire about a NetCDF builtin or user-defined data type.
type.inq.nc(ncfile, type, fields=TRUE)
ncfile |
Object of class " |
type |
ID or name of a NetCDF data type. |
fields |
Read members of enum types or fields of compound types (default |
.
This function obtains information about a NetCDF data type, which could be builtin or user-defined. The items in the return list depend on the class of the NetCDF type.
A list containing the following components:
id |
Type ID. |
name |
Type name. |
class |
One of the keywords "builtin", "compound", "enum", "opaque" or "vlen". |
size |
Size in bytes of a single item of the type (or a single element of a "vlen"). |
basetype |
("enum" or "vlen") Name of the NetCDF type of each element. |
If fields=TRUE
, the return list includes details about members of enum types or fields of compound types:
value |
("enum" only) Named vector with numeric values of all members. |
offset |
("compound" only) Named vector with the offset of each field in bytes from the beginning of the compound type. |
subtype |
("compound" only) Named vector with the NetCDF type name of each field. |
dimsizes |
("compound" only) Named list with array dimensions of each field. Dimension lengths are reported in R order (leftmost index varies fastest; opposite to CDL conventions). A |
Pavel Michna, Milton Woods
grp.inq.nc
- get a list of NetCDF types defined in a dataset or group.
type.def.nc
- define a new NetCDF type.
## Create a new NetCDF4 dataset and define types file1 <- tempfile("type.inq_", fileext=".nc") nc <- create.nc(file1, format="netcdf4") # Define a type of each class: type.def.nc(nc, "blob", "opaque", size=128) type.def.nc(nc, "vector", "vlen", basetype="NC_FLOAT") type.def.nc(nc, "factor", "enum", basetype="NC_INT", names=c("peanut butter", "jelly"), values=c(101, 102)) type.def.nc(nc, "struct", "compound", names=c("siteid", "height", "colour"), subtypes=c("NC_INT", "NC_DOUBLE", "NC_SHORT"), dimsizes=list(NULL, NULL, c(3))) # Inquire about the types: typeids <- grp.inq.nc(nc)$typeids for (typeid in typeids) { print(type.inq.nc(nc, typeid)) } close.nc(nc) unlink(file1)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.