ArrayToNc: Not taking into account variable names in attributes list.
As reported by @rcruzgar , the following code doesn't correcly interpret the variable name 'sic_nohole' as provided in the 'variables' attribute in the input array, and the variable in the generated netCDF is assigned the default name var1_1. Older versions of this function took the name correctly.
library(easyNCDF)
sic_nohole <- array(rnorm(360*180*460), dim = c(lat = 180, lon = 360, time = 460))
lon <- as.numeric(0:359)
lat <- as.numeric(seq(-90, 90, length.out = 180))
names(dim(sic_nohole)) <- c('lat', 'lon','time')
metadata <- list(sic_nohole = list(units = '1'))
attr(sic_nohole, 'variables') <- metadata
dim(lon) <- length(lon)
names(dim(lon)) <- 'lon'
metadata <- list(lon = list(units = 'degrees_east'))
attr(lon, 'variables') <- metadata
dim(lat) <- length(lat)
names(dim(lat)) <- 'lat'
metadata <- list(lat = list(units = 'degrees_north'))
attr(lat, 'variables') <- metadata
ArrayToNc(list(sic_nohole, lon, lat), 'tmp.nc')
ncdump -h tmp.nc
netcdf tmp {
dimensions:
lat = 180 ;
lon = 360 ;
time = UNLIMITED ; // (460 currently)
variables:
float var1_1(time, lon, lat) ;
float lon(lon) ;
lon:units = "degrees_east" ;
float lat(lat) ;
lat:units = "degrees_north" ;
}