-
Notifications
You must be signed in to change notification settings - Fork 12
/
findTfFile.m
141 lines (112 loc) · 3.34 KB
/
findTfFile.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
function PathFileList = findTfFile(indir,stationDeploy)
% findTfFile.m
% Simple script finds transfer function file based on given TPWS file name.
% If site or deployment do not much the specified cases, user will be
% propmpt to select the transfer function file (.tf)
if (size(stationDeploy,1) > 1 || size(stationDeploy,2) > 1) && iscell(stationDeploy)
stationDeploy = stationDeploy{2}; % skip site name if given
end
if iscell(stationDeploy)
stationDeploy = stationDeploy{:};
end
% select which tf corresponds to station/deployment
autoSel = true; % by default select file automatically based on case
switch stationDeploy
% site DT
case {'DT01','DT02','DT03'}
tfnum = 589;
serie = '500_series';
case {'DT04','DT05','DT06','DT07','DT08'}
tfnum = 638;
serie = '600_series';
case 'DT09'
tfnum = 715;
serie = '700_series';
case 'DT10'
tfnum = 822;
serie = '800_series';
% site MC
case {'MC01','MC02','MC03','MC04','MC05'}
tfnum = 585;
serie = '500_series';
case 'MC06'
tfnum = 651;
serie = '600_series';
case 'MC07'
tfnum = 693;
serie = '600_series';
case 'MC09'
tfnum = 729;
serie = '700_series';
case 'MC10'
tfnum = 718;
serie = '700_series';
case 'MC11'
tfnum = 618;
serie = '600_series';
case 'MC12'
tfnum = 821;
serie = '800_series';
% site GC
case {'GC01','GC02','GC03','GC04'}
tfnum = 601;
serie = '600_series';
case 'GC05'
tfnum = 656;
serie = '600_series';
case {'GC06','GC07'}
tfnum = 694;
serie = '600_series';
case 'GC08'
tfnum = 719;
serie = '700_series';
case 'GC09'
tfnum = 718;
serie = '700_series';
case 'GC10'
tfnum = 809;
serie = '800_series';
% 'Antarc01EIE'
case {'Antarc01EIE'}
tfnum = 729;
serie = '700_series';
% site SOCAL
case{'SOCAL34M'}
tfnum = 452;
serie = '400_series';
case{'SOCAL35S'}
tfnum = 492;
serie = '400_series';
case{'SOCAL61E'}
tfnum = 830;
serie = '800_series';
case{'SOCAL61N'}
tfnum = 857;
serie = '800_series';
case{'SOCAL61H'}
tfnum = 844;
serie = '800_series';
otherwise
% select manually
autoSel = false;
disp(['Transfer function not specified for automatic selection. ',...
'Add path in findTfFile for automatic selection ']);
[fname,pname] = uigetfile(fullfile(indir,'*.tf'),'Select Transfer Function File (.tf)');
end
if autoSel
pathSeries = fullfile(indir,serie);
folders = dir(pathSeries);
folders = ({folders.name})' ;
folders = folders(3:end);
foldNums = cell2mat(strtok(folders,'_')); % get part of number
tfnumFold = find(str2num(foldNums) == tfnum,1,'last');
pathTfFile = fullfile(pathSeries,folders{tfnumFold});
SearchFileMask = {'*.tf'};
SearchPathMask = {pathTfFile};
SearchRecursiv = 1;
[PathFileList, ~, ~] = ...
utFindFiles(SearchFileMask, SearchPathMask, SearchRecursiv);
PathFileList = cell2mat(PathFileList);
else
PathFileList = fullfile(pname,fname);
end