-
Notifications
You must be signed in to change notification settings - Fork 20
/
HydroSight.m
136 lines (120 loc) · 4.72 KB
/
HydroSight.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
131
132
133
134
135
136
%function [f, status] = HydroSight()
function varargout = HydroSight(doingTesting)
if nargin==0
doingTesting=false;
end
% Test if HydroSight started with -nodisplay.
noDesktop = true;
if usejava('desktop')
noDesktop = false;
end
% Check Matlab is 2018a or later.
if ~isdeployed
v=version();
ind = strfind(v,'.');
v_major = str2double(v(1:(ind(1)-1)));
v_minor = str2double(v((ind(1)+1):(ind(2)-1)));
if v_major<9 && v_minor<4 %ie 2018a;
msgstr = 'HydroSight requires Matlab 2018a or later.';
if ~ispc && noDesktop
disp(msgstr)
else
errordlg(msgstr,'Please update Matlab');
end
return;
end
end
% Add Paths
addpath(genpath([pwd, filesep, 'algorithms']));
addpath(genpath([pwd, filesep, 'GUI']));
% Load GUI
try
% Use GUI Layout Toolbox if it exists.
if ~isdeployed && ~isempty(ver('layout'))
rmpath(genpath(fullfile( pwd, 'GUI','GUI Layout Toolbox 2.3.4')));
end
f = HydroSight_GUI();
if doingTesting
varargout = {f};
end
catch ME
% Check the toolbox for GUIs exists
if ~isdeployed && isempty(ver('layout'))
msgstr = {'The GUI cannot be opened. This may be because the GUI Layout Toolbox is ', ...
'not installed within Matlab. Please download it using the URL below and', ...
'then install it and re-start HydroSight.', ...
'', ...
'https://www.mathworks.com/matlabcentral/fileexchange/47982-gui-layout-toolbox'};
if ~ispc && noDesktop
for i=1:length(msgstr)
disp(msgstr{i});
end
else
msgbox(msgstr, 'Toolbox missing: gui-layout-toolbox', 'error');
end
else
if size(ME.stack,1)>1
functionName = ME.stack(end-1,1).name;
functionLine = num2str(ME.stack(end-1,1).line);
else
functionName='';
functionLine ='';
end
% Output message
msgstr = {'An unexpected error occured. To help with fixing the issue please', ...
'copy the error message below and submit a bug report to:', ...
'https://github.com/peterson-tim-j/HydroSight/issues', ...
'', ...
['Message:', ME.message], ...
'', ...
['Function:', functionName], ...
'', ...
['Line Number:', functionLine]};
if ~ispc && noDesktop
for i=1:length(msgstr)
disp(msgstr{i});
end
else
msgbox(msgstr, 'Unknown error', 'error');
end
end
if doingTesting
varargout = {};
end
end
% Check if the required toolboxes are installed.
if ~isdeployed
v = ver;
[installedToolboxes{1:length(v)}] = deal(v.Name);
if ~any(strcmp(installedToolboxes, 'Statistics and Machine Learning Toolbox'))
msgstr = {'Statistics and Machine Learning Toolbox is required.', ...
'This toolbox is required for the most model algorithms.'};
if ~ispc && noDesktop % added to check if doing testing with nodisplay etc
disp(msgstr{1});
disp(msgstr{2});
else
warndlg(msgstr,'Statistics Toolbox not installed','modal')
end
end
if ~any(strcmp(installedToolboxes, 'Parallel Computing Toolbox'))
msgstr = {'Parallel Computing Toolbox is recommended.', ...
'This toolbox is used to reduce the calibration time for the most models.'};
if ~ispc && noDesktop % added to check if doing testing with nodisplay etc
disp(msgstr{1});
disp(msgstr{2});
else
warndlg(msgstr,'Parallel Toolbox not installed','modal');
end
end
if ~any(strcmp(installedToolboxes, 'Curve Fitting Toolbox'))
msgstr = {'Curve Fitting Toolbox is recommended.', ...
'Outlier detection algorithm will used regression, rather than splines, the estimate the initial slope.'};
if ~ispc && noDesktop % added to check if doing testing with nodisplay etc
disp(msgstr{1});
disp(msgstr{2});
else
warndlg(msgstr,'Curve Fitting Toolbox not installed','modal');
end
end
end
end