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.

Value

A list of named components, some of which are only included for datasets in "netcdf4" format (as indicated by file.inq.nc).

id

Variable ID.

name

Variable name.

type

External NetCDF data type as one of the following labels: NC_BYTE, NC_UBYTE, NC_CHAR, NC_SHORT, NC_USHORT, NC_INT, NC_UINT, NC_INT64, NC_UINT64, NC_FLOAT, NC_DOUBLE, NC_STRING, or a user-defined type name.

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.

The list components below apply only to datasets in "netcdf4" format:

chunksizes

Chunk size expressed as the number of elements along each dimension, in the same order as dimids. NULL implies contiguous storage.

cache_bytes

Size of chunk cache in bytes (NULL if unsupported).

cache_slots

The number of slots in the chunk cache (NULL if unsupported).

cache_preemption

A value between 0 and 1 (inclusive) that biases the cache scheme towards eviction of chunks that have been fully read (NULL if unsupported).

deflate

Integer indicating level of compression, from 0 (minimum) to 9 (maximum), or NA if compression is not enabled.

shuffle

TRUE if byte shuffling is enabled for the variable, FALSE otherwise.

big_endian

Byte order of the variable. TRUE for big-endian, FALSE for little-endian, NA for not yet determined, or NULL if unsupported.

fletcher32

TRUE if the fletcher32 checksum is enabled for this variable, FALSE otherwise.

szip_options

Integer containing a bitmask of szip options. NA if szip is not used, or NULL if unsupported.

szip_bits

Number of bits per pixel for szip. NA if szip is not used, or NULL if unsupported.

filter_id

Vector of filter IDs associated with the variable, or NULL if the NetCDF library does not support the multi-filter interface.

filter_params

List with one element per filter_id, or NULL if the NetCDF library does not support the multi-filter interface. Each list member is a vector of numeric parameters for the corresponding filter. Please see the NetCDF documentation for information about the available filters and their parameters.

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
##  Create a new NetCDF dataset and define two dimensions
file1 <- tempfile("var.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))

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

close.nc(nc)
unlink(file1)

Example output

$id
[1] 0

$name
[1] "time"

$type
[1] "NC_INT"

$ndims
[1] 1

$dimids
[1] 1

$natts
[1] 0

$id
[1] 1

$name
[1] "temperature"

$type
[1] "NC_DOUBLE"

$ndims
[1] 2

$dimids
[1] 0 1

$natts
[1] 0

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