Error using websave (line 98)

조회 수: 19 (최근 30일)
Augusto Gabriel da Costa Pereira
편집: Voss 2023년 8월 10일
The purpose of this code is to download the .nc4 data files.
I'm using the following code on my Linux Mint, and I'm encountering this error:
Error using websave (line 98)
Execution of script HTTPConnector as a function is not supported:
/usr/local/MATLAB/R2021a/toolbox/matlab/external/interfaces/webservices/restful/+matlab/+internal/+webservices/HTTPConnector.m
My code:
% Anos e meses correspondentes aos links
years = ['1990', '1990', '1990'];
months = ['01', '02', '03'];
% Loop para baixar os dados
for i = 1:length(years)
year = years(i);
month = months(i);
url = sprintf(['https://goldsmr4.gesdisc.eosdis.nasa.gov/opendap/MERRA2_DIURNAL/M2IUNXASM.5.12.4/',...
year, '/MERRA2_100.instU_2d_asm_Nx.', year, month, '.nc4.nc4?',...
'QV10M[0:23][141:206][148:246],time,lat[141:206],lon[148:246]']);
filename = ['MERRA2_', year, month, '.nc4.nc4'];
disp(['Baixando dados de ', year, '-', month]);
websave(filename, url);
disp(['Dados de ', year, '-', month, ' baixados e salvos como ', filename]);
end
  댓글 수: 4
Augusto Gabriel da Costa Pereira
Now remove the comments from the following lines and check if the data is being downloaded properly with your new suggestion.
url = sprintf(['https://goldsmr4.gesdisc.eosdis.nasa.gov/opendap/MERRA2_DIURNAL/M2IUNXASM.5.12.4/',...
year, '/MERRA2_100.instU_2d_asm_Nx.', year, month, '.nc4.nc4?',...
'QV10M[0:23][141:206][148:246],time,lat[141:206],lon[148:246]']);
and
websave(filename, url);
Voss
Voss 2023년 8월 10일
편집: Voss 2023년 8월 10일
"check if the data is being downloaded properly with your new suggestion."
As I stated clearly: "The following comment doesn't address the error with websave/HTTPConnector".
It's a question of whether you want to try to access
year = '1990'; % my suggestion
month = '01';
url = sprintf(['https://goldsmr4.gesdisc.eosdis.nasa.gov/opendap/MERRA2_DIURNAL/M2IUNXASM.5.12.4/',...
year, '/MERRA2_100.instU_2d_asm_Nx.', year, month, '.nc4.nc4?',...
'QV10M[0:23][141:206][148:246],time,lat[141:206],lon[148:246]'])
url = 'https://goldsmr4.gesdisc.eosdis.nasa.gov/opendap/MERRA2_DIURNAL/M2IUNXASM.5.12.4/1990/MERRA2_100.instU_2d_asm_Nx.199001.nc4.nc4?QV10M[0:23][141:206][148:246],time,lat[141:206],lon[148:246]'
or
year = '1'; % your way
month = '0';
url = sprintf(['https://goldsmr4.gesdisc.eosdis.nasa.gov/opendap/MERRA2_DIURNAL/M2IUNXASM.5.12.4/',...
year, '/MERRA2_100.instU_2d_asm_Nx.', year, month, '.nc4.nc4?',...
'QV10M[0:23][141:206][148:246],time,lat[141:206],lon[148:246]'])
url = 'https://goldsmr4.gesdisc.eosdis.nasa.gov/opendap/MERRA2_DIURNAL/M2IUNXASM.5.12.4/1/MERRA2_100.instU_2d_asm_Nx.10.nc4.nc4?QV10M[0:23][141:206][148:246],time,lat[141:206],lon[148:246]'
etc.

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2023년 8월 10일
/usr/local/MATLAB/R2021a/toolbox/matlab/external/interfaces/webservices/restful/+matlab/+internal/+webservices/HTTPConnector.m should not be a script. It should start with
%matlab.internal.webservices.HTTPConnector HTTP connector handle object
and the first non-comment line should be
classdef HTTPConnector < handle
If you are lucky, you have simply accidentally editted it like inserting a couple of characters right before the initial % that you can just remove. But otherwise you will need to restore the file from backup or reinstall MATLAB.
  댓글 수: 2
Augusto Gabriel da Costa Pereira
I believe you got completely confused in your response. Take a close look at what you wrote, your answer doesn't make much sense in relation to my question.
Walter Roberson
Walter Roberson 2023년 8월 10일
You posted
Error using websave (line 98)
Execution of script HTTPConnector as a function is not supported:
/usr/local/MATLAB/R2021a/toolbox/matlab/external/interfaces/webservices/restful/+matlab/+internal/+webservices/HTTPConnector.m
That tells us that your call to websave() is internally calling matlab.internal.webservices.HTTPConnector as-if it were a function (more exactly, expecting it to be a constructor), but that the implementing file /usr/local/MATLAB/R2021a/toolbox/matlab/external/interfaces/webservices/restful/+matlab/+internal/+webservices/HTTPConnector.m is instead a script. That is, that the implementing file has something potentially executable before the first "function" or "classdef" statement.
I examined the executable file, which happens to be at location /Applications/MATLAB_R2021a.app/toolbox/matlab/external/interfaces/webservices/restful/+matlab/+internal/+webservices/HTTPConnector.m on my system. The first line of the file is the comment I indicated, and that is followed by comments and empty lines until it reaches the "classdef" line that I indicated.
We can tell from the error message that the error is not in your lines of code, and is not in websave(): that instead your /usr/local/MATLAB/R2021a/toolbox/matlab/external/interfaces/webservices/restful/+matlab/+internal/+webservices/HTTPConnector.m is corrupted relative to what it should be.
If you are lucky then your /usr/local/MATLAB/R2021a/toolbox/matlab/external/interfaces/webservices/restful/+matlab/+internal/+webservices/HTTPConnector.m file has a few extra characters at the beginning that you can edit out. If you are not so lucky then you will need to restore that file from backups or reinstall MATLAB.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by