-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsplitlab.m
More file actions
executable file
·329 lines (278 loc) · 10.7 KB
/
Copy pathsplitlab.m
File metadata and controls
executable file
·329 lines (278 loc) · 10.7 KB
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
function splitlab
% Main window of the SplitLab toolbox, configure the parameters and projects
% creating the configuration figure of Splitlab
global config eq
% maybe a bad idea, but warnings may come up regarding try-catch syntax and
% round condition
warning('off','MATLAB:mir_warning_changing_try_catch');
SL_checkversion
config.version='SplitLab1.3.0';
config.azwin = [0 360];
ok = checkmattaupclass;
if ok==0; warning('Troubles loading matTaup: Go to checkmattaupclass.m and fix path to MaTTaup folder in Splitlab Folder'); end
[p,f] = fileparts(mfilename('fullpath')); % directory of Splitlab
set(0,'DefaultFigurecolor', [224 223 227]/255 ,...
'DefaultFigureWindowStyle','normal',...
'DefaultUIControlBackgroundColor', [224 223 227]/255)
cfig=findobj('type','Figure','name',['Configure ' config.version]);
if isempty(cfig)
cfig=figure('name',['Configure ' config.version],...
'Menubar','none',...
'NumberTitle','off','units','pixel');
else
clf
end
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
load icon.mat ;
p = get(0,'DefaultFigurePosition');
p(3:4)=[560 420];
set(gcf,'Position',p,'Resize','off');
pos = [130 5 425 410];
configpanelGENERAL;
configpanelSTATION;
configpanelPHASES;
configpanelSEARCHWIN;
configpanelUSER; % panel to create breqfast style requests
configpanelFETCHTRACES; % Panel to replace USER with a fetch method
configpanelFINDFILE;
set(h.panel(2:end), 'Visible','off');
%% Side panel: radio buttons
h.menu = uibuttongroup('visible','off','units','pixel','Position',[5 5 120 410],...
'BackgroundColor','w','HighlightColor',[1 1 1]*.3,...
'BorderWidth',1,'BorderType','beveledin' );
h.menu(2) = uicontrol(...
'Style','Radio','String','General',...
'BackgroundColor','w',...
'pos',[10 350 100 30],'parent',h.menu(1),'HandleVisibility','off',...
'Userdata',h.panel([6 8]));
h.menu(4) = uicontrol(...
'Style','Radio','String','Station',...
'BackgroundColor','w',...
'pos',[10 325 100 30],'parent',h.menu(1),'HandleVisibility','off',...
'Userdata',h.panel(1 ));
h.menu(4) = uicontrol(...
'Style','Radio','String','Event window',...
'BackgroundColor','w',...
'pos',[10 300 100 30],'parent',h.menu(1),'HandleVisibility','off',...
'Userdata',h.panel(3));
h.menu(5) = uicontrol(...
'Style','Radio','String','Fetch Traces',...
'BackgroundColor','w',...
'pos',[10 275 100 30],'parent',h.menu(1),'HandleVisibility','off',...
'Userdata',h.panel(4:5));
h.menu(7) = uicontrol(...
'Style','Radio','String','Email data request',...
'BackgroundColor','w',...
'pos',[10 250 100 30],'parent',h.menu(1),'HandleVisibility','off',...
'Userdata',h.panel(10:11));
h.menu(3) = uicontrol(...
'Style','Radio','String','Phases',...
'BackgroundColor','w',...
'pos',[10 225 100 30],'parent',h.menu(1),'HandleVisibility','off',...
'Userdata',h.panel(2));
h.menu(6) = uicontrol(...
'Style','Radio','String','Find Files ',...
'BackgroundColor','w',...
'pos',[10 200 100 30],'parent',h.menu(1),'HandleVisibility','off',...
'Userdata',h.panel([7 9]));
%% Side panel: push buttons
tmp = mfilename('fullpath');
tmp = fileparts(tmp);
tmp = ['file:///' tmp filesep 'Doc' filesep 'splitlab.html'];
uicontrol('parent',h.menu(1),...
'Units','pixel',...
'Style','Pushbutton',...
'Position',[10 160 100 25],...
'Cdata', icon.help,...
'Tooltip',' See help documents',...
'Callback',['web ' tmp ]);
clear tmp
%-------------------------------------------------------------------------
pjtlist = getpref('Splitlab','History');
files = {};
for k =1:length(pjtlist);
[pp,name,ext] = fileparts(pjtlist{k});
files{k}=[name ext];
end
loadstr={' Load Project',' Browse...', files{:}};
h.menu(8) = uicontrol(...
'Style','popupmenu',...
'String',loadstr,...
'UserData',pjtlist,...
'BackgroundColor','w',...
'Value',1,...
'pos',[10 130 100 25],'parent',h.menu(1),'HandleVisibility','off',...
'Callback',@loadcallback);
%-------------------------------------------------------------------------
h.menu(7) = uicontrol(...
'Style','pushbutton',...
'String','Save Project As',...
'BackgroundColor','w',...
'pos',[10 100 100 25],'parent',h.menu(1),'HandleVisibility','off',...
'Callback',@savecallback,...
'USERDATA', h.menu(8));
h.menu(9) = uicontrol(...
'Style','pushbutton',...
'String','View Seismograms',...
'ToolTipString','Start / Continue splitting',...
'BackgroundColor','w',...
'pos',[10 70 100 25],'parent',h.menu(1),'HandleVisibility','off',...
'Callback','SL_SeismoViewer(config.db_index)'); %open last splitting event
h.menu(10) = uicontrol(...
'Style','pushbutton',...
'String',' View Database',...
'BackgroundColor','w',...
'pos',[10 40 100 25],'parent',h.menu(1),'HandleVisibility','off',...
'Callback','SL_databaseViewer');
h.menu(10) = uicontrol(...
'Style','pushbutton',...
'String','Results',...
'BackgroundColor','w',...
'pos',[10 10 100 25],'parent',h.menu(1),'HandleVisibility','off',...
'Callback','SL_Results');
h.menu(99) = uicontrol(...
'Style','pushbutton',...
'String',' Save Preferences',...
'ToolTipString','Save current configuration as preference',...
'BackgroundColor','w',...
'pos',[7 380 106 22],'parent',h.menu(1),'HandleVisibility','off',...
'Callback','SL_preferences(config); helpdlg(''Preferences succesfully saved!'',''Preferences'')');
set(h.menu(1),'SelectionChangeFcn',@selcbk);
set(h.menu(1),'SelectedObject',[h.menu(2)]);
set(h.panel([6 8]),'Visible','on');
set(h.menu(1),'Visible','on');
figure(cfig)
% intrestingly, at startup the first value of the random gegenator is often 0.9501
% so, generate first dum dummy random numbers, and than in a new round take
% two random to state if show postcard or acknowldgement dialogs
rng('shuffle'); % RWP: Matlab will always generate the same sequence of pseudo random numbers upon startup. By using rng('shuffle'),
% we force Matlab to set a new sequence of random numbers based on the time
% that rng was called.
% rand(100,100);
R = rand(1,2);
% if R(1)>.92, postcardware, end %Delete this line, if you have already sent a PostCard
% if R(2)>.92, acknowledgement, end
if R(1) > .5
postcardware
else
acknowledgement
end
% This setup promises you get either a postcardware message or the
% acknowledgement message
%% S U B F U N C T I O N S %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function selcbk(source,eventdata)
%set selected menu panel visible, others are made invisible
old = get(eventdata.OldValue,'Userdata');
new = get(eventdata.NewValue,'Userdata');
set (old, 'visible', 'off')
set (new, 'visible', 'on')
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function loadcallback(source,eventdata)
evalin('base','global eq thiseq config');
global config eq
val =get(gcbo,'Value');
if val ==1;
%"Load" string... do nothing!
return
elseif val == 2 %Browse...
str ={'*.pjt', '*.pjt - SplitLab projects files';
'*.mat', '*.mat - MatLab files';
'*.*', '* - All files'};
pjtlist = getpref('Splitlab','History');
[tmp1,pathstr] = uigetfile( str ,'Project file', [config.projectdir, filesep]) ;
if isstr(pathstr) %user did not cancle
load('-mat',fullfile(pathstr,tmp1))
newfile = fullfile(pathstr,tmp1);
match = find(strcmp(newfile, pjtlist));
if isempty(match)% selection not in history
if length(pjtlist)>5
pjtlist = {newfile, pjtlist{1:5}};
else
pjtlist = {newfile, pjtlist{:}};
end
else
%re-order list
L = 1:length(pjtlist);
new = [match setdiff(L,match)];
pjtlist = pjtlist(new);
end
else %user did cancle
return
end
else
pjtlist = getpref('Splitlab','History');
%moving recently loaded to top of list
n = val-2; %data does not contain the "Load" and "browse" entries
L = 1:length(pjtlist);
new = [n setdiff(L,n)];
pjtlist = pjtlist(new);
files = get(gcbo,'Userdata'); %need full path name, which is stored in userdata
load('-mat',files{n})
[pathstr,name] = fileparts(files{n});
end
config.projectdir = pathstr;
setpref('Splitlab','History', pjtlist);
splitlab
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function savecallback(src,e)
global config eq
str ={'*.pjt', '*.pjt - SplitLab projects files';
'*.mat', '*.mat - MatLab files';
'*.*', '* - All files'};
[tmp1,tmp2]=uiputfile( str ,'Project file', ...
[config.projectdir, filesep, config.project]);
if isstr(tmp2)
oldpjt = config.project ;
config.projectdir = tmp2;
config.project = tmp1;
newfile = fullfile(tmp2,tmp1);
pjtlist = getpref('Splitlab','History');
match = find(strcmp(newfile, pjtlist));
if isempty(match)% selection not in history
if length(pjtlist)>5
pjtlist = {newfile, pjtlist{1:5}};
else
pjtlist = {newfile, pjtlist{:}};
end
else
%re-order list
L = 1:length(pjtlist);
new = [match setdiff(L,match)];
pjtlist = pjtlist(new);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
setpref('Splitlab','History', pjtlist)
save(fullfile(tmp2,tmp1), 'config','eq')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
files = {};
for k =1:length(pjtlist);
[pp,name,ext] = fileparts(pjtlist{k});
files{k}=[name ext];
end
loadstr={' Load Project',' Browse...', files{:}};
loadUIcontrol = get(gcbo,'Userdata');
set(loadUIcontrol,'UserData', pjtlist, 'String', loadstr)
pjtfield = findobj('String',oldpjt,'type','uicontrol');
set(pjtfield,'String',config.project)
end
clear tmp*
%% This program is part of SplitLab
% © 2006 Andreas Wüstefeld, Université de Montpellier, France
%
% DISCLAIMER:
%
% 1) TERMS OF USE
% SplitLab is provided "as is" and without any warranty. The author cannot be
% held responsible for anything that happens to you or your equipment. Use it
% at your own risk.
%
% 2) LICENSE:
% SplitLab is free software; you can redistribute it and/or modifyit under the
% terms of the GNU General Public License as published by the Free Software
% Foundation; either version 2 of the License, or(at your option) any later
% version.
% This program is distributed in the hope that it will be useful, but WITHOUT
% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
% more details.