Error reading netcdf files online
3 次查看(过去 30 天)
显示 更早的评论
Hi, everyone
when I read netcdf files online in matlab R2015a, I always encountered problems as follows:
*Error using netcdflib
The NetCDF library encountered an error during execution of 'open' function - 'Malformed or inaccessible DAP DDS
(NC_EDDS)'. If the data source was an OPeNDAP URL, see the OPeNDAP Troubleshooting section in the Users Guide.
Error in netcdf.open (line 59)
[varargout{:}] = netcdflib ( 'open', filename, varargin{1} );*
The code for reading nc file is as follows:
url=['http://www.cmar.csiro.au/dods/nph-dods/dods-data/bl/BRAN2.2/temp/ocean_temp_' Nyear '_01_01.nc'];
ncid=netcdf.open(ur1,'NC_NOWRITE');
Lat0=netcdf.getVar(ncid,'yt_ocean'); Lon0=netcdf.getVar(ncid,'xt_ocean');
Could anyone please tell me how to deal with the above problem?
Many thanks and kind regards,
Fanglou_
1 个评论
Geoff Hayes
2016-2-13
编辑:Geoff Hayes
2016-2-13
Fanglou - have you verified that the URL is correct? Note that in your above code, you assign the URL to the variable url, but then try to open ur1 where the last character is a one and not an 'l'.
回答(1 个)
Bankim Chandra Yadav
2018-4-26
编辑:Bankim Chandra Yadav
2018-4-26
I have faced same situation: The most probable reason is while you are getting a list of .nc files using loop you are getting them as 'cell' type. When you try the read the file name at a particular cell value you can do that using
fileName = filesList(i)
where i = 1 to the numeber of files returned in your output.
The solution is: while using 'ncread' function use it as follows:
ncread(fileName{:},'variableName')
This will solve your problem. It solved mine. I was going through the exact problem of being able to use ncread in a single directory but not over a list of files obtained through loop.
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!