i use library(ncdf) to read this file as follow library(ncdf) sst.nc = open.ncdf(title) lonall = get.var.ncdf(sst.nc,'lon') latall = get.var.ncdf(sst.nc,'lat') precip = get.var.ncdf(sst.nc,'pre') close(sst.nc) if i use this method my pc freeze and not respond until i restart it is there -- View this message in context: http://r.789695.n4.nabble.com/i-can-t-read-large-NETCDF-file-like-CRU-tp4185435p4185435.html Sent from the R help mailing list archive at Nabble.com.
On 12/12/2011 10:19 AM, tony333 wrote:> i use library(ncdf) to read this file as follow > library(ncdf) > sst.nc = open.ncdf(title) > lonall = get.var.ncdf(sst.nc,'lon') > latall = get.var.ncdf(sst.nc,'lat') > precip = get.var.ncdf(sst.nc,'pre') > close(sst.nc) > if i use this method my pc freeze and not respond until i restart it is > there > > -- > View this message in context: http://r.789695.n4.nabble.com/i-can-t-read-large-NETCDF-file-like-CRU-tp4185435p4185435.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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.Hi Tony, We are sympathetic to your cause, but without more information helping you is really hard. Please consult the posting guide: PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. for some more hints. regards, Paul ps This question might be more suitable for R-sig-geo ps2 You could use the raster package to analyse the data on the harddrive (not reading all data in from disk) -- Paul Hiemstra, Ph.D. Global Climate Division Royal Netherlands Meteorological Institute (KNMI) Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39 P.O. Box 201 | 3730 AE | De Bilt tel: +31 30 2206 494 http://intamap.geo.uu.nl/~paul http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770
On Mon, Dec 12, 2011 at 2:19 AM, tony333 <tony333_6@hotmail.com> wrote:> i use library(ncdf) to read this file as follow > library(ncdf) > sst.nc = open.ncdf(title) > lonall = get.var.ncdf(sst.nc,'lon') > latall = get.var.ncdf(sst.nc,'lat') > precip = get.var.ncdf(sst.nc,'pre') > close(sst.nc) > if i use this method my pc freeze and not respond until i restart it is > there >As Paul already mentioned, more information would be useful, but here's a suggestion. If you have a data set that is too big to fit in your computer's memory, read it in one timestep at a time and process that timestep. For example, you could get the number of timesteps in the variable like this: varname = 'pre' sst.nc = open.ncdf(file) varsize = sst.nc$var[[varname]]$size nt = dim( varsize )[3] Then read in one timestep at a time and process it: for( itstep in 1:nt ) { data = get.var.ncdf( sst.nc, varname, start=c(1,1,itstep), count=c(-1,-1,1)) ...process one timestep of the data here ... } Regards, --Dave -- Dr. David W. Pierce Division of Climate, Atmospheric Science, and Physical Oceanography Scripps Institution of Oceanography, La Jolla, California, USA (858) 534-8276 (voice) / (858) 534-8561 (fax) dpierce@ucsd.edu [[alternative HTML version deleted]]