-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDownload_HYCOMfromOPENDAP_GLBv008_expt930.m
73 lines (70 loc) · 2.89 KB
/
Download_HYCOMfromOPENDAP_GLBv008_expt930.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
clear,clc
latlim = [10 50];
lonlim = [110 270];
this_folder = pwd;
%% 2018/01/01 00:00:00 ~ 2020/02/18 21:00:00
firstdate = datenum('2000010100','yyyymmddHH');
fn_i = ['https://tds.hycom.org/thredds/dodsC/GLBv0.08/expt_93.0/uv3z?lat[0:1:3250],lon[0:1:4499],time[0:1:0]'];
first_date_download = datetime('2018/01/01 12:00:00','InputFormat','yyyy/MM/dd HH:mm:ss');
end_date_download = datetime('2020/02/18 21:00:00','InputFormat','yyyy/MM/dd HH:mm:ss');
%%
loop_count = 0;
while loop_count == 0
try
lon_i = ncread(fn_i,'lon');
lat_i = ncread(fn_i,'lat');
time_i = ncread(fn_i,'time');
loop_count = loop_count+1;
catch %如果error,等待60秒並再執行一次
disp('error')
loop_count = loop_count - 1;
pause(60)
end
end
lonindex = find(lon_i>=lonlim(1)&lon_i<=lonlim(end))-1;
latindex = find(lat_i>=latlim(1)&lat_i<=latlim(end))-1;
%%
base_date_download = datetime(2000,01,01)+hours(time_i);
% first_index = hours(first_date_download-base_date_download)/3;
while first_index < 0
first_date_download = first_date_download + hours(3);
first_index = hours(first_date_download-base_date_download)/3;
end
% end_index = hours(end_date_download-base_date_download)/3;
end_index = 612;
%%
time_index = first_index;
t = time_index; %起始時間index
while t <= end_index
%https://tds.hycom.org/thredds/dodsC/GLBu0.08/expt_19.1/3hrly?depth[0:1:39],lat[0:1:2000],lon[0:1:4499],time[0:1:50519],water_u[0:1:0][0:1:0][0:1:0][0:1:0],water_v[0:1:0][0:1:0][0:1:0][0:1:0]
fn = ['https://tds.hycom.org/thredds/dodsC/GLBv0.08/expt_93.0/uv3z?lat[' ...
num2str(latindex(1)) ':1:' num2str(latindex(end)) ...
'],lon[' num2str(lonindex(1)) ':1:' num2str(lonindex(end)) ...
'],time[' num2str(t) '],water_u[' num2str(t) ...
'][0:1:0][' num2str(latindex(1)) ':1:' num2str(latindex(end)) ...
'][' num2str(lonindex(1)) ':1:' num2str(lonindex(end)) ...
'],water_v[' num2str(t) '][0:1:0][' num2str(latindex(1)) ':1:' ...
num2str(latindex(end)) '][' num2str(lonindex(1)) ':1:' ...
num2str(lonindex(end)) ']'];
% depth = ncread(fn,'depth');
try
lat = ncread(fn,'lat');
lon = ncread(fn,'lon');
u = ncread(fn,'water_u');
v = ncread(fn,'water_v');
time = ncread(fn,'time');
date = datestr([firstdate + time/24],'yyyymmddHH')
% save(['F:\1_Tec_all\DATA\HYCOM\HYCOM_GLBy_surface_uv\' date],'lat','lon','u','v')
saving_folder = 'E:/Data/HYCOM/HYCOM_GLBv_surface_uv/expt_930';
mkdir(saving_folder)
save([saving_folder '/' date],'lat','lon','u','v')
% clear depth lat lon u v time date
catch %如果error,等待60秒並再執行一次
disp('error')
t = t - 1;
pause(60)
end
clear depth lat lon u v time date
t = t + 1;
end
cd(this_folder)