Commit 50b46707 authored by Nicolau Manubens's avatar Nicolau Manubens
Browse files

Possible to specify global attrs.

parent 70e1bb98
......@@ -23,7 +23,10 @@ ArrayToNc <- function(arrays, file_path) {
} else {
vars_info <- NULL
}
global_attrs[names(array_attrs)] <- array_attrs
#global_attrs[names(array_attrs)] <- array_attrs
if ('global_attrs' %in% names(array_attrs)) {
global_attrs <- c(global_attrs, array_attrs[['global_attrs']])
}
var_dim <- which(names(dim(arrays[[i]])) %in% c('var', 'variable'))
if (length(var_dim) > 0) {
var_dim <- var_dim[1]
......
......@@ -155,6 +155,17 @@ attr(a, 'variables') <- metadata
names(dim(a)) <- c('lat', 'lon', 'time', 'var')
ArrayToNc(a, 'tmp.nc')
# Global attributes can be specified
a <- array(rnorm(10), dim = c(a = 5, b = 2))
attrs <- list(variables =
list(tas = list(var_attr_1 = 'test_1_var',
var_attr_2 = 2)),
global_attrs = list(global_attr_name_1 = 'test_1_global',
global_attr_name_2 = 2)
)
attributes(a) <- c(attributes(a), attrs)
ArrayToNc(a, 'tmp.nc')
# Unlimited dimensions can be manually created
a <- array(1:400, dim = c(5, 10, 4, 2))
metadata <- list(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment