-
Notifications
You must be signed in to change notification settings - Fork 15
/
vbr_init.m
78 lines (71 loc) · 2.36 KB
/
vbr_init.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
function vbr_init(varargin)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% vbr_init(varargin)
%
% adds all relevant VBR paths to the matlab path
%
% if within the vbr top level directory, just call:
% vbr_init
%
% if elsewhere (or within scripts), you need to add the path to the top level
% vbr directory first:
% addpath('/path/to/vbr')
% vbr_init
%
% Parameters
% ----------
% optional keyword-value pair inputs:
% 'forwardModel','ThermalEvolution_1d' to use a thermal model other than
% the default, e.g., vbr_init('forwardModel','ThermalEvolution_1d')
%
% Output
% ------
% Some screen printing, but just sets paths
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% define available versions, defaults
ValidOpts=struct();
ValidOpts.forwardModel={'ThermalEvolution_1d','none'};
Options=struct('forwardModel',ValidOpts.forwardModel{1});
ValidOpts.quiet={};
Options.quiet=0;
% get full path to vbr, regardless of where vbr_init is called from
p=mfilename('fullpath'); % full path of vbr_init without extension
[filepath,name,ext] = fileparts([p,'.m']);
vbr_dir=filepath; % remove filename from fullpath
% add the vbr/support directory and validate input options
addpath(genpath(fullfile(vbr_dir,'vbr','support')));
Options=validateStructOpts('vbr_init',varargin,Options,ValidOpts,1);
% collect all the subdirectories under ./vbr/ to add
subDirs2add={'vbrCore';'fitting'};
success=1;
for i_fo = 1:numel(subDirs2add)
fo=subDirs2add{i_fo};
path2add=fullfile(vbr_dir,'vbr',fo);
if exist(path2add,'dir')
addpath(genpath(path2add));
else
disp('Warning, vbr path is missing:')
disp(path2add)
success=0;
end
end
if success
if Options.quiet==0
version = vbr_version();
msg = ['VBRc version ', version.version, ' added to working path'];
disp(msg);
end
else
disp('WARNING: VBR calculator (or its components) is not in path')
end
if ~strcmp(lower(Options.forwardModel),'none')
path2add=fullfile(vbr_dir,'vbr','forwardModels',Options.forwardModel);
if exist(path2add,'dir')
addpath(genpath(path2add));
else
disp('Forward Model path does not exist, no forward model at this path:')
disp(path2add)
disp('Path is case sensitive.')
end
end
end