Data not written correctly to netcdf file
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
I am trying to create a netcdf file with variables 'latitude', 'longitude' and 'zeros' to create a map of the world. I want to create a 0.5 degree grid so my latitude and longitude vectors have lengths of 360 and 720, respectively. My code (below) runs fine but when it creates the variable 'zeros' it does not write any data (i.e. has a cell value of 9.9692100e+36) for rows 714 (columns 246-360) and 715-720 (all columns). This produces a stripe going across my map when I visualise the data. Do you have any idea why this might be happening?
ncid = netcdf.create('Annual.nc','NC_NOCLOBBER');
%Define dimensions
londimid = netcdf.defDim(ncid,'lon', 720);
latdimid = netcdf.defDim(ncid,'lat', 360);
%Define variables
latvarid=netcdf.defVar(ncid, 'lat', 'float', latdimid);
lonvarid=netcdf.defVar(ncid, 'lon', 'float', londimid);
zerosvarid=netcdf.defVar(ncid, 'zeros', 'float', [latdimid londimid]);
netcdf.endDef(ncid)
%Write data to variables
netcdf.putVar(ncid,lonvarid,longitude);
netcdf.putVar(ncid,latvarid,latitude);
netcdf.putVar(ncid, zerosvarid, zeros(360,720));
0 comentarios
Respuesta aceptada
Ashish Uthama
el 7 de Oct. de 2011
Anna, the data might not get fully written unless you close the file. A call to close would flush out all the data to the file:
netcdf.close(ncid);
Of course, you would then have to use netcdf.open to open the file again for reading.
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!