-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathwebinstall_extras.m
130 lines (116 loc) · 3.7 KB
/
webinstall_extras.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
129
130
function [ok]=webinstall_extras(dlflag)
%WEBINSTALL_EXTRAS Install extra SEIZMO components
%
% Usage: ok=webinstall_extras
% ok=webinstall_extras(true)
%
% Description:
% OK=WEBINSTALL_EXTRAS downloads & installs some extra files for SEIZMO
% such as a SAC polezero db, feature data for mapping, & 3D velocity
% models. The download is large at 50+ megabytes so make sure you have
% a good connection or this operation will take a while and you cannot
% do anything else at the Matlab/Octave prompt while waiting for the
% files to download.
%
% OK=WEBINSTALL_EXTRAS(TRUE) forces a redownload of the extra packages.
%
% Notes:
%
% Examples:
% % Reinstall:
% uninstall_irisws & webinstall_extras(true)
%
% See also: UNINSTALL_IRISWS, WEBINSTALL_GSHHS, UNINSTALL_GSHHS,
% WEBINSTALL_MMAP, UNINSTALL_MMAP, WEBINSTALL_EXPORTFIG,
% UNINSTALL_EXPORTFIG, WEBINSTALL_NJTBX, UNINSTALL_NJTBX,
% WEBINSTALL_EXTRAS, UNINSTALL_EXTRAS, WEBINSTALL_TAUP,
% UNINSTALL_TAUP, INSTALL_SEIZMO, UNINSTALL_SEIZMO
% Version History:
% Feb. 21, 2014 - initial version
% Feb. 27, 2014 - minor doc update
% Mar. 1, 2014 - iscfmdb not ready yet
% Mar. 2, 2014 - minor fix to web links
%
% Written by Garrett Euler (ggeuler at wustl dot edu)
% Last Updated Mar. 2, 2014 at 15:25 GMT
% todo:
% check nargin
error(nargchk(0,1,nargin));
% directory separator
fs=filesep;
% path to seizmo directory
mypath=fileparts(mfilename('fullpath'));
% check path
if(~exist(mypath,'dir'))
error('seizmo:webinstall_extras:badPath',...
['Directory (' mypath ') does not exist!']);
end
% default/check download flag
if(nargin<1 || isempty(dlflag)); dlflag=false; end
if(~islogical(dlflag) || ~isscalar(dlflag))
error('seizmo:webinstall_extras:badInput',...
'DLFLAG must be TRUE or FALSE!');
end
% attempt extras install
try
% go to desired install location
cwd=pwd;
cd(mypath);
% current versions
sacpzdb='seizmo_iris_sacpzdb.zip'; % ~20mb
sz3dmod='seizmo_3d_models.zip'; % ~20mb
mapfeat='seizmo_mapping_features.zip'; % ~10mb
%iscfmdb='seizmo_iscfmdb.zip'; % ~6mb
% grab files (either locally or remotely)
url0='http://epsc.wustl.edu/~ggeuler/codes/m/seizmo/';
%url1='https://s3-us-west-2.amazonaws.com/seizmo/'; % backup currently
fprintf(' Getting %s\n',sacpzdb);
if(~dlflag && exist(sacpzdb,'file'))
if(~exist([mypath fs sacpzdb],'file'))
copyfile(which(sacpzdb),'.');
end
else
urlwrite([url0 sacpzdb],sacpzdb);
end
fprintf(' Getting %s\n',sz3dmod);
if(~dlflag && exist(sz3dmod,'file'))
if(~exist([mypath fs sz3dmod],'file'))
copyfile(which(sz3dmod),'.');
end
else
urlwrite([url0 sz3dmod],sz3dmod);
end
fprintf(' Getting %s\n',mapfeat);
if(~dlflag && exist(mapfeat,'file'))
if(~exist([mypath fs mapfeat],'file'))
copyfile(which(mapfeat),'.');
end
else
urlwrite([url0 mapfeat],mapfeat);
end
%fprintf(' Getting %s\n',iscfmdb);
%if(~dlflag && exist(iscfmdb,'file'))
% if(~exist([mypath fs iscfmdb],'file'))
% copyfile(which(iscfmdb),'.');
% end
%else
% urlwrite([url0 iscfmdb],iscfmdb);
%end
% unpack files
% - These should land in their appropriate
% locations if I packaged them correctly.
unzip(sacpzdb);
unzip(sz3dmod);
unzip(mapfeat);
%unzip(iscfmdb);
% return
cd(cwd);
% all good
ok=true;
catch
le=lasterror;
warning(le.identifier,le.message);
ok=false;
cd(cwd);
end
end