grp.inq.nc: Inquire About a NetCDF Group

Description Usage Arguments Details Value Author(s) References Examples

View source: R/RNetCDF.R

Description

Inquire about a NetCDF group.

Usage

1
grp.inq.nc(ncid,grpname=NULL,ancestors=TRUE)

Arguments

ncid

Object of class "NetCDF" which points to a NetCDF group (from grp.def.nc) or dataset (from open.nc).

grpname

By default, the inquiry relates to the group represented by ncid. If grpname is a character string, a group with this name is examined instead. A hierarchical search is performed if grpname contains "/", otherwise only the immediate group of ncid is searched for a matching group name.

ancestors

If TRUE, dimensions and names of ancestor groups are examined. Otherwise, only dimensions and names defined in the current group are reported.

Details

This function provides information about the structure of a NetCDF group or dataset. The results allow programs to explore a dataset without prior knowledge of the contents.

Value

A list containing the following components:

self

Object of class NetCDF representing the group.

parent

Object of class NetCDF representing the parent group, or NULL for the root group.

grps

List of objects of class NetCDF representing the groups in the group.

name

Name of the NetCDF group.

fullname

Full name of the NetCDF group, with ancestors listed in order from the root group of the dataset and separated by "/". Omitted if ancestors is FALSE.

dimids

Vector of dimension identifiers. If ancestors is TRUE (default), all visible dimensions in the group and its ancestors are reported, otherwise only dimensions defined in the group of ncid are shown.

unlimids

Vector of identifiers for unlimited dimensions. If ancestors is TRUE (default), all unlimited dimensions in the group and its ancestors are reported, otherwise only unlimited dimensions defined in the group of ncid are shown.

varids

Vector of identifiers for variables in the group.

typeids

Vector of identifiers for types in the group.

ngatts

Number of group attributes.

Author(s)

Pavel Michna, Milton Woods

References

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
##  Create a new NetCDF dataset and define two dimensions
file1 <- tempfile("grp.inq_", fileext=".nc")
nc <- create.nc(file1)

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))

##  Put some attributes
att.put.nc(nc, "NC_GLOBAL", "title", "NC_CHAR", "Data from Foo")
att.put.nc(nc, "NC_GLOBAL", "history", "NC_CHAR", paste("Created on", date()))

##  Inquire about the root group
grp.inq.nc(nc)

close.nc(nc)
unlink(file1)

RNetCDF documentation built on Aug. 20, 2021, 9:08 a.m.