error whilw downloading Copernicus Marine data via MOTU in MATLAB
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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?
0 comentarios
Respuestas (1)
Walter Roberson
el 11 de Nov. de 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
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 comentarios
Walter Roberson
el 16 de Nov. de 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;
Ver también
Categorías
Más información sobre Downloads en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!