coord.def.ncv {ncvar} | R Documentation |
Define a new NetCDF coordinate variable object.
coord.def.ncv(name, data=NULL, xtype=NULL, att=NULL, mvar=NULL, unlim=FALSE)
name |
Variable name. Must begin with an alphabetic character,
followed by zero or more alphanumeric characters including the underscore
("_ "). Case is significant. |
data |
The (onedimensional) array containing the coordinate values. |
xtype |
One of the predefined numeric NetCDF external data types
(NC_BYTE , NC_SHORT , NC_INT , NC_FLOAT ,
NC_DOUBLE ).
If none is provided, the type is determined automatically from
value to one of the follwoing NC_INT , or NC_FLOAT . |
unlim |
Set to TRUE if an unlimited dimension should be
created, otherwise to FALSE . |
att |
A list of attribute objects (class "att.ncv"), as returned from
att.def.ncv . |
mvar |
A list of variable objects (class "var.ncv") as returned from
var.def.ncv . |
This function creates a new NetCDF coordinate variable, that is
an object of class "coord.ncv". A NetCDF coordinate variable is a
one-dimensional variable with the same name as its dimension. See
var.def.ncv
for further information on NetCDF
variables.
An object of class "coord.ncv".
Juerg Schmidli
## define some coordinate variables lon <- coord.def.ncv("lon", seq(1,10), xtype="NC_FLOAT", att=list("axis", "X", "long_name", "longitude", "units", "degrees_east") ) lat <- coord.def.ncv("lat", 1.*seq(1,5), att=list("axis", "Y", "long_name", "latitude", "units", "degrees_north") ) hgt <- coord.def.ncv("hgt", 0., att=list("axis", "Z", "long_name", "altitude", "units", "metre", "positive", "up") ) time <- coord.def.ncv("time", 0., att=list("axis", "T", "calendar", "standard", "long_name", "time", "units", "days since 1979-01-01 00:00:00.0"), unlim=TRUE) ## define data variable pre <- var.def.ncv("precip", array(1,dim=c(10,5,1,1)), xtype="NC_FLOAT", dim=list(lon, lat, hgt, time), att=list("long_name", "precipitation", "units", "mm d-1", "_FillValue", -998.9) ) ## write to file var.put.ncv(paste(tempdir(),"/foo.nc",sep=""), pre, new=TRUE)