How do I write a netcdf file that ncdump and cdo/GrADS will understand?
9 次查看(过去 30 天)
显示 更早的评论
I am experimenting with writing netcdf files using nccreate and ncwrite. everything appears to work fine and I can read the resulting netcdf file back into Matlab no problem. But when I try using unix/DOS utilities like ncdump, I'm told "Not a netCDF file". I am trying to import the data into GrADS using cdo (Climate data operators) but strike essentially the same problem. Is there something I'm missing?
My data are sea ice concentrations on a 161x161 grid over the southern oceans and Antarctica. I created the data set using
nccreate('ice_monthly_ps161x161_3d.nc','x','dimensions',{'x',nx},'format','netcdf4')
ncwrite('ice_monthly_ps161x161_3d.nc','x',x)
nccreate('ice_monthly_ps161x161_3d.nc','y','dimensions',{'y',ny})
ncwrite('ice_monthly_ps161x161_3d.nc','y',y)
nccreate('ice_monthly_ps161x161_3d.nc','lat','dimensions',{'x','y'})
ncwrite('ice_monthly_ps161x161_3d.nc','lat',lat)
nccreate('ice_monthly_ps161x161_3d.nc','lon','dimensions',{'x','y'})
ncwrite('ice_monthly_ps161x161_3d.nc','lon',lon)
nccreate('ice_monthly_ps161x161_3d.nc','time','dimensions',{'time',ice.nt})
ncwrite('ice_monthly_ps161x161_3d.nc','time',timenum)
nccreate('ice_monthly_ps161x161_3d.nc','projection','dimensions',{'projection',length(ice.specs)})
ncwrite('ice_monthly_ps161x161_3d.nc','projection',ice.specs)
nccreate('ice_monthly_ps161x161_3d.nc','ice_concentration','dimensions',{'x','y','time'})
ncwrite('ice_monthly_ps161x161_3d.nc','ice_concentration',icef)
where 'icef' is a 3d array of the sea ice data. I can look at the netCDF file with ncinfo and can read it OK with the ncread routine or with the nctoolbox library. But when I use ncdump from the DOS command line I am told this is not a netCDF file.
Am I missing something simple here? Any suggestions appreciated.
[Edit: Formatted code. -AU]
1 个评论
Geoff Hayes
2014-9-5
James - what happens if you use change the format from netcdf4 to netcdf4_classic?
采纳的回答
Ashish Uthama
2014-9-5
编辑:Ashish Uthama
2014-9-5
James - my guess is that the other utilities you are using are based on an older version of the NetCDF library - they do not recognize netcdf4 files. netcdf4 is not backwards compatible, hence @Geoff's suggestion to try a different format. Though, I would recommend also trying 'classic'.
更多回答(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!