I am trying to create a multi-dimensional NetCDF file using the R package ncdf. I am working with climatic daily observations for a set of 1500 points, the number of observations is ~ 18250 for each point. The problem is that the structure of the NetCDF file (create.ncdf) occupies 4Gb and each point makes the size of the file increase by more than 3 Gb (put.var.ncdf)
This is the code I am using:
# Make a few dimensions we can use
dimX <- dim.def.ncdf( "Long", "degrees", Longvector )
dimY <- dim.def.ncdf( "LAT", "degrees", Latvector )
dimT <- dim.def.ncdf( "Time", "days", 1:18250, unlim=FALSE )
# Make varables of various dimensionality, for illustration purposes
mv <- -9999 # missing value to use
var1d <- var.def.ncdf( "var1d", "units", dimX, mv,prec="double" )
var2d <- var.def.ncdf( "var2d", "units", list(dimX,dimY), mv,prec="double" )
var3d <- var.def.ncdf( "var3d", "units", list(dimX,dimY,dimT), mv,prec="double" )
# Create the test file
nc <- create.ncdf( "writevals.nc", list(var1d,var2d,var3d) )
# !!Creates a nc file with + 4 Gb
# Adding the complete time series for one point (the first point in the list of the dataset)
put.var.ncdf( nc, var3d,dataset[[1]], start=c(Longvector[1],Latvector[1],1), count=c(1,1,-1))
Longvector and Latvector are vectors taken from the matrix with the Long and Lat for each point. The dataset is a list format and for each point I have a list of numeric values.
dataset[[1]]=c(0,0,0,9.7,0,7.5,3.6,2.9,0,0.5,....)
Am I missing something or should I try other packages??