forked from benjaminbritton/AstroEBSD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start_AstroEBSD.m
97 lines (76 loc) · 2 KB
/
start_AstroEBSD.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
function Astro_FP=start_AstroEBSD(varargin)
% Load AstroEBSD
%set up the path
local_path = fileparts(mfilename('fullpath'));
fprintf('Loading AstroEBSD');
if MATLABverLessThan('9.0')
error('AstroEBSD needs at least version 9 of Matlab')
end
%read Astro version from version file - adapted from MTEX
try
fid = fopen('VERSION','r');
AstroVersion = fgetl(fid);
fclose(fid);
fprintf([' ' AstroVersion ' ']);
catch
AstroVersion = 'AstroEBSD';
end
%initalise folders as needed
%read the current folder
astroloc=strfind(local_path,'AstroEBSD');
%check that w are in a subfolder
if isempty(astroloc)
error('Path must be run first from a subfolder of ''AstroEBSD''');
end
%get the file path
Astro_FP=local_path(1:astroloc+8);
%build folders for things if this is a first run
if exist([Astro_FP '\testing'],'dir') ~= 7
mkdir([Astro_FP '\testing']);
end
if exist([Astro_FP '\outputs'],'dir') ~= 7
mkdir([Astro_FP '\outputs']);
end
if exist([Astro_FP '\decks'],'dir') ~= 7
mkdir([Astro_FP '\decks']);
end
%build the paths
addpath([Astro_FP '\gen']);
addpath([Astro_FP '\bin']);
addpath([Astro_FP '\utils']);
addpath([Astro_FP '\phases']);
addpath([Astro_FP '\testing']);
addpath([Astro_FP '\decks']);
addpath([Astro_FP '\outputs']);
addpath([Astro_FP '\plot']);
addpath([Astro_FP]);
disp('AstroEBSD file paths loaded');
end
% check MATLAB version - borrowed from MTEX loader
% --------------------
function result = MATLABverLessThan(verstr)
MATLABver = ver('MATLAB');
toolboxParts = getParts(MATLABver(1).Version);
verParts = getParts(verstr);
result = (sign(toolboxParts - verParts) * [1; .1; .01]) < 0;
end
function parts = getParts(V)
parts = sscanf(V, '%d.%d.%d')';
if length(parts) < 3
parts(3) = 0; % zero-fills to 3 elements
end
end
function p()
if isempty(lasterr)
fprintf('.');
end
end
function pathadd(path)
pathCell = regexp(path, pathsep, 'split');
if ispc % Windows is not case-sensitive
onPath = any(strcmpi(Folder, pathCell));
else
onPath = any(strcmp(Folder, pathCell));
end
end
%eof