Error using netcdflib, error in netcdf.open

131 次查看(过去 30 天)
My code to open and download files from a OPeNDAP URL is no longer working. It was working great, then all of a sudden I get errors. I am using Matlab R2020a. Thanks for the help. Barbara
*******
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 67)
[varargout{:}] = netcdflib ( 'open', filename, varargin{1} );
Error in internal.matlab.imagesci.nc/openToRead (line 1278)
this.ncRootid = netcdf.open(this.Filename,'NOWRITE');
Error in internal.matlab.imagesci.nc (line 121)
this.openToRead();
Error in ncread (line 61)
ncObj = internal.matlab.imagesci.nc(ncFile);
********
Code:
myVar = 'tmin';
myURL = ['http://thredds.northwestknowledge.net:8080/thredds/dodsC/agg_terraclimate_',myVar,'_1958_CurrentYear_GLOBE.nc'];
latList=[41 44 45 41]; %list of north latitudes for each point location
lonList=[-110 -100 -101 -95]; %list of East longitudes for each point location
NUM_POINTS = length(latList');
year_start = 1980;
month_start=1;
year_end = 2019;
month_end=12;
%===================================================
timebounds_start =datenum(year_start,month_start,1)-datenum(1900,1,1);
timebounds_end = datenum(year_end,month_end,1)-datenum(1900,1,1);
timebounds = [timebounds_start timebounds_end];
lat=ncread(myURL,'lat');
lon=ncread(myURL,'lon');
time=ncread(myURL,'time');
[Y,M,D]=datevec(time+datenum(1900,1,1));
ftimei=find(time>=timebounds(1) & time<=timebounds(2));
time = time(ftimei);
NUM_TIME= length(time);
myData = NaN(NUM_POINTS,NUM_TIME);
myLat = NaN(NUM_POINTS,1);
myLon = NaN(NUM_POINTS,1);
for i= 1:NUM_POINTS;
[dist,flati]=min(abs(lat-latList(i)));
[dist,floni]=min(abs(lon-lonList(i)));
myLat(i)=lat(flati);
myLon(i)=lon(floni);
myData(i,:)=ncread(myURL,myVar,[floni(1) flati(1) ftimei(1)],[length(floni) length(flati) length(ftimei)],[1 1 1]);
end;
  2 个评论
Kenny Larsen
Kenny Larsen 2023-4-20
Did you ever find an adequate solution to this problem? I am having a similar problem and can'r for the life of me figure it out!
麟轩 马
麟轩 马 2023-10-5
I am having the same problem with the same database. Is there a solution yet please?

请先登录,再进行评论。

回答(1 个)

Prabhan Purwar
Prabhan Purwar 2021-5-11
Hi Barbara,
This is a known issue with the NetCDF library in R2020a and is now fixed in R2020b and further releases.
The easiest workaround is to upgrade to R2020b or R2021a.
Please let me know if you are still having any concerns.
Thanks
  2 个评论
金龙 张
金龙 张 2021-5-13
I met the same problem with the moderator.
This error is still exist when I use R2021a. And the error will happen only when I want to read the data of uo.
size uo is : uo(lon,lat,lev,time)
I hope I won't disturb you.
--------------------
my code:
lon=ncread(filename,'longitude');
lat=ncread(filename,'latitude');
lev=ncread(filename,'lev');
uo=ncread(filename,'uo');
---------------------
error code:
错误使用 matlab.internal.imagesci.netcdflib
NetCDF 库在执行 'getVarFloat' 函数期间遇到错误 - 'HDF error (NC_EHDFERR)'。
出错 netcdf.getVar (第 182 行)
data = matlab.internal.imagesci.netcdflib(funcstr,ncid,varid,varargin{:});
出错 internal.matlab.imagesci.nc/read (第 607 行)
data = netcdf.getVar(gid, varid);
出错 ncread (第 66 行)
vardata = ncObj.read(varName, varargin{:});

请先登录,再进行评论。

产品

Community Treasure Hunt

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

Start Hunting!

Translated by