forked from sspagnol/easyplot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_easyplot.m
75 lines (59 loc) · 1.97 KB
/
setup_easyplot.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
function setup_easyplot
% path to easyplot dir
[EPdir, name, ext] = fileparts(mfilename('fullpath'));
%easyplotDir='D:\Projects\aims-gitlab\easyplot';
% location of the users toolbox installation
imos_tb_home='/Users/cow074/Documents/work_mac/moorings/imos-toolbox/imos-toolbox/';
%location of raw data files:
raw_files_pth = '/Volumes/DWmoorings1/Solander_2015/2014_recoveries/RawData/';
% user should not need to edit anything further
%%
reAddPaths(EPdir,'AIMS easyplot',true);
%% add IMOS Toolbox paths
reAddPaths(imos_tb_home,'IMOS toolbox',true);
%% add Data file paths
reAddPaths(raw_files_pth,'Raw Files',true);
end
%%
function reAddPaths(topDir,messageStr,atBeginning)
disp(['Adding paths for ' messageStr ', please wait...']);
gp=genpath_clean(topDir);
disp(' Removing any existing paths.')
rempath(gp);
disp(' Adding new paths');
if atBeginning
addpath(gp,'-begin');
else
addpath(gp);
end
end
%%
function rempath(gp)
% from a genpath path string, remove on paths that are currently in the
% matlab path
ss=strsplit(gp,';');
pp=strsplit(path,';');
ii=ismember(ss,pp);
ss=ss(ii); %list with only directories that are currently on matlab path
if ~isempty(ss)
thePath=sprintf(['%s' pathsep],ss{:}); %make string seperated by pathsep
if thePath(end)==pathsep % remove last not needed pathsep
thePath(end)=[];
end
rmpath(thePath);
end
end
%%
function thePath = genpath_clean( topDir )
%genpath_clean generate a path without .svn, .git etc.
% generate a path without .svn, .git etc. Based on idea from OpenEarthTools
b=genpath(topDir);
s = strread(b, '%s','delimiter', pathsep); % read path as cell
rpattern='(\.svn|\.git|\.hg\private)';
ii=cellfun(@isempty,regexp(s,rpattern,'match','once'));
s=s(ii); %cell array without .git etc
thePath=sprintf(['%s' pathsep],s{:}); %make string seperated by pathsep
if thePath(end)==pathsep % remove last not needed pathsep
thePath(end)=[];
end
end