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) ;
我有一个 netCDF 文件,我想在该文件上减小其中一个维度的大小mid1
并替换值:
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)
但这并没有给我输出文件中的任何数据。