Re: [R] how to read netcdf file in R
On Fri, Apr 13, 2012 at 12:09 AM, Yogesh Tiwari yogesh@googlemail.com wrote: Dear David, Thanks, I could read and open .nc file in R, but now how to plot a simple filled color. [...] Hi Yogesh, glad to hear that the ncdf package is doing its job correctly. I'm sure you understand that I don't have the resources to answer miscellaneous general questions about how to use R, especially considering that there are good instruction manuals freely available on the web. You can also buy a textbook on R if you want to learn it in a more structured fashion. Either way, R is a capable system that rewards a modest effort devoted to learning how to use it. Regards, --Dave -- 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) dpie...@ucsd.edu __ 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.
Re: [R] how to read netcdf file in R
On Mon, Apr 2, 2012 at 1:54 AM, Yogesh Tiwari yogesh@googlemail.com wrote: How to read netcdf files in R ? Which packeges do we need to install for this, and what commands are used for reading netcdf files. Typical code would look something like this: library('ncdf'') filename - 'data.nc' varname - 'Temperature' ncid - open.ncdf( filename ) data - get.var.ncdf( ncid, varname ) If you need to see what variables the file contains to get the variable names, just do a print(ncid) after you open it. If it is a very large file, too large for the data to fit in memory all at once, you can step through and read each timestep in the file separately using the start= and count= arguments to the get.var.ncdf() call. Regards, --Dave -- 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) dpie...@ucsd.edu __ 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.
Re: [R] [ncdf] programmatically copying a netCDF file
Hi Tom, a few answers to your questions: On Mon, Jan 9, 2012 at 3:54 PM, Tom Roche tom_ro...@pobox.com wrote: :-) I guess I should have explained: I need to copy most of a source file, modifying only part, and to write a target file. So my motivation for this thread is, first, to be sure I can do the copying correctly (*not* merely to copy an netCDF file). Does this seem reasonable? Well ... all I can say is I'd advise against doing this. I think it's the wrong approach. Better to use 'cp' to make a bit-for-bit copy and then modify that. I.e., infile = 'data.nc' outfile = 'data_new.nc' varname = 'ozone' cmd = paste('cp',infile,outfile) system(cmd) ncid = open.ncdf( outfile, write=TRUE ) ...modify exact copied file as desired, for example: var = ncid$var[[varname]] data_old = var.get.ncdf( ncid, var ) data_new = some_function( data_old ) var.put.ncdf( ncid, var, data_new ) close.ncdf( ncid ) 1 Precisions int and float not supported by var.def.ncdf(...). When I tried to do (formatted for email) target.datavars[[target.datavars.i]] - var.def.ncdf(source.datavar$name, source.datavar$units, target.datavar.dims, source.datavar$missval, - prec=source.datavar$prec) I got - var.def.ncdf: error: unknown precision specified: int . - Known values: short single double integer char byte Sorry, bug. Unfortunately ncdf4 is the new and supported release -- netcdf library version 4 has been out for years now -- so I concentrate on supporting that. 2 Copying I/O API global attributes fails. I/O API uses lots of these (33 in my source.nc!), so my diff has -// global attributes: - :IOAPI_VERSION = 1.0 1997349 (Dec. 15, 1997) ; - :EXEC_ID = ; - :FTYPE = 1 ; - :CDATE = 2011353 ; - :CTIME = 1224 ; + ) for (attr.name in global.attr.name.list) { + source.datavar.attr - att.get.ncdf(source.file, 0, attr.name) + att.put.ncdf(target.file, 0, attr.name, source.datavar.attr$value) + } I think you *don't* want that leading colon (:). That's the syntax of ncdump, not the name of the attribute. I.e., the attribute name is FTYPE, not :FTYPE. 3 When I diff my `ncdump`s, i.e., $ diff -uwB ( ncdump -h source.nc ) ( ncdump -h target.nc ) I get This is why you want to use 'cp' to make a bit-for-bit copy. *In general*, R cannot guarantee a bit-for-bit copy programatically because it does not have all the data types that a netcdf file supports. So if you really want a bit-for-bit copy, use 'cp', that's what it's for. You could, with enough effort, manipulate the ncdf library into making a file with the same structure as the original, but it's not set up for that. Think of it this way. You want to copy a database. The database is held in a netcdf file. Using ncdf, R provides a way of generating a new database that has the same information in it as the original database. However, the bits might be arranged differently. Maybe the original has table-A stored before table-B, and the copy has table-B stored before table-A. This won't matter to someone who uses the database. Using 'diff' checks if the actual bits are arranged exactly the same, not whether the same information is in the two data sets. * the target file has *new* coordinate variables for the dimensions. * I don't understand why those coordinate variables weren't in the source file. But they're not! ncdf4 provides a mechanism to suppress creating a coordinate variable. 4 Attribute=long_name is missing for every original/copied data variable. Hence when I diff my `ncdump`s I also get, e.g., int TFLAG(TSTEP, VAR, DATE-TIME) ; TFLAG:units = DDD,HHMMSS ; - TFLAG:long_name = TFLAG; TFLAG:var_desc = ... Just a bug. Fixed in ncdf4. -- 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)dpie...@ucsd.edu [[alternative HTML version deleted]] __ 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.
Re: [R] [ncdf] programmatically copying a netCDF file
On Thu, Jan 5, 2012 at 3:29 PM, Tom Roche tom_ro...@pobox.com wrote: How to programmatically (i.e., without no or minimal handcoding) copy a netCDF file? (Without calling system(cp whatever wherever) [...] So I'm wondering, can anyone point me to, or provide, code that copies a netCDF file both * completely: all coordinate variables, all data variables and their attributes, and all global attributes, such that $ diff -wB ( ncdump -h source.nc ) ( ncdump -h target.nc ) | wc -l 0 * programmatically: no or minimal hand-coding of, e.g., attribute names and values, missing-value value. ? If not, can this be done in principle, or are there steps that must (at least currently) necessarily be hand-coded? Hi Tom, yes, this can be done in principle, although it would be a pain. Mostly because a netcdf file is a surprisingly complicated object, so asking for R script that copies one programmatically is actually asking quite a lot. You might think that it should be as easy as grab THIS var ... then grab THAT var .. then write them both to the output file. But that fails, because vars have dims, and in classic netcdf files the dims are identified by name. What if one var has a lon dim with 360 entries, and the other has a lon dim with 128 entries? Putting them both into the same file will give an error. What I'd suggest is keeping focused on your goal. Since cp file1.nc file2.nc accomplished a complete copy of your netcdf file in a few seconds of typing, simply copying the file generally isn't the point of an R script. If I wanted to copy a var from an existing file to a new file, manipulating it along the way, I'd do something like this (untested code off the top of my head): varname = 'temperature' file_in = 'data1.nc' file_out = 'data2.nc' # Get var to copy ncid_in = open.ncdf( file1 ) var = ncid_in$var[[varname]] # Make new output dims that are copies of input dims ndims = var$ndims dim_out = list() for( idim in 1:ndims ) { dim_in = var$dim[[idim]] dim_out[[idim]] = dim.def.ncdf( dim_in$name, dim_in$units, dim_in$vals, unlim=dim_in$unlim ) } # Make output var that is copy of input var var_out = var.def.ncdf( var$name, var$units, dim_out, var$missval ) ncid_out = create.ncdf( file_out, var_out ) # Loop over timesteps to avoid running out of memory sz = var$varsize nt = sz[ndims] for( it in 1:nt ) { # Goal of following lines is to construct a 'start' array that is (1,1,...,it) and a count array # that is (nx,ny,,1) start = array(1,ndims-1) count = sz[1:(ndims-1)] start = c(start, it)# Get just this timestep count = c(count, 1) # Get just this timestep data = get.var.ncdf( ncid_in, var, start=start, count=count ) # ... Manipulate data here ... put.var.ncdf( ncid_out, var_out, data, start=start, count=count ) sync.ncdf( ncid_out ) # always a good idea to keep your file sync'ed } close.ncdf( ncid_out ) Hope that gets you started, --Dave -- 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)dpie...@ucsd.edu [[alternative HTML version deleted]] __ 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.
Re: [R] where to ask questions regarding package=ncdf?
On Mon, Jan 2, 2012 at 6:08 PM, Tom Roche tom_ro...@pobox.com wrote: Should one ask questions relating to the R package 'ncdf' here? or look for a more netCDF-oriented (but probably less R-oriented) list? Hi Tom, you can ask here and I can give a shot at answering them (I'm the author of the ncdf and ncdf4 packages). The netcdf library also has a mailing list run out of ucar, but that doesn't usually address packages that use netcdf so much as the library itself. Regards, --Dave -- 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)dpie...@ucsd.edu [[alternative HTML version deleted]] __ 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.
Re: [R] i can't read large NETCDF file like CRU
On Mon, Dec 12, 2011 at 2:19 AM, tony333 tony33...@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)dpie...@ucsd.edu [[alternative HTML version deleted]] __ 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.
Re: [R] ncdf - install error
2011/9/24 Muhammad Rahiz muhammad.ra...@ouce.ox.ac.uk: Dear all, I'm having issues with the installation of the ncdf package. It returns a non-zero exit status. Can anyone suggest what I should do next? FYI, I do not have problems installing other packages. [...] /usr/bin/ld: /usr/local/lib/libnetcdf.a(attr.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC /usr/local/lib/libnetcdf.a: could not read symbols: Bad value collect2: ld returned 1 exit status make: *** [ncdf.so] Error 1 ERROR: compilation failed for package ‘ncdf’ * removing ‘/home/rahiz/R/x86_64-redhat-linux-gnu-library/2.13/ncdf’ See that part where it said /usr/local/lib/libnetcdf.a needed to be recompiled with -fPIC? It means that the netcdf library on your machine, which is located in /usr/local/lib, needs to be recompiled with the -fPIC flag specified. :) I suggest consulting the netcdf library documentation for how to do this, or talk to your system administrator, or ask one of your local computer experts. Regards, --Dave -- David W. Pierce Division of Climate, Atmospheric Science, and Physical Oceanography Scripps Institution of Oceanography (858) 534-8276 (voice) / (858) 534-8561 (fax) dpie...@ucsd.edu __ 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.
Re: [R] Problem in put.var.ncdf
On Mon, Sep 12, 2011 at 1:32 PM, Claudia Stocker cstoc...@climate.unibe.ch wrote: Dear all, I have a problem in writing a variable to a NetCDF-File. My code works pretty well until the step put.var.ncdf(): [...code omitted...] R prints the following error: #- Error in put.var.ncdf(spi, var.spi.24.03.me, spi24.me) : NA/NaN/Inf in foreign function call (arg 5) I can exclude an error in length (dim.time.spi and spi24.me have the same length) or NA (there are no NA in the spi24.me vector). Where is the error?? The code seems so simple.. Hi Claudia, could you put the following code in right before the put.var.ncdf call and see what it prints: print(paste('num of NAs in time:, sum(is.na(dim.time)) )) print(paste(length of time:, length(dim.time) )) print(paste(num of NAs in spi24.me:, sum(is.na(spi24.me)) )) print(paste(length of spi24.me:, length(spi24.me) )) If that doesn't show anything wrong, you can email me the data and your code and I can give it a try. Or, you can try the newest version of the ncdf/ncdf4 packages, which you can download from: http://cirrus.ucsd.edu/~pierce/ncdf/ it may be a bug that I've already fixed. Regards, --Dave -- David W. Pierce Division of Climate, Atmospheric Science, and Physical Oceanography Scripps Institution of Oceanography (858) 534-8276 (voice) / (858) 534-8561 (fax) dpie...@ucsd.edu __ 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.
Re: [R] Editing the variables attributes section in the netCDF header of netCDF files created using the package ncdf.
On Fri, Sep 9, 2011 at 3:18 PM, RMaidment r.i.maidm...@pgr.reading.ac.uk wrote: Another question which you might be able to answer is, is it possible to set the order of the variables attributes in which they appear? [...] Hi Ross, The ncdf package makes the units and longname attributes automatically, so those will always be the first and second attributes, and the ones you add using att.put.ncdf will follow later in the order of your att.put.ncdf calls. So no, there is no way of arranging them all in arbitrary order. I would personally consider any software that cares about the order of the attributes to be non-compliant with netCDF standards, but perhaps there is some software out there that does care about the order anyway. Regards, --Dave -- David W. Pierce Division of Climate, Atmospheric Science, and Physical Oceanography Scripps Institution of Oceanography (858) 534-8276 (voice) / (858) 534-8561 (fax) dpie...@ucsd.edu __ 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.
Re: [R] Editing the variables attributes section in the netCDF header of netCDF files created using the package ncdf.
On Wed, Sep 7, 2011 at 2:25 PM, Ross Maidment r.i.maidm...@pgr.reading.ac.uk wrote: Hi, I am using the package ncdf to create netCDF files and I want to mimic the the header of an exiting netCDF file created outside of R. Below is what the existing header looks like (part of it that is different): netcdf ccd1984_05_08 { dimensions: lat = 1974 ; [...listings omitted...] I am unable to replicate the variables attributes that exist in the first example in the second example. Is there anyway to transfer across the header information or edit the ncdf package to do this? Hi Ross, to specify the units attribute in the output file, you just set the units parameter correctly when calling dim.def.ncdf. Since your ncdf-created file has blank units attributes, I can only assume your R code is doing something like this: dim_lon - dim.def.ncdf( 'lon', , lonvals ) when it should be doing something more like this: dim_lon - dim.def.ncdf( 'lon', degrees_east, lonvals ), etc. Easiest way to copy a dimension is R code like this: file2copy = 'old_file.nc' ncid_old = open.ncdf( file2copy ) dim2copy = lon old_dim = ncid_old$dim[[ dim2copy ]] new_dim = dim.def.ncdf( old_dim$name, old_dim$units, old_dim$vals, unlim=old_dim$unlim, longname=old_dim$longname ) For attributes other than units, you can use the att.put.ncdf() call. You make this call AFTER you have created the output file: ... ncid_out = create.ncdf( 'new_output_file.nc', list(output_vars1,...,output_varN)) att.put.ncdf( ncid_out, 'lat', 'axis', 'Y' ) att.put.ncdf( ncid_out, 'ccd', 'Unit_duration', 7.5 ) etc. --Dave __ 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. -- David W. Pierce Division of Climate, Atmospheric Science, and Physical Oceanography Scripps Institution of Oceanography (858) 534-8276 (voice) / (858) 534-8561 (fax)dpie...@ucsd.edu [[alternative HTML version deleted]] __ 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.
Re: [R] HIRHAM netcdf files
On Fri, Jul 29, 2011 at 7:44 AM, Ana rrast...@gmail.com wrote: Can someone help me out with a small problem? I've started using netcdf files recently, and I want to extract the grid id and also the coordinates from a HIRHAM netcdf file. I know how to extract a slice of dataset both in space and in time and I also know the area that this file should cover, however I have no idea regarding the reference for both LAT/LON and RLAT/RLON. I tried already tried is ArcGIS to give the Lambert Conformal Conic projection as the spatial reference, by default arcgis gets the rlat and rlon for coordinates. however the resulting raster is displaced from were it should be. Can someone help me with this? Hello, I can't tell if you're asking: * How to tell what information is in your netcdf file, * How to get the data you need out of your netcdf file, * How to interpret the data you are getting from the netcdf file. Perhaps you could be a bit clearer? As a suggestion, try ncdump -h filename.nc and look to see what information is in your file. Is it what you expected need? Regards, --Dave -- David W. Pierce Division of Climate, Atmospheric Science, and Physical Oceanography Scripps Institution of Oceanography (858) 534-8276 (voice) / (858) 534-8561 (fax)dpie...@ucsd.edu [[alternative HTML version deleted]] __ 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.
Re: [R] Select element out of several ncdf variables
On Thu, Jul 7, 2011 at 9:10 AM, confused cstoc...@climate.unibe.ch wrote: Hi there I'm working with ncdf data. I have different dataset for 4 runs, 4 seasons and 3 timeslices (48 datasets in total). The datasets have the following dimensions: 96 longitudes, 48 latitudes and 30 time steps. To read all of them in, I wrote the following loop: runs - c(03,04,05,06) years - c(1851,1961,2061) seasons - c(DJF,MAM,JJA,SON) for (i in runs) { for (j in years) { for (k in seasons) { data - open.ncdf(paste(/data09/cstocker/data/atm/tr_1500_, i,/PRECT/PREC_tr1500_, i,_, j,_, k,.nc, sep=)) prect - get.var.ncdf(data, PRECT) assign(paste(prec, k, j, i, sep=_), prect) } } } I produced 48 variables called prec_DJF_1851_03 and so on.. Now, how can I select an element out of each of these variables? Are all your data arrays (i.e., the data in each of your 48 files) the same shape? If so, easiest approach (assuming I'm understanding your problem, which is not a given!) would be simply to put all the data into one array in the first place. I.e, something like: nruns - length(runs) nyears - length(years) nseaons - length(seasons) bigdata - NA# flag to show it's not initialized yet for (i in runs) { for (j in years) { for (k in seasons) { data - open.ncdf(paste(/data09/cstocker/data/atm/tr_1500_,i,/PRECT/PREC_tr1500_, i,_, j,_, k,.nc, sep=)) prect - get.var.ncdf(data, PRECT) if( length(bigdata) == 1 ) { # is bigdata un-initialized? nx = dim(prect)[1] ny = dim(prect)[2] nz = dim(prect)[3] bigdata = array(0., dim=c(nx,ny,nz,nseasons,nyears,nruns)) } bigdata[,,,k,j,i] = prect close.ncdf( data )# remember to close the file } } } Then you can conveniently select from bigdata however you want. If the shape of the data in each file is different, you have to use an analogous approach with lists instead. Regards, --Dave -- David W. Pierce Division of Climate, Atmospheric Science, and Physical Oceanography Scripps Institution of Oceanography (858) 534-8276 (voice) / (858) 534-8561 (fax)dpie...@ucsd.edu [[alternative HTML version deleted]] __ 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.
Re: [R] read a netcdf file _Fill_value=-32768
On Fri, May 6, 2011 at 10:11 AM, francoise orain francoise.or...@meteo.frwrote: Hello I am a new user of R . and I ve problem with R and netcdf . I succed installation , I could use all examples . But when I take my netcf it is different . I want to do statistic on this kind of file . 1) first calculate mean . my data is like that through ncdump -h test.nc netcdf test { dimensions: lat = 301 ; lon = 401 ; time = UNLIMITED ; // (80 currently) variables: float lat(lat) ; lat:long_name = latitude ; lat:standard_name = latitude ; lat:units = degrees_north ; lat:valid_range = -60., 60. ; float lon(lon) ; lon:long_name = longitude ; lon:standard_name = longitude ; lon:units = degrees_east ; lon:valid_range = -100., 45. ; double sst(time, lat, lon) ; sst:long_name = sea surface temperature ; sst:standard_name = sea_surface_temperature ; sst:units = K ; sst:_FillValue = -32768. ; double time(time) ; time:long_name = time ; time:standard_name = time ; time:units = seconds since 1981-01-01 00:00:00 ; time:ancillary_variables = sst_data_processed_flag ; I succeed to read it with R, there is only one variable sst 80 days and lat = 301 lon = 401 (this file is already a concatenation with nco fonctions . Here is what I do : nc-open.ncdf(test.nc) summary (nc) data- get.var.ncdf(nc) print (data) answer extract : [331,] -32768.00 -32768.00 -32768.00 -32768.00 -32768.00 -32768.00 -32768.00 [332,] -32768.00 -32768.00 -32768.00 -32768.00 -32768.00 -32768.00 -32768.00 [,295][,296][,297][,298][,299][,300][,301] [1,] 0.10 0.10 0.12 0.15 0.15 0.14 0.15 [2,] 0.12 0.12 0.13 0.15 0.15 0.14 0.15 [3,] 0.13 0.13 0.13 0.16 0.14 0.14 0.14 [4,] 0.15 0.13 0.11 0.16 0.15 0.15 0.15 [5,] 0.17 0.16 0.15 0.15 0.16 0.17 0.15 #_fill_value is at -32768.00 Hello, I'm not sure what the problem you are experiencing is. As a practical matter, I suggest you try something like this: nc-open.ncdf(test.nc) summary (nc) data- get.var.ncdf(nc) data[ data -32000 ] - NA Regards, --Dave -- David W. Pierce Division of Climate, Atmospheric Science, and Physical Oceanography Scripps Institution of Oceanography (858) 534-8276 (voice) / (858) 534-8561 (fax)dpie...@ucsd.edu [[alternative HTML version deleted]] __ 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.
Re: [R] Reading a large netCDF file using R
On Tue, May 10, 2011 at 10:17 AM, Sulochan Dhungel sulochandhun...@gmail.com wrote: Hi Dave, I asked for the climate group for one particular day's data so that I could match it up with the data I got from the codes for the same day. It did not match. So I knew it was not working. Also time is the first thing on the list of summary for nc , but when I saw other netCDF files, time was the last thing. Thanks again for looking into my problem. Sulochan Hi Sulochan, whether time is listed first or last depends on the application ... in R, it's listed last. In some other applications, it's listed first. So that's just one of those things, and doesn't mean anything is wrong. Re the data not matching, I fear that is some other problem then start and count in the R get.var.ncdf() call not working correctly. I suggest you check the exact values you use for start and count. Using a time index of 1 in R gives you the first time entry. --Dave [[alternative HTML version deleted]] __ 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.
Re: [R] Reading a large netCDF file using R
On Mon, May 9, 2011 at 6:29 PM, sulochandhungel sulochandhun...@gmail.comwrote: I got a netCDF file from a climate group and wanted to aggregate the data. The file summary looks like this [...] I didnt think it worked... can u suggest me some other way ... I could not use the start and count properly Could you be a little more explicit? Why don't you think it worked? In general, you seem to be using count and start correctly. --Dave -- David W. Pierce Division of Climate, Atmospheric Science, and Physical Oceanography Scripps Institution of Oceanography (858) 534-8276 (voice) / (858) 534-8561 (fax)dpie...@ucsd.edu [[alternative HTML version deleted]] __ 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.