Hi Nana, This is not a r-devel question.
I suspect this should be something like: write.netcdf.time(paste(path,'cam_fore.nc',sep=""), fore[,,times] ,lon,lat,times) Robert On Tue, Nov 10, 2009 at 8:31 AM, nana <amabr...@yahoo.com> wrote: > Dear CSAG R users, > > I will be glad if someone can point out what I am doing wrong or not doing at > all in this. > > I am trying to write out netcdf file in R. I have 26 time step but only the > first time step is written. > > For example: >>library(ncdf) >>path <- '/home/work/' >>forecast <- open.ncdf(paste(path,'cam.1980.2005.nc',sep="")) >> fore <- get.var.ncdf(forecast,'ppt') >> lon <- get.var.ncdf(forecast,'lon') >> lat <- get.var.ncdf(forecast,'lat') >>dim(fore)[3] >>26 >> times <- 1:dim(fore)[3] >> write.netcdf.time(paste(path,'cam_fore.nc',sep=""), fore,lon,lat,times) > [1] "put.var.ncdf: warning: you asked to write 1440 values, but the passed > data array has 37440 entries!" > [[1]] > [1] 6 > > Warning message: > In 1:nt : numerical expression has 26 elements: only the first used > > > ################# function for writing out the netcdf file ############# > write.netcdf.time <- function(filename='outputfile.nc',data,lons,lats,nt){ > lon <- dim.def.ncdf('lon','degrees_east',lons) > lat <- dim.def.ncdf('lat','degrees_north',lats) > times <- 1:nt > tdim <- dim.def.ncdf('time','days since 1980-01-01', times, unlim=TRUE) > # levs <- dim.def.ncdf('lev','pressure',levs) > var <- var.def.ncdf('data','unitless',list(lon,lat,tdim),-999.9) > ncid <- create.ncdf(filename,list(var)) > put.var.ncdf(ncid, var, data) > close.ncdf(ncid) > } > > ##########################end of function####################### > > Thank you. > Nana Browne > > ==================================================================== > > There is no key to happiness. The door is always open. > > > > [[alternative HTML version deleted]] > > ______________________________________________ > r-de...@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.