-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathinstall_SplitLab.m
More file actions
executable file
·441 lines (382 loc) · 14.5 KB
/
Copy pathinstall_SplitLab.m
File metadata and controls
executable file
·441 lines (382 loc) · 14.5 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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
function install_SplitLab
% installation of SplitLab
% -Adding SplitLab to the MATLAB search path
% -Installation of the matTaup-toolbox
% for calculation of seismic travel times and paths
% -on Microsoft-Systems: assign icons
% -on non-Microsoft systems try to assign webbrowser (see docopt.m)
%
%
% In case of problems please check:
% - The file classpath.txt (containing the path to JAVA classes in Matlab)
% should contain the propper path to the file "matTaup.jar" located by
% default in $MATLABROOT/toolbox/matTaup/lib/mattaup.jar
% You can view the file by typing in matlab: edit(which('classpath.txt'))
% After editing classpath.txt you have to restart Matlab
%
% - The matlab search path should contain the following folders:
% SplitlabX.X.X/
% SplitlabX.X.X/Tools
% SplitlabX.X.X/ShearWaveSplitting
% The path to the SacLab Utility
% SplitlabX.X.X/Saclab
% The path pointing to matTaup (usually at the end of the path)
% $MATLABROOT/toolbox/mattaup
% For editing the path use the command: pathtool
%
% Furthermore, Splitlab preferences are added to the Matlab environment
% (See the prefdir documentation for further details on preferences). the
% Splitlab Preferences contain the fields CONFIGURATION (default Splitlab
% project configuration), ASSOCIATIONS (figure export file types and, on
% non-PCs, the system command line to open the file type) and HISTORY
% (recently used Splitlab Projects). These preferences are only valid for
% the user, who installed SplitLab. However, if a new user run Splitlab,
% new default preferences are automatically created for that user. In
% multiuser case be sure that all users have permission to the
% Splitlab, Saclab and matTaup path and the paths are set correctly for
% each user.
%
% have fun
% Andy Wüstefeld
% September 2006
[pathstr,name,ext] = fileparts(mfilename('fullpath'));
%%
v = version;
if str2num(v(1:3))< 8.4
beep
Answer = questdlg({'Error:', 'Matlab Version 8.4 or later is required for Splitlab. Sorry...',...
'You appear to be using version ' version,...
'Try using Splitlab1.1.0 instead',...
'',...
'Full functionaliy will not be available',...
'',...
'Please make also sure that your Matlab installation contains the',...
'Mapping Toolbox and the Signal Processing Toolbox',...
''},...
'Version Error',...
'Continue anyway', 'Cancel', 'Cancel');
if strcmp(Answer, 'Cancel')
return
end
end
mapbox = ~license('checkout','map_toolbox');
signalbox = ~license('checkout','signal_toolbox');
% Appears this version is changing the userpath, ie where matlab starts, to
% "/"
% So this fix avoids that problem
myuserpath = userpath;
str = strsplit(myuserpath,':');
myuserpath = str{1};
if any([mapbox signalbox])
beep
v=ver;
toolboxes = upper(char({v.Name}));
Answer = questdlg({'Error:', 'Mapping Toolbox and Signal Processing Toolbox ', 'are required for Splitlab. Sorry...',...
'Full functionaliy will not be available',...
'',...
'Your current Matlab License contains the following toolboxes:',...
toolboxes,...
''},...
'License Error',...
'Continue anyway', 'Cancel', 'Cancel');
if strcmp(Answer, 'Cancel')
return
end
end
%%
%%
licensestring={'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 modify ',...
'it 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.'],...
' ',...
['You should have received a copy of the GNU General Public License ',...
'along with this program; if not, write to the Free Software ',...
'Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA'],' ',' '};
%% THE BEER-WARE LICENSE" (Revision 42):
% If we meet some day, and you think this stuff is worth it, you can buy me a beer in return
pos = get(0,'DefaultFigurePosition');
pos(3:4) = [ 560 420];
H = figure('Name', 'Splitlab Licence Agreement', 'Color','w','units','Pixel',...
'NumberTitle','Off','ToolBar','none','MenuBar','none','Position',pos);
% movegui(H,'center')
ui = uicontrol('style','text','Parent',H,'units','Pixel','String',licensestring,...
'Position',[30 20 pos(3:4)-[60 130]], 'BackGroundColor','w','HorizontalAlignment','Center');
logo = imread(fullfile(pathstr,'Doc','splitlabLogo.png'));
axpos = [pos(3)-190 pos(4)-120 158 110];
ax = axes('units','Pixel','Position', axpos, 'parent',H);
image(logo)
axis off
ui = uicontrol('style','pushbutton','Parent',H,'units','Pixel','String','I agree...',...
'Position',[190 15 90 25],'Callback',' set(0,''Userdata'',1);uiresume; closereq; ');
ui = uicontrol('style','pushbutton','Parent',H,'units','Pixel','String','I do not agree!!!',...
'Position',[290 15 90 25],'Callback','set(0,''Userdata'',0);uiresume; closereq; ');
uiwait
agree = get(0,'Userdata');
if ~agree
return
end
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
run(fullfile(pathstr,'Tools','postcardware.m'))
run(fullfile(pathstr,'Tools','acknowledgement.m'))
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% installation starts here
% remove earlier instalations of SplitLab from the path
P = path;
sep = [0 findstr(pathsep,P)];
SL = [0 findstr('SplitLab',P)]; %occurences of "SplitLab" in the path
for k=2:length(SL);
ff = find(SL(k-1)<=sep & sep<SL(k));
s1 = sep(ff)+1;
s2 = sep(ff+1);
tmp = P(s1:s2);
rmpath(tmp)
end
% check if matTaup and iris-ws are installed
%javaClasspath = textread(which('classpath.txt'),'%s','delimiter','\n','whitespace','');% eqivalent to javaclasspath('-static')
%javaClasspathFile = which('classpath.txt');
% if str2double(v(1:3)) >= 8.5
% javaClasspathFile = which('javaclasspath.txt');
% else
javaClasspathFile = which('classpath.txt');
% end
javaClasspathFid = fopen(javaClasspathFile,'r');
javaClassPathCell = textscan(javaClasspathFid,'%s');
fclose(javaClasspathFid);
javaClasspath = javaClassPathCell{1};
isMatTaup = strfind(javaClasspath,'matTaup');
isIrisWS = strfind(javaClasspath,'IRIS-WS');
splitlabpath = pathstr;%[matlabroot filesep 'toolbox' filesep 'splitlab' filesep ];
matpath = [matlabroot filesep 'toolbox' filesep 'matTaup' filesep ];
saclabpath = [pathstr filesep 'Saclab' filesep ];
toolboxpath = [matlabroot filesep 'toolbox' filesep];
installSplitlab = 1;
installSaclab = 1;
if all (cellfun('isempty',isMatTaup))
installMatTaup = 1;
else
installMatTaup=0;
end
if all (cellfun('isempty',isIrisWS))
installIrisWS = 1;
else
installIrisWS = 0;
end
next=0;
installSL_GUI
waitfor(h)
next=1;
%% XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
%% INSTALL starts here
if ~next%user did not press the "next" button
return
end
if all([installSplitlab, ~(exist(splitlabpath,'dir')==7)])
mkdir(splitlabpath)
splitlabpath
end
if all([installSaclab, ~(exist(saclabpath,'dir')==7)])
mkdir(saclabpath)
end
if installSaclab
oldSACpath = [pathstr filesep 'Saclab' filesep ];
if ~strcmp(oldSACpath, saclabpath)
movefile([oldSACpath '*'], saclabpath)
end
end
matpath = strrep(matpath, [filesep 'matTaup'], '');%will be added from the .zip file
if all([installMatTaup, ~(exist(matpath,'dir')==7)])
linenumber = find (cellfun('isempty',isMatTaup));
mkdir(matpath)
disp(matpath)
end
disp(' ')
disp('*******************************************')
disp('adding directories to Matlab Path')
if installSaclab
addpath(saclabpath)
disp(saclabpath)
end
if installSplitlab
addpath([splitlabpath filesep 'ShearWaveSplitting'])
addpath([splitlabpath filesep 'Tools'])
addpath(splitlabpath)
disp([splitlabpath filesep 'ShearWaveSplitting'])
disp([splitlabpath filesep 'Tools'])
disp(splitlabpath)
end
%% matTauP
if installMatTaup
disp(' ')
disp('*******************************************')
disp('extracting matTaup.zip and add to MATLAB path')
disp([matpath 'matTaup' filesep])
%unzip(fullfile([pathstr filesep 'Tools'],'matTaup.zip'),matpath)
pause(1)%necessary to for system processes to end; don't know why...
disp('*******************************************')
disp(' ')
matpath = [matpath 'matTaup' filesep];
addpath(matpath, '-end');
savepath
disp('Updating static java classpath')
disp('*******************************************')
%clpath=which('classpath.txt');
%if str2double(v(1:3)) >= 8.5
% clpath = which('javaclasspath.txt');
%else
clpath = which('classpath.txt');
%end
disp(clpath)
if ~(matpath(end)==filesep)
matpath=[matpath filesep];
end
jfile = [matpath 'lib' filesep 'matTaup.jar'];
jfiledir = [matpath 'lib' filesep];
[~,~,~] = mkdir(jfiledir);
includedJarFile = ['Tools' filesep 'matTaup' filesep 'matTaup' filesep 'lib' filesep 'matTaup.jar'];
copyfile(includedJarFile,jfiledir);
fid = fopen(clpath,'a+');
if fid==-1
commandwindow
error('SplitLab:Install',['Opening of classpath.txt failed.\n',...
' You need Root/Administrator privileges to change this file. \n',...
' Please contact your system administrator to add following line to \n',...
' ', strrep(clpath,'\','\\'), ':\n',...
strrep(jfile,'\','\\') ])
else
fseek (fid, 0, 'eof'); %go to end of file
fprintf(fid,'%s\n',jfile);
fclose(fid);
disp('*******************************************')
end
end
if installIrisWS
disp('*******************************************')
disp(' ')
addpath(matpath, '-end');
savepath
disp('Updating static java classpath')
disp('*******************************************')
%clpath=which('classpath.txt');
%if str2double(v(1:3)) >= 8.5
% clpath = which('javaclasspath.txt');
%else
clpath = which('classpath.txt');
%end
disp(clpath)
if ~(matpath(end)==filesep)
matpath=[matpath filesep];
end
jfile = [matpath 'lib' filesep 'IRIS-WS-2.0.12.jar'];
jfiledir = [matpath 'lib' filesep];
[~,~,~] = mkdir(jfiledir);
includedJarFile = ['Tools' filesep 'IRIS-WS-2.0.12.jar'];
copyfile(includedJarFile,jfiledir);
fid = fopen(clpath,'a+');
if fid==-1
commandwindow
error('FuncLab:Install',['Opening of classpath.txt failed.\n',...
' You need Root/Administrator privileges to change this file. \n',...
' Please contact your system administrator to add following line to \n',...
' ', strrep(clpath,'\','\\'), ':\n',...
strrep(jfile,'\','\\') ])
else
fseek (fid, 0, 'eof'); %go to end of file
fprintf(fid,'%s\n',jfile);
fclose(fid);
disp('*******************************************')
end
end
%% Registering SAC-files and Splitlab-projects (Windows only)
if ispc
disp(' ')
disp(' ')
disp('Registering SplitLab-Project Files: ')
dos('assoc .pjt=SplitLabProject');
dos('assoc .sac=SACfile');
[xxx,xxx] = dos(['ftype SACfile=']);
dos(['ftype SplitLabProject=' matlabroot '\bin\win32\matlab.exe -minimize -memmgr fast -r openpjt(''"%1"'');"global thiseq";splitlab']);
disp(' ')
disp(' ')
disp('registering SAC- and PJT-icons:')
disp('SplitlabProject')
dos(['reg add HKCR\SplitLabProject\DefaultIcon /ve /f /d "' pathstr '\Tools\project.ico"']);
disp(' ')
disp(' ')
disp('SAC')
dos(['reg add HKCR\SACfile\DefaultIcon /ve /f /d "' pathstr '\Tools\sacfile.ico"']);
% disp('registering file types:')
[xxx,xxx] = dos(['reg add HKCR\SplitLabProject /ve /f /t REG_SZ /d "SplitLab Project"']);
[xxx,xxx] = dos(['reg add HKCR\SACfile /ve /f /t REG_SZ /d "SAC seismogram"']);
end
%% preferences
disp(' ')
disp(' ')
disp('Generating Splitlab Default Preferences')
config=SL_defaultconfig;
SL_preferences(config);
disp('*******************************************')
pause(2)
%% DOCOPT
% on non-Windows machine
if ~ispc & ~strncmp(computer,'MAC',3)
[doccmd,options,docpath] = docopt
if isempty(doccmd)
try
edit('docopt.m')
catch
docsearch docopt
error(['For full functionality of Splitlab, the external WEB-browser needs to\n',...
' be specified on Unix-systems. You need root privileges to edit \n ',...
strrep(which('docopt.m'),'\','\\') '\n',...
' Please contact your Administrator \n\n See also ',...
sprintf('<a href="matlab:help docopt">docopt</a>') ],'\n')
end
pause(1)
else
docsearch docopt
beep
disp('For full functionality of Splitlab, the external WEB-browser needs to')
disp(['be specified on Unix-systems. Current Browser is ' doccmd])
disp('If this is correct you can continue, otherwise please ')
disp('edit <a href="matlab:docopt.m">docopt.m</a>')
end
commandwindow
disp(' ')
disp('You may want to add the following lines to your .bashrc file:')
disp(' ')
disp('###############################################################')
disp('#SPLITLAB')
disp('alias splitlab=''unset LANG; cd; matlab -nodesktop -r splitlab''')
disp('###############################################################')
disp(' ')
pause(2)
end
SL_defaultconfig;
userpath(myuserpath);
%% FINISHING
savepath
button = questdlg({'SplitLab installed', 'To changes take effect, please restart MATLAB!', ' Have fun'}, ...
'Exit Dialog','Restart Matlab','Later','Restart Matlab');
switch button
case 'Restart Matlab';
if ispc
!matlab /nosplash /r splitlab&
else
eval(['!cd ' matlabroot filesep 'bin'])
eval(['!matlab -nosplash -r splitlab&'])
end
quit
case 'Later',
end