Reputation: 5542
dimensions:
i1 = 3 ;
x = 11 ;
s1 = 1 ;
mid1 = 8 ;
mid2 = 8 ;
variables:
double Height(i1,x) ;
double Temp(s1, x) ;
short Soil(s1, x) ;
double Liq(mid1, x) ;
I have a netCDF file on which I want to reduce the size of one of the dimensions mid1
and replace values:
icond <- ncdf4::nc_open('dat.nc)
#New dimensions for new file
idim <- icond$dim[['i1']]
xdim <- icond$dim[['x']]
s1dim <- icond$dim[['s1']]
mid1dim <- ncdim_def("mid1", "", 1:3) #3 layers
mid2dim <- icond$dim[['mid2']]
mv <- -9999
#Get variable data
Liqxdat <- ncvar_get(icond, 'Liq')[,1:3] #3 Layers
#Define new variable
Liqx = ncvar_def( "Liq", "units", list(mid1dim, i1), mv, prec="double")
#Create netCDF file
nc = nc_create("test.nc", list(Height, Temp, Soil, Liqx)
#Write data to the NetCDF file
ncvar_put(nc, Liqx, Liqxdat)
But this is not giving me any data in the output file.
Upvotes: 0
Views: 702
Reputation: 164
Unfortunately I cannot run your code. So I just can guess why it's not working.
ncvar_add()
Upvotes: 1