Correct as.s2dv_cube to avoid overwrite variables with different length in multiple datasets:
Within the element Variables creation loop, if variable (ex. 'lon') is already there, don't add it to esult$attrs$Variable$metadata
. This could cause inconsistency if datasets are loaded with different longitudes or latitudes values.
With this change, the coordinates elements and the corresponding metadata in $attrs$Variables
is equal.
## Variables
for (var_type in names(attributes(object)$Variables)) {
if (!is.null(attributes(object)$Variables[[var_type]])) {
for (var in names(attributes(object)$Variables[[var_type]])) {
attr_variable <- attributes(object)$Variables[[var_type]][[var]]
if (is.null(result$attrs$Dates)) {
if (inherits(attr_variable, "POSIXct")) {
result$attrs$Dates <- attr_variable
}
}
if (is.null(result$attrs$Variable$metadata[[var]])) {
result$attrs$Variable$metadata[[var]] <- attr_variable
}
}
}
}