NCObject | R Documentation |
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.
id
Numeric identifier of the netCDF object.
name
The name of the netCDF object.
attributes
data.frame
with the attributes of the netCDF object.
new()
Create a new netCDF object. This class should not be instantiated directly, create descendant objects instead.
NCObject$new(id, name)
id
Numeric identifier of the netCDF object.
name
Character string with the name of the netCDF object.
print_attributes()
This function prints the attributes of the netCDF object to the console. Through object linkages, this also applies to the CF data variables and axes, which each link to a netCDF object.
NCObject$print_attributes(width = 50L)
width
The maximum width of each column in the data.frame
when
printed to the console.
attribute()
This method returns an attribute of a netCDF object.
NCObject$attribute(att, field = "value")
att
Attribute name whose value to return.
field
The field of the attribute to return values from. This must be "value" (default) or "type".
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.
set_attribute()
Add an attribute. If an attribute name
already exists, it
will be overwritten.
NCObject$set_attribute(name, type, value)
name
The name of the attribute. The name must begin with a letter and be composed of letters, digits, and underscores, with a maximum length of 255 characters. UTF-8 characters are not supported in attribute names.
type
The type of the attribute, as a string value of a netCDF data type.
value
The value of the attribute. This can be of any supported type, including a vector or list of values. Matrices, arrays and like compound data structures should be stored as a data variable, not as an attribute and they are thus not allowed. In general, an attribute should be a character value, a numeric value, a logical value, or a short vector or list of any of these. Values passed in a list will be coerced to their common mode.
Self, invisibly.
append_attribute()
Append the text value of an attribute. If an attribute
name
already exists, the value
will be appended to the existing
value of the attribute. If the attribute name
does not exist it will
be created. The attribute must be of "NC_CHAR" or "NC_STRING" type; in
the latter case having only a single string value.
NCObject$append_attribute(name, value, sep = "; ", prepend = FALSE)
name
The name of the attribute. The name must begin with a letter and be composed of letters, digits, and underscores, with a maximum length of 255 characters. UTF-8 characters are not supported in attribute names.
value
The character value of the attribute to append. This must be a character string.
sep
The separator to use. Default is "; "
.
prepend
Logical to flag if the supplied value
should be placed
before the existing value. Default is FALSE
.
Self, invisibly.
delete_attribute()
Delete attributes. If an attribute name
is not present
this method simply returns.
NCObject$delete_attribute(name)
name
Vector of names of the attributes to delete.
Self, invisibly.
write_attributes()
Write the attributes of this object to a netCDF file.
NCObject$write_attributes(nc, nm)
nc
The handle to the netCDF file opened for writing.
nm
The NC variable name or "NC_GLOBAL" to write the attributes to.
Self, invisibly.
clone()
The objects of this class are cloneable with this method.
NCObject$clone(deep = FALSE)
deep
Whether to make a deep clone.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.