-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathget_nodc_buoy.m
64 lines (61 loc) · 1.23 KB
/
get_nodc_buoy.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
function perr = get_nodc_buoy(year,mon,stat,pdir)
p = inputParser;
p.addRequired('year');
p.addRequired('mon');
p.addOptional('stat','00000');
%
% get NODC netCDF4 file from ftp server
% created 07/12 TJ. Hesser
cd(pdir);
months = ['jan';'feb';'mar';'apr';'may';'jun';'jul';'aug';'sep';'oct'; ...
'nov';'dec'];
dir1 = num2str(year);
if ~exist(dir1,'dir')
mkdir(dir1);
end
cd(dir1);
dir2 = months(mon,:);
if ~exist(dir2,'dir')
mkdir(dir2);
end
cd(dir2);
if ~strcmp(stat,'00000')
filefull = dir(['*',stat,'*.nc']);
else
filefull = dir('*.nc');
end
if ~isempty(filefull)
perr = 0;
return
else
perr = 1;
end
f = ftp('ftp.nodc.noaa.gov');
cd(f,'pub/data.nodc/ndbc/cmanwx');
if mon < 10
monc = ['0',num2str(mon)];
else
monc = num2str(mon);
end
timec = [num2str(year),'/',monc];
try
cd(f,timec);
catch
copyfile(['Z:NDBC/',num2str(year),'/',months(mon,:),'/n',stat,'_',...
num2str(year),'_',monc,'.spe*'],'.');
return
end
if strcmp(stat,'00000')
mget(f,'*.nc');
else
mget(f,['*',stat,'*.nc']);
end
if ~exist('ADCP','dir')
mkdir('ADCP')
end
adcpfile = dir('*_adcp*');
if ~isempty(adcpfile)
movefile('*_adcp*','ADCP');
end
close(f);
end