How to write the Netcdf file including latitude, longitude and time.
31 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am not a native English speaker so ignore the language mistakes.
I have 2 variables along with lat, long and time, trying to write in a single nc file. The properties of data is lat 42*1 lon 42*1 time 1392*1 (year and month. i.d YYYYMM format) var1 75*42*1392 var 75*42*1392
I have tried as below ncid = netcdf.create('test.nc','CLASSIC_MODEL'); dim_lon = netcdf.defDim(ncid,'lon',75); dim_lat = netcdf.defDim(ncid,'lat',42); dim_time= netcdf.defDim(ncid,'time',1392); dim_var1= netcdf.defDim(ncid,'var1',75*42*1392); dim_var2= netcdf.defDim(ncid,'var2',75*42*1392);
var_lon = netcdf.defVar(ncid,'lon','single',dim_lon); var_lat = netcdf.defVar(ncid,'lat','single',dim_lat); var_ti = netcdf.defVar(ncid,'time','single',dim_time); var_var1 = netcdf.defVar(ncid,'var1','double',dim_var1); var_var2 = netcdf.defVar(ncid,'var2','double',dim_var2);
netcdf.putAtt(ncid,var_lon,'standard_name','longitude'); netcdf.putAtt(ncid,var_lon,'long_name','longitude'); netcdf.putAtt(ncid,var_lon,'units','degrees_east'); netcdf.putAtt(ncid,var_lon,'axis','X');
netcdf.putAtt(ncid,var_lat,'standard_name','latitude'); netcdf.putAtt(ncid,var_lat,'long_name','latitude'); netcdf.putAtt(ncid,var_lat,'units','degrees_north'); netcdf.putAtt(ncid,var_lat,'axis','Y');
netcdf.putAtt(ncid,var_var1,'standard_name','var1'); netcdf.putAtt(ncid,var_var1,'long_name','m_var1');
netcdf.putAtt(ncid,var_var2,'standard_name','var2'); netcdf.putAtt(ncid,var_var2,'long_name','x_var2');
netcdf.putAtt(ncid,var_ti,'standard_name','month'); netcdf.putAtt(ncid,var_ti,'units','month since 1901-01');
netcdf.putAtt(ncid,var_1392,'table','1392'); netcdf.putAtt(ncid,var_1392,'table','1392');
In the result of these line, I am getting the errors as Error using netcdflib The NetCDF library encountered an error during execution of 'create' function - 'No such file or directory (2)'.
Error in netcdf.create (line 53) ncid = netcdflib('create', filename, mode);
0 comentarios
Respuestas (1)
KSSV
el 15 de Mzo. de 2018
MATLAB has very simple netcdf interface......you need to know read about nccreate, ncwrite and ncwriteatt. Just with these three functions, you can create your netcdf file.
You may refer this link for code:
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!