NCObject: NetCDF base object

NCObjectR Documentation

NetCDF base object

Description

This class is a basic ancestor to all classes that represent netCDF objects, specifically groups, dimensions, variables and the user-defined types in a netCDF file. More useful classes use this class as ancestor.

The fields in this class are common among all netCDF objects. In addition, this class manages the attributes for its descendent classes.

Active bindings

id

(read-only) Retrieve the identifier of the netCDF object.

name

(read-only) Retrieve the name of the object.

attributes

(read-only) Read the attributes of the object. When there are no attributes, an empty data.frame will be returned.

Methods

Public methods


Method new()

Create a new netCDF object. This class should not be instantiated directly, create descendant objects instead.

Usage
NCObject$new(id, name, attributes = data.frame())
Arguments
id

Numeric identifier of the netCDF object.

name

Character string with the name of the netCDF object.

attributes

Optional, data.frame with attributes of the object.


Method print_attributes()

This function prints the attributes of the netCDF object to the console.

Usage
NCObject$print_attributes(width = 50L)
Arguments
width

The maximum width of each column in the data.frame when printed to the console.


Method attribute()

Retrieve an attribute of a NC object.

Usage
NCObject$attribute(att, field = "value")
Arguments
att

Single character string of attribute to return.

field

The field of the attribute to return values from. This must be "value" (default) or "type".

Returns

If the field argument is "type", a character string. If field is "value", a single value of the type of the attribute, or a vector when the attribute has multiple values. If no attribute is named with a value of argument att NA is returned.


Method write_attributes()

Write the attributes of this object to a netCDF file.

Usage
NCObject$write_attributes(nc, nm)
Arguments
nc

The handle to the netCDF file opened for writing.

nm

The NC variable name or "NC_GLOBAL" to write the attributes to.

Returns

Self, invisibly.


Method clone()

The objects of this class are cloneable with this method.

Usage
NCObject$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


ncdfCF documentation built on Sept. 13, 2025, 5:07 p.m.