Learn R Programming

ncdfCF (version 0.4.0)

CFVariableBase: Base ancestor of CFVariable and CFArray

Description

This class is a basic ancestor to CFVariable and CFArray. It should not be instantiated directly, use the descendant classes instead.

This class provides access to common properties of data variables and the data they contain.

Arguments

Super class

ncdfCF::CFObject -> CFVariableBase

Public fields

axes

List of instances of classes descending from CFAxis that are the axes of the data object. If there are any scalar axes, they are listed after the axes that associate with the dimensions of the data. (In other words, axes 1..n describe the 1..n data dimensions, while any axes n+1..m are scalar axes.)

crs

The coordinate reference system of this variable, as an instance of CFGridMapping. If this field is NULL, the horizontal component of the axes are in decimal degrees of longitude and latitude.

Methods

Inherited methods


Method new()

Create an instance of this class.

Usage

CFVariableBase$new(var, group, axes, crs)

Arguments

var

The NC variable that describes this data object.

group

The group that this data object should live in.

axes

A list of CFAxis descendant instances that describe the axes of the data object.

crs

The CFGridMapping instance of this data object, or NULL when no grid mapping is available.

Returns

An instance of this class.


Method time()

Return the time object from the axis representing time.

Usage

CFVariableBase$time(want = "time")

Arguments

want

Character string with value "axis" or "time", indicating what is to be returned.

Returns

If want = "axis" the CFAxisTime axis; if want = "time" the CFTime instance of the axis, or NULL if the variable does not have a "time" dimension.


Method summarise()

Summarise the temporal dimension of the data, if present, to a lower resolution, using a user-supplied aggregation function.

Attributes are copied from the input data variable or data array. Note that after a summarisation the attributes may no longer be accurate. This method tries to sanitise attributes (such as removing scale_factor and add_offset, when present, as these will no longer be appropriate in most cases) but the onus is on the calling code (or yourself as interactive coder). Attributes like standard_name and cell_methods likely require an update in the output of this method, but the appropriate new values are not known to this method. Use CFArray$set_attribute() on the result of this method to set or update attributes as appropriate.

Usage

CFVariableBase$summarise(name, period, fun)

Arguments

name

Character vector with a name for each of the results that fun returns. So if fun has 2 return values, this should be a vector of length 2. Any missing values are assigned a default name of "result_#" (with '#' being replaced with an ordinal number).

period

The period to summarise to. Must be one of either "day", "dekad", "month", "quarter", "season", "year". A "quarter" is the standard calendar quarter such as January-March, April-June, etc. A "season" is a meteorological season, such as December-February, March-May, etc. (any December data is from the year preceding the January data). The period must be of lower resolution than the resolution of the time dimension.

fun

A function or a symbol or character string naming a function that will be applied to each grouping of data. The function must return an atomic value (such as sum() or mean()), or a vector of atomic values (such as range()). Lists and other objects are not allowed and will throw an error that may be cryptic as there is no way that this method can assert that fun behaves properly so an error will pop up somewhere, most probably in unexpected ways. The function may also be user-defined so you could write a wrapper around a function like lm() to return values like the intercept or any coefficients from the object returned by calling that function.

Returns

A CFData object, or a list thereof with as many CFData objects as fun returns values, created in the same group as self with the summarised data.


Method clone()

The objects of this class are cloneable with this method.

Usage

CFVariableBase$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.