Skip to content
Snippets Groups Projects
Commit a35358c0 authored by leprob001's avatar leprob001
Browse files

feat: IBCSO dataset can now be used to plot topographical lines

parent e9a579ae
No related branches found
No related tags found
No related merge requests found
331 332
\ No newline at end of file \ No newline at end of file
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
-floatfile ..\HAFOS.flo % not used in artoa4 yet -floatfile ..\HAFOS.flo % not used in artoa4 yet
-bathyfile % not used in artoa4 yet -bathyfile % not used in artoa4 yet
-etopo /your/filepath/here/data/etopo1_bed_c.flt -etopo /your/filepath/here/data/etopo1_bed_c.flt
-ibcso /your/filepath/here/data/contours_Grid5000_Step50.mat
[directory] [directory]
-interim /your/filepath/here/ -interim /your/filepath/here/
...@@ -56,7 +57,10 @@ ...@@ -56,7 +57,10 @@
-pressure 9999 -pressure 9999
-temperature 9999 -temperature 9999
-toa 9999 -toa 9999
-topographical_lines -4000 -3000 -2000
[topographical_lines]
-depth -4000 -3000 -2000
-use_ibcso 1 % set this to 0 if you want to use etopo
[offsetvariations] [offsetvariations]
1 1 1 1
......
...@@ -2,7 +2,7 @@ function [] = loadArtoaIni(~, ~) ...@@ -2,7 +2,7 @@ function [] = loadArtoaIni(~, ~)
%RELOADARTOAINI Loads the artoa.ini file and copies the required values to workspace. %RELOADARTOAINI Loads the artoa.ini file and copies the required values to workspace.
% %
global artoaConfig artoaWorkspace; global artoaConfig artoaWorkspace artoaDataInput;
try try
artoaConfig = artoa.load.tomlini('artoa.ini'); artoaConfig = artoa.load.tomlini('artoa.ini');
...@@ -16,6 +16,15 @@ if isempty(artoaConfig) ...@@ -16,6 +16,15 @@ if isempty(artoaConfig)
error([mfilename ': artoa.ini has been found but is empty. Please use a valid artoa.ini!']); error([mfilename ': artoa.ini has been found but is empty. Please use a valid artoa.ini!']);
end end
% load ibcso if required
if artoaConfig.topographical_lines.use_ibcso == 1
try
artoaDataInput.ibcso = load(artoaConfig.files.ibcso);
catch ex
error([mfilename ': Loading IBCSO file failed. Please make sure that file "' artoaConfig.files.ibcso '" exists!']);
end
end
artoa.controller.addDefaults(); artoa.controller.addDefaults();
artoa.controller.edit.updateAvailablePlots(); artoa.controller.edit.updateAvailablePlots();
......
...@@ -14,7 +14,8 @@ if ~artoa.controller.file.loadEtopoFile( ... ...@@ -14,7 +14,8 @@ if ~artoa.controller.file.loadEtopoFile( ...
end end
%% Get required variables %% Get required variables
topographical_line_values = artoaConfig.defaults.topographical_lines; topographical_line_values = artoaConfig.topographical_lines.depth;
use_ibcso = artoaConfig.topographical_lines.use_ibcso;
%% Plot topographical lines %% Plot topographical lines
...@@ -22,9 +23,10 @@ topographical_line_values = artoaConfig.defaults.topographical_lines; ...@@ -22,9 +23,10 @@ topographical_line_values = artoaConfig.defaults.topographical_lines;
axes(pAxesHandle); axes(pAxesHandle);
hold(pAxesHandle, 'on'); hold(pAxesHandle, 'on');
topographicalLineHandles = cell(length(topographical_line_values), 1); topographicalLineHandles = {};
topoColors = {'r', 'g', 'b', 'm', 'y'};
for o = 1:length(topographicalLineHandles) for o = 1:length(topographical_line_values)
if isnan(topographical_line_values(o)) ... if isnan(topographical_line_values(o)) ...
| (ischar(topographical_line_values(o)) && strcmp(strip(topographical_line_values(o)), '')) | (ischar(topographical_line_values(o)) && strcmp(strip(topographical_line_values(o)), ''))
continue; continue;
...@@ -35,13 +37,42 @@ for o = 1:length(topographicalLineHandles) ...@@ -35,13 +37,42 @@ for o = 1:length(topographicalLineHandles)
else else
lineValue = topographical_line_values(o); lineValue = topographical_line_values(o);
end end
[~, topographicalLineHandles{o}] = contourm( ...
artoaDataInput.etopo.Z, ... if use_ibcso
artoaDataInput.etopo.refvec, ... depth_index = find(artoaDataInput.ibcso.contourLevels == lineValue, 1);
[lineValue, lineValue], ... if isempty(depth_index)
'ShowText', 'on', ... warning(['No data has been found for contour line at ' num2str(lineValue) ' in IBCSO dataset. Please double check that the dataset contains the specified contour level.']);
'LabelSpacing', 400 ... continue;
); end
c_data = artoaDataInput.ibcso.cArray{depth_index};
lineValueBool = c_data(1, :) == lineValue;
idxFilter = c_data(1, :) ~= lineValue;
filteredCData = mat2cell(c_data(:, idxFilter), 2, c_data(2, lineValueBool));
for cIdx = 1:length(filteredCData)
currentData = filteredCData{cIdx};
[topographicalLineHandles{end + 1}] = plot( ...
currentData(1, :), ...
currentData(2, :), ...
topoColors{o} ...
);
end
[~, maxIdx] = max(c_data(2, lineValueBool));
textCoordinatesIdx = round(size(filteredCData{maxIdx}, 2)/2);
topographicalLineHandles{end + 1} = text( ...
filteredCData{maxIdx}(1, textCoordinatesIdx), ...
filteredCData{maxIdx}(2, textCoordinatesIdx), ...
num2str(lineValue), ...
'BackgroundColor', 'white' ...
);
else
[~, topographicalLineHandles{o}] = contourm( ...
artoaDataInput.etopo.Z, ...
artoaDataInput.etopo.refvec, ...
[lineValue, lineValue], ...
'ShowText', 'on', ...
'LabelSpacing', 400 ...
);
end
catch catch
warning('There was an error on plotting topographical lines. Kindly ignore this warning if your zoomed area does not contain any topograpical lines.'); warning('There was an error on plotting topographical lines. Kindly ignore this warning if your zoomed area does not contain any topograpical lines.');
end end
......
...@@ -2,10 +2,10 @@ function [] = tableTopographicalLinesEdit(~, ~) ...@@ -2,10 +2,10 @@ function [] = tableTopographicalLinesEdit(~, ~)
%UPDATETABLEGENERATEDTRACKS Summary of this function goes here %UPDATETABLEGENERATEDTRACKS Summary of this function goes here
% Detailed explanation goes here % Detailed explanation goes here
global artoaGui artoaWorkspace; global artoaGui artoaWorkspace artoaConfig;
%% Save to workspace %% Save to workspace
artoaWorkspace.trajectoryOutput.topographicalLines = artoaGui.trajectoryOutput.tableTopographicalLines.Data; artoaConfig.topographical_lines.depth = artoaGui.trajectoryOutput.tableTopographicalLines.Data';
%% Plot if required %% Plot if required
if ~artoaWorkspace.trajectoryOutput.showTopographicalLines if ~artoaWorkspace.trajectoryOutput.showTopographicalLines
......
...@@ -2,7 +2,7 @@ function [] = updateGui() ...@@ -2,7 +2,7 @@ function [] = updateGui()
%UPDATEGUI Summary of this function goes here %UPDATEGUI Summary of this function goes here
% Detailed explanation goes here % Detailed explanation goes here
global artoaWorkspace artoaGui; global artoaWorkspace artoaGui artoaConfig;
if artoa.data.hasMember(artoaWorkspace, {'trajectoryOutput', 'updateTrackParameterWindow'}) if artoa.data.hasMember(artoaWorkspace, {'trajectoryOutput', 'updateTrackParameterWindow'})
artoaGui.trajectoryOutput.checkboxUpdateTrackParameterWindow.Value = ... artoaGui.trajectoryOutput.checkboxUpdateTrackParameterWindow.Value = ...
...@@ -42,7 +42,7 @@ else ...@@ -42,7 +42,7 @@ else
end end
if artoa.data.hasMember(artoaWorkspace, {'trajectoryOutput', 'topographicalLines'}) if artoa.data.hasMember(artoaWorkspace, {'trajectoryOutput', 'topographicalLines'})
artoaGui.trajectoryOutput.tableTopographicalLines.Data = ... artoaGui.trajectoryOutput.tableTopographicalLines.Data = ...
artoaWorkspace.trajectoryOutput.topographicalLines; artoaConfig.topographical_lines.depth';
else else
artoaGui.trajectoryOutput.checkboxShowTopographicalLines.Value = false; artoaGui.trajectoryOutput.checkboxShowTopographicalLines.Value = false;
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment