How to edit a specific variable inside a Netcdf file?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Ashish Uthama
le 1 Avr 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 commentaires
Ashish Uthama
le 12 Avr 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
le 12 Avr 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
Voir également
Catégories
En savoir plus sur NetCDF dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!