Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Earth Sciences
easyNCDF
Commits
50b46707
Commit
50b46707
authored
May 24, 2018
by
Nicolau Manubens
Browse files
Possible to specify global attrs.
parent
70e1bb98
Changes
2
Show whitespace changes
Inline
Side-by-side
R/ArrayToNc.R
View file @
50b46707
...
...
@@ -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
]
...
...
man/ArrayToNc.Rd
View file @
50b46707
...
...
@@ -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(
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment