-
Notifications
You must be signed in to change notification settings - Fork 1
/
radialFolderBuilder_v22.m
69 lines (52 loc) · 2.01 KB
/
radialFolderBuilder_v22.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
%% radialFolderBuilder_v22.m
% This function builds the folder structure for storing the converted nc files
% for radial data and the full filename of the converted nc radial file,
% according to the structure YYYY/YYYY_MM/YYYY_MM_DD/.
% INPUT:
% mainPath: root path for total nc folder.
% siteCode: code of the radial site.
% ts: timestamp of the total file.
% OUTPUT:
% rFB_err: error flag (0 = correct, 1 = error)
% fullPath: full path of the folder where to store the converted nc
% radial file.
% Author: Lorenzo Corgnati
% Date: September 28, 2020
% E-mail: lorenzo.corgnati@sp.ismar.cnr.it
%%
function [rFB_err,fullPath] = radialFolderBuilder_v22(mainPath,siteCode,ts)
disp(['[' datestr(now) '] - - ' 'radialFolderBuilder_v22.m started.']);
rFB_err = 0;
fullPath = '';
warning('off', 'all');
% Retrieve the time-related elements of the path
try
[yMDF_err,yearFolder,monthFolder,dayFolder] = yearMonthDayFolder(ts);
catch err
disp(['[' datestr(now) '] - - ERROR in ' mfilename ' -> ' err.message]);
rFB_err = 1;
return
end
% Create the folder structure
% Version v2.2
try
if (exist([mainPath filesep 'v2.2' filesep siteCode filesep yearFolder], 'dir') ~= 7)
mkdir([mainPath filesep 'v2.2' filesep siteCode filesep yearFolder]);
end
if (exist([mainPath filesep 'v2.2' filesep siteCode filesep monthFolder], 'dir') ~= 7)
mkdir([mainPath filesep 'v2.2' filesep siteCode filesep monthFolder]);
end
if (exist([mainPath filesep 'v2.2' filesep siteCode filesep dayFolder], 'dir') ~= 7)
mkdir([mainPath filesep 'v2.2' filesep siteCode filesep dayFolder]);
end
catch err
disp(['[' datestr(now) '] - - ERROR in ' mfilename ' -> ' err.message]);
rFB_err = 1;
return
end
% Build the full filename for the nc total file
fullPath = [mainPath filesep 'v2.2' filesep siteCode filesep dayFolder];
if(rFB_err==0)
disp(['[' datestr(now) '] - - ' 'radialFolderBuilder_v22.m successfully executed.']);
end
return