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

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개)

KSSV
KSSV 2017년 3월 6일
편집: KSSV 2017년 3월 6일

0 개 추천

There are other easy commands like ncdisp, ncinfo, ncread. I advise you to use these easy functions to read nc files.

댓글 수: 5

Thank you for the suggestion. Actually, with ncread I should be able to access the variable 'Precipitation_rate', but I get the same error:
>> ncread(url,'Precipitation_rate',[1,1,1],[1,2,3])
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
'getVarsFloat' function - 'Access failure (-77)'.
Error in netcdf.getVar (line 136)
data = netcdflib(funcstr,ncid,varid,varargin{:});
Error in internal.matlab.imagesci.nc/read (line 635)
data = netcdf.getVar(gid, varid, ...
Error in ncread (line 58)
vardata = ncObj.read(varName, varargin{:});
KSSV
KSSV 2017년 3월 6일
You are accessing the file via link or it is present in your folder?
Damiano Pasetto
Damiano Pasetto 2017년 3월 6일
via link. The other netcdf commands (as ncdisp, ncinfo) are working well. Should I download the whole file? How?
KSSV
KSSV 2017년 3월 7일
When ncdisp and ncinfo working, you shall get this too. Check are you calling the variable in right manner.
BN
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
Matt 2017년 3월 21일

0 개 추천

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
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
Damiano Pasetto 2017년 3월 22일
So, it is a common problem! I was told to try to download the data from different sites, but I still have to try. Hope to solve this soon.
Matt
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
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
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
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.

태그

질문:

2017년 3월 6일

댓글:

BN
2022년 11월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by