NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.
To learn about what's going on, see About the Archive Site.
summary: I can successfully ncvar_put(...) data to a file, but when I try to ncvar_get(...) the same data, I get > Error in if (nc$var[[li]]$hasAddOffset) addOffset = nc$var[[li]]$addOffset > else addOffset = 0 : > argument is of length zero How to fix or debug? details: R code @ https://github.com/TomRoche/GEIA_to_NetCDF successfully (if crudely) uses R packages={ncdf4, maps, fields} to + extract data from a GEIA-distributed datafile https://github.com/downloads/TomRoche/GEIA_to_netCDF/N2OOC90Y.1A + display the data (mostly successfully--the map's legend has problems which I'll attack later) https://github.com/downloads/TomRoche/GEIA_to_netCDF/output.1.png + create a netCDF file using the data read from the GEIA file. (At least, after nc_sync(netcdf.file), the file `ncdump -h`s properly.) However, I can only *put* the data to the netCDF file: > ncvar_put( > + nc=netcdf.file, > + varid=emis.var, > + vals=t(global.emis.mx), > + start=c(1, 1, 1), > + count=c(-1,-1, 1)) # -1 -> all data When I try to *pull* the data *from* the netCDF I created, > > target.data <- ncvar_get( > + nc=netcdf.file, > + varid=emis.var, > + # read all the data > + start=rep(1, emis.var$ndims), > + # count=rep(-1, emis.var$ndims)) I get > Error in if (nc$var[[li]]$hasAddOffset) addOffset = nc$var[[li]]$addOffset > else addOffset = 0 : > argument is of length zero And I get the same error if I try the minor variation(s) > target.data <- ncvar_get( + nc=netcdf.file, + # varid=emis.var, + varid=emis.var.name, + # read all the data + start=rep(1, emis.var$ndims), + count=c(-1, -1, 1)) But the data itself appears to be OK--at least, it virtualizes properly (above). So I'm thinking I must just be missing something simple, and hoping Someone Out There with fresh eyeballs can point to my error(s). (And, in case you're wondering: - I'm not just ncvar_put'ing the data for the exercise: I want the GEIA data in netCDF format for subsequent use. - I tried to find the GEIA data distributed in netCDF format, and asked around, but have gotten no responses. ) TIA, Tom Roche <Tom_Roche@xxxxxxxxx>
netcdfgroup
archives: