How to write a 3d variable to a netcdf
3 ビュー (過去 30 日間)
古いコメントを表示
I want to extract a variable from an existing NetCDF file, Shift its dimensions and write the shifted variable to a new netcdf which is a copy of existing file by rewriting existing variable. So far I am able to extract a variable from an existing NetCDF file and Shift its dimensions but getting error when trying to write it to a new netcdf file
clc
clear all
data=ncread('MISR_AM1_AS_AEROSOL_P125_O075081_F13_0023.nc','/4.4_KM_PRODUCTS/Spectral_AOD_Scaling_Coeff')
Shift= shiftdim(data,1)
copyfile(which('MISR_AM1_AS_AEROSOL_P125_O075081_F13_0023.nc'),'myfile.nc');
ncdisp('myfile.nc','/4.4_KM_PRODUCTS/Spectral_AOD_Scaling_Coeff');
ncwrite('myfile.nc','/4.4_KM_PRODUCTS/Spectral_AOD_Scaling_Coeff',Shift);
ncdisp('myfile.nc','/4.4_KM_PRODUCTS/Spectral_AOD_Scaling_Coeff');
where
MISR_AM1_AS_AEROSOL_P125_O075081_F13_0023.nc
is the existing nc file
/4.4_KM_PRODUCTS/Spectral_AOD_Scaling_Coeff
Is the subfolder and existing variable
and the error which Iam getting is
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 netcdfread (line 9)
ncwrite('myfile.nc','/4.4_KM_PRODUCTS/Spectral_AOD_Scaling_Coeff',Shift);
Any suggetion or correction will be very much helpful,
Thanks alot in advance.
7 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で NetCDF についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!