Start+count exceeds dimension bound (NC_EEDGE)

49 ビュー (過去 30 日間)
Steven
Steven 2016 年 1 月 28 日
コメント済み: Steven 2016 年 1 月 28 日
I'm trying to load netcdf data, crop it, and then save it to a new netcdf file. For some reason I'm getting the following error and it's driving me crazy.
Error using netcdflib
The NetCDF library encountered an error during execution of 'putVaraDouble' function - 'Start+count exceeds dimension bound
(NC_EEDGE)'.
Error in netcdf.putVar (line 84)
netcdflib(funcstr,ncid,varid,varargin{:});
Error in internal.matlab.imagesci.nc/write (line 831)
netcdf.putVar(gid, varid,start, count, varData);
Error in ncwrite (line 75)
ncObj.write(varName, varData, start, stride);
Error in Make_initial_rst_file_no_single (line 289)
ncwrite(nfile,'h',ncread(tfile,'h'));
------------------------------
The script that it is choking on is as follows...
h=ncread(tfile,'h');
h=h(istart:iend,jstart:jend);
nccreate(nfile,'h','Datatype','double','Dimensions',{'xi_rho',size(h,1),'eta_rho',size(h,2)});
ncwrite(nfile,'h',ncread(tfile,'h'));
All I am doing is loading in "h" from an existing netcdf file, cropping it with the i and j start and end values, and trying to save it to a new netcdf file.
I have double checked the dimensions and they are correct. 32 x 37 is the dimension of the new "h" array after cropping.

採用された回答

Ashish Uthama
Ashish Uthama 2016 年 1 月 28 日
編集済み: Ashish Uthama 2016 年 1 月 28 日
The ncread call in you ncwrite call returns the full variable, did you mean to use the variable h instead of the function call?
  1 件のコメント
Steven
Steven 2016 年 1 月 28 日
Doh! Well that was silly. Found my mistake. Thank you for your help.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNetCDF についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by