error using netcdf.getVar
显示 更早的评论
Hi all, I am trying to access the following file using netcdf in matlab:
url='http://nomads.ncdc.noaa.gov/thredds/dodsC/modeldata/cfsv2_forecast_ts_9mon/2016/201609/20160901/2016090100/prate.01.2016090100.daily.grb2’
and the with the codes
ncid=netcdf.open(url)
prate = netcdf.getVar(ncid, 5, [0,0,0],[1,2,3])
However I receive the following error message
syntax error, unexpected WORD_STRING, expecting WORD_WORD
context: Error { code = 2; message = "The variable `Precipitation%5frate' was not found in the dataset."^;};
Error using netcdflib
The NetCDF library encountered an error during execution of
'getVaraFloat' function - 'Access failure (-77)'.
Error in netcdf.getVar (line 136)
data = netcdflib(funcstr,ncid,varid,varargin{:});
The same code was working without errors the last December, and now I have no idea on how to access the file from matlab. Any idea on how I should proceed?
Thank you,
Damiano
1 个评论
mv2195
2017-5-2
I am having what seems to be a similar issue. The URL is http (not https) and the file has four variables: Latitude, Longitude, Time, and Precipitation. I can successfully ncread the Lat, Lon and Time variables, but neither ncread nor netcdf.getVar are successful for the Precipitation variable. Following are the error messages.
For netcdf.getVar:
Error using netcdflib
The NetCDF library encountered an error during execution of
'getVarFloat' function - 'Access failure (-77)'.
Error in netcdf.getVar (line 136)
data = netcdflib(funcstr,ncid,varid,varargin{:});
With the addition of the following for ncread:
Error in internal.matlab.imagesci.nc/read (line 605)
data = netcdf.getVar(gid, varid);
Error in ncread (line 58)
vardata = ncObj.read(varName, varargin{:});
The only difference I see among the variables based on the info from ncdisp is that Lat, Lon,and Time have one dimension each, while Precipitation has three (Lat,Lon,Time).
Is there something simple I'm missing or is this a more complicated issue?
回答(4 个)
There are other easy commands like ncdisp, ncinfo, ncread. I advise you to use these easy functions to read nc files.
5 个评论
Damiano Pasetto
2017-3-6
KSSV
2017-3-6
You are accessing the file via link or it is present in your folder?
Damiano Pasetto
2017-3-6
KSSV
2017-3-7
When ncdisp and ncinfo working, you shall get this too. Check are you calling the variable in right manner.
BN
2022-11-9
I have a same issue,
Error using matlab.internal.imagesci.netcdflib
The NetCDF library encountered an error during execution of
'getVarsDouble' function - 'Access failure (-77)'.
Error in netcdf.getVar (line 182)
data =
matlab.internal.imagesci.netcdflib(funcstr,ncid,varid,varargin{:});
Error in internal.matlab.imagesci.nc/read (line 637)
data = netcdf.getVar(gid, varid, ...
Error in ncread (line 66)
vardata = ncObj.read(varName, varargin{:});
I hope one of you could solve it and told me now. please help with this error.
Matt
2017-3-21
I'm getting the exact same error when trying to get data from a netcdf file in R2016b:
url = 'http://data.nodc.noaa.gov/thredds/dodsC/testdata/mbiddle/veg_test_his_compressed.nc';
ncid = netcdf.open(url);
varid = netcdf.inqVarID(ncid,'Hwave')
data = netcdf.getVar(ncid,varid)
varid =
142
syntax error, unexpected WORD_STRING, expecting WORD_WORD
context: Error { code = 2; message = "The variable `nl%5fvisc2' was not found in the dataset."^;};
Error using netcdflib
The NetCDF library encountered an error during execution of 'getVarFloat' function - 'Access failure (-77)'.
Error in netcdf.getVar (line 136)
data = netcdflib(funcstr,ncid,varid,varargin{:});
Error in coawst_import (line 25)
data = netcdf.getVar(ncid,varid)
All of the other netCDF tools work fine, ncdisp, ncinfo, ncread. Its only an issue when trying to get the data...
4 个评论
Matt
2017-3-22
The problem is something to do with the DODS link. I downloaded my file locally and those exact commands worked as expected. I'd be interested in learning what the 'Access failure (-77)' warning actually means. I've searched all over and can't find anything. What could the problem be? This causes a huge headache for me, because I don't want to download some large multi GB file when I want to do my processing. I would like to use the DODS url to remotely access the file. Any thoughts?
Damiano Pasetto
2017-3-22
Matt
2017-3-24
FWIW, I did see this thread https://www.mathworks.com/matlabcentral/answers/248192-problem-with-netcdf-file-downloaded-from-an-opendap-source#answer_195740 talking about https, the file I was trying to open is on https, I just changed the url to http. Maybe that is part of the problem?
Matt
2017-3-24
And one more conversation https://www.mathworks.com/matlabcentral/answers/223837-problem-to-access-opendap-data-behind-https-urls, maybe this bugfix will help https://www.mathworks.com/support/bugreports/1072120 unless you are using R2017...
fuchang wang
2020-6-30
0 个投票
version: R2018a
When ncread('A.nc', 'VAR'), it shows the same Error.
For my case, it is due to the data is not properly downloaded. Redownload it, solving the issue.
Though A.nc can be read by other tools, and new A.nc owes the same file size as the old A.nc. Maybe tiny difference exists.
lucksoftware
2020-8-6
0 个投票
I meet exactly the same problem when I am reading a variable from a link via OpenDAP. It turned out that the variable is too larege. Reading the variable part by part solves the problem in my case.
类别
在 帮助中心 和 File Exchange 中查找有关 NetCDF Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!