error whilw downloading Copernicus Marine data via MOTU in MATLAB

13 vues (au cours des 30 derniers jours)
Ameen Bassam
Ameen Bassam le 10 Nov 2023
Commenté : Ameen Bassam le 16 Nov 2023
I am trying to download Copernicus Marine data via MOTU in MATLAB as explained in
I have downloaded the provided matlab script and modify it as below
% Create the work directory 'data'
out_dir = fullfile(pwd, 'data');
if ~exist(out_dir, 'dir')
mkdir(out_dir)
end
% Copernicus Marine username and password
username = input('user', "s");
password = input('bassword', "s");
% Product and dataset IDs
serviceId = 'GLOBAL_ANALYSISFORECAST_PHY_001_024';
productId = 'cmems_mod_glo_phy-thetao_anfc_0.083deg_P1D-m';
% Ocean Variable(s)
variables = ["--variable thetao"];
% Time range
date_start = '2022-01-01 12:00:00';
date_end = '2022-01-07 12:00:00';
% Geographic area and depth level
lon = [-15.26, 5.04]; % lon_min, lon_max
lat = [35.57, 51.03]; % lat_min, lat_max
depth = ["0", "100"]; % depth_min, depth_max
% Output filename
filename = 'global_20220101_2022_01_07.nc';
motu_line = sprintf("py -m motuclient --motu https://nrt.cmems-du.eu/motu_web/Motu", ...
" --service-id ", serviceId, "-TDS --product-id ", productId, ...
"--longitude-min ", lon(1), "--longitude-max ", lon(2), ...
"--latitude-min ", lat(1), "--latitude-max ", lat(2), ...
" --date-min ",date_start," --date-max ",date_end, ...
" --depth-min ", depth(1), " --depth-max ", depth(2), ...
variables(1), ...
" --out-dir ", out_dir, " --out-name ", filename, ...
" --user ", username, " --pwd ", password);
disp(motu_line)
system(motu_line)
After many trails, I have the following error:
py -m motuclient --motu https://nrt.cmems-du.eu/motu_web/Motu
2023-11-10 22:55:24.028 [ERROR] Execution failed: [Excp 13] User (option 'user') is mandatory when 'cas' authentication is set. Please provide it.
I have Python 3.8 on Windows 10 and I have installed Pandas and motuclient on Python as well. Anyhelp please?

Réponses (1)

Walter Roberson
Walter Roberson le 11 Nov 2023
motu_line = sprintf("py -m motuclient --motu https://nrt.cmems-du.eu/motu_web/Motu", ...
" --service-id ", serviceId, "-TDS --product-id ", productId, ...
"--longitude-min ", lon(1), "--longitude-max ", lon(2), ...
"--latitude-min ", lat(1), "--latitude-max ", lat(2), ...
" --date-min ",date_start," --date-max ",date_end, ...
" --depth-min ", depth(1), " --depth-max ", depth(2), ...
variables(1), ...
" --out-dir ", out_dir, " --out-name ", filename, ...
" --user ", username, " --pwd ", password);
No format characters such as %s in the first parameter to sprintf. The sprintf() is not going to output any of the additional parameters you pass.
The format for sprintf() is sprintf(FORMAT, param1, param2, param3, ...) where the FORMAT specifies how to convert param1 and so on into output. Each % in FORMAT causes the processing of the next param* (with the exception of %$ sequences) .
When the end of FORMAT has been reached, and there were no % format characters, then sprintf() makes no effort to convert any additional parameters and just drops them.
If the end of FORMAT has been reached and there is at least 1 % sequence, and there are additional values to convert, the FORMAT gets reused from the beginning.
In all situations if a % format sequence requires a value and there are no more values to convert, conversion stops at that point. For example, sprintf('abc %g def %g hij\n', 10 ) would output abc 10 def and then would encounter the %g for which there is no corresponding input value, so it would just stop without going on to hij
You should probably be considering use the string plus, + operator to create the motu_line
motu_line = "py -m motuclient --motu https://nrt.cmems-du.eu/motu_web/Motu" ...
+ " --service-id " + serviceId + "-TDS --product-id " + productId ...
+ "--longitude-min " + lon(1) + "--longitude-max " + lon(2) ...
+ "--latitude-min " + lat(1) + "--latitude-max " + lat(2) ...
+ " --date-min " + date_start + " --date-max " + date_end ...
+ " --depth-min " + depth(1) + " --depth-max " + depth(2) ...
+ variables(1) ...
+ " --out-dir " + out_dir + " --out-name " + filename, ...
+ " --user " + username + " --pwd " + password;
but if so then you should test to see whether the conversion of lat and lon to string is acceptable for your purposes -- the automatic conversion will only hold on to at most 4 decimal places.
  13 commentaires
Walter Roberson
Walter Roberson le 16 Nov 2023
motu_line = "py -m motuclient --motu 'https://nrt.cmems-du.eu/motu_web/Motu'" ...
+ " --service-id " + serviceId + "-TDS --product-id " + productId ...
+ " --longitude-min " + lon(1) + " --longitude-max " + lon(2) ...
+ " --latitude-min " + lat(1) + " --latitude-max " + lat(2) ...
+ " --date-min '" + date_start + "' --date-max '" + date_end ...
+ "' --depth-min " + depth(1) + " --depth-max " + depth(2) ...
+ " " + variables(1) ...
+ " --out-dir '" + out_dir + "' --out-name " + filename ...
+ " --user " + username + " --pwd " + password;
Ameen Bassam
Ameen Bassam le 16 Nov 2023
Regarding the code, I received the following message from the support team of CopernicusMarineService.
The error you received means that there is an error in the code spell (lack of space between the parameters, wrong spell parameters, ...). So it is recommended to double check the command line.
Looking at your request, I see that there is no space after --depth-max 100 .
Also, maybe you need to use quote marks instead of apostrophes around the dates.
Here is the example of a correct MOTU request to compare it to yours:
python -m motuclient --motu https://nrt.cmems-du.eu/motu-web/Motu --service-id MEDSEA_ANALYSISFORECAST_PHY_006_013-TDS --product-id cmems_mod_med_phy-tem_anfc_4.2km_P1D-m --longitude-min 11.278194265352782 --longitude-max 17.322023164435105 --latitude-min 35.62677046686681 --latitude-max 39.17599884720039 --date-min "2023-09-01 00:00:00" --date-max "2023-09-08 23:59:59" --depth-min 1.0182366371154785 --depth-max 26.20039939880371 --variable thetao --out-dir <OUTPUT_DIRECTORY> --out-name <OUTPUT_FILENAME> --user <USERNAME> --pwd <PASSWORD>
I hope this help!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Downloads dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by