How to edit a specific variable inside a Netcdf file?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi guys; I have a netcdf file (.nc) and I would like to do some editing on this file by using matlab. I first use the following command to read the file:
ncid=netcdf.open('GROM-hind-crv-bot-10-05-19-00-thru-10-05-21-00.nc','NC_WRITE');
Then, by using the netcdf.inq(ncid) command:
[numdims numvars numatts unlimdimID] = netcdf.inq(ncid)
I get:
numdims =
3
numvars =
7
numatts =
7
unlimdimID =
2
As shown, there are 7 variables in the section of variables. I want to delete one of the variables. In other words, I want to change number of variables from 7 to 6 by deleting one of them. Could you please help me about that. I am pretty new to netcdf package in Matlab and I do appreciate if everyone could help me about that. Thanks Reza
0 comentarios
Respuestas (1)
Ashish Uthama
el 1 de Abr. de 2011
NetCDF does not let you delete a variable from a file.
Your best bet is to create a new file from the existing one, copying over all BUT the one you want to delete.
2 comentarios
Ashish Uthama
el 12 de Abr. de 2011
The 2011a feature |ncwriteschema|: http://www.mathworks.com/help/techdoc/ref/ncwriteschema.html will be useful if you choose to go this route.
Kelly Kearney
el 12 de Abr. de 2011
Though if you're going to go the new file method (which I agree is the easiest way to delete a variable, though a bit of a pain if you're working with large files), it's probably easier to use NCO (<http://nco.sourceforge.net/>) than Matlab:
ncks -x -v varToBeDeleted oldfile.nc newfile.nc
Ver también
Categorías
Más información sobre NetCDF en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!