How to edit a specific variable inside a Netcdf file?
조회 수: 5 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Ashish Uthama
2011년 4월 1일
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
Ashish Uthama
2011년 4월 12일
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
2011년 4월 12일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 NetCDF에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!