CFLabel: CF label object

CFLabelR Documentation

CF label object

Description

This class represent CF labels, i.e. a variable of character type that provides a textual label for a discrete or general numeric axis. See also CFAxisCharacter, which is an axis with character labels.

Super class

ncdfCF::CFObject -> CFLabel

Active bindings

friendlyClassName

(read-only) A nice description of the class.

coordinates

Set or retrieve the labels of this object. Upon retrieval, label values are read from the netCDF resource, if there is one, upon first access and cached thereafter. Upon setting values, if there is a linked netCDF resource, this object will be detached from it.

length

(read-only) The number of labels in the set.

dimid

(read-only) The netCDF dimension id of this label set. This field should only be accessed if the label set is backed by a netCDF resource.

Methods

Public methods

Inherited methods

Method new()

Create a new instance of this class.

Usage
CFLabel$new(var, values = NA, start = NA, count = NA)
Arguments
var

The NCVariable instance upon which this CF object is based when read from a netCDF resource, or the name for the object new CF object to be created.

values

Optional. The labels of the CF object. Ignored when argument var is a NCVariable object.

start

Optional. Integer index value indicating where to start reading data from the file. The value may be NA (default) to read all data, otherwise it must not be larger than the number of labels. Ignored when argument var is not an NCVariable instance.

count

Optional. Integer value indicating the number of labels to read from file. The value may be NA to read to the end of the labels, otherwise its value must agree with the corresponding start value and the number of labels on file. Ignored when argument var is not an NCVariable instance.

Returns

A CFLabel instance.


Method print()

Prints a summary of the labels to the console.

Usage
CFLabel$print(...)
Arguments
...

Arguments passed on to other functions. Of particular interest is ⁠width = ⁠ to indicate a maximum width of attribute columns.


Method slice()

Given a range of domain coordinate values, returns the indices into the axis that fall within the supplied range.

Usage
CFLabel$slice(rng)
Arguments
rng

A character vector whose extreme (alphabetic) values indicate the indices of coordinates to return.

Returns

An integer vector of length 2 with the lower and higher indices into the axis that fall within the range of coordinates in argument rng. Returns NULL if no values of the axis fall within the range of coordinates.


Method subset()

Retrieve a subset of the labels.

Usage
CFLabel$subset(name, rng)
Arguments
name

The name for the new label set, optional.

rng

The range of indices whose values from this axis to include in the returned axis.

Returns

A CFLabel instance, or NULL if the rng values are invalid.


Method write()

Write the labels to a netCDF file, including its attributes.

Usage
CFLabel$write(nc, dim)
Arguments
nc

The handle of the netCDF file opened for writing or a group in the netCDF file. If NULL, write to the file or group where the labels were read from (the file must have been opened for writing). If not NULL, the handle to a netCDF file or a group therein.

dim

The dimension to write the labels for. This is the name or dimension id of the object that owns these labels. The dimension must have been written to file before this method is called.

Returns

Self, invisibly.


Method clone()

The objects of this class are cloneable with this method.

Usage
CFLabel$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


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