var.inq.nc: Inquire About a NetCDF Variable

Description Usage Arguments Details Value Author(s) References Examples

View source: R/RNetCDF.R

Description

Inquire about a NetCDF variable.

Usage

1
var.inq.nc(ncfile, variable)

Arguments

ncfile

Object of class "NetCDF" which points to the NetCDF dataset (as returned from open.nc).

variable

Either the ID or the name of the variable to be inquired.

Details

This function returns information about a NetCDF variable. Information about a variable include its name, its ID, its type, its number of dimensions, a vector of the dimension IDs of this variable and the number of attributes. The valid external NetCDF data types are NC_BYTE, NC_CHAR, NC_SHORT, NC_INT, NC_FLOAT, and NC_DOUBLE.

Value

A list containing the following components:

id

Variable ID.

name

Variable name.

type

External NetCDF data type.

ndims

Number of dimensions the variable was defined as using.

dimids

Vector of dimension IDs corresponding to the variable dimensions (NA for scalar variables). Order is leftmost varying fastest.

natts

Number of variable attributes assigned to this variable.

Author(s)

Pavel Michna

References

http://www.unidata.ucar.edu/software/netcdf/

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
##  Create a new NetCDF dataset and define two dimensions
nc <- create.nc("var.inq.nc")

dim.def.nc(nc, "station", 5)
dim.def.nc(nc, "time", unlim=TRUE)

##  Create two variables, one as coordinate variable
var.def.nc(nc, "time", "NC_INT", "time")
var.def.nc(nc, "temperature", "NC_DOUBLE", c(0,1))

##  Inquire about these variables
var.inq.nc(nc, 0)
var.inq.nc(nc, "temperature")

close.nc(nc)

RNetCDF documentation built on May 2, 2019, 6:12 p.m.