Error when merging netCDF files

Hi,

I'm trying to merge monthly .nc files into single yearly files. The monthly files have 86 variables 13 dimensions and 37 NetCDF attributes.

I've been trying to use this code, this is an example when I try to merge two files:

transNcdfMerge(c(jan01,feb01, name.change = function(x) return(x),
    time.diff = NULL, fun.start = NULL, fun.end = NULL, time.range.out = c(),
    format = "%Y%m", convert = function(x) chron(paste(x, "15",
        sep = ""), format = "ymd", out.format = "d-m-y"), path.target = getwd(),
    target.name = "output.nc")

But I get this error message:

Error in convertDateNcdf2R(fileT) : 
  time.source needs to be numeric if not a netCDF file connection!```

So I tried to use the date converting code like this:

timevector<- ncvar_get(jan01,attributes(jan01$dim)$names[1])
new_time2<- convertDateNcdf2R(timevector, units = "seconds",
origin = as.POSIXct("1999-01-01 00:00:00",tz = "UTC"),
time.format = c("%Y-%m-%d %H:%M:%S"))```

This seemed to be working and correct so then I tried to merge again like this

ttransNcdfMerge(c(jan01,feb01), name.change = function(x) return(x),
               time.diff = NULL, fun.start = NULL, fun.end = NULL, time.range.out = c(new_time2,new_time3),
               format = "%Y-%m-%d %H:%M:%S", convert = function(x) chron(paste(x, "15",
                                                                               sep = ""), format = "%Y-%m-%d %H:%M:%S", out.format = "%Y-%m-%d %H:%M:%S"), path.target = getwd(),
               target.name = "out.nc")

But I keep getting the same error message as above.
Any help is deeply appreciated!
Vivien

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.