diff --git a/VERSION b/VERSION index b99877a597907968a7f18a0383ece82f077280a8..8db9866c8463f9bebbc4a3bdc87d5455578267c9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -331 \ No newline at end of file +332 \ No newline at end of file diff --git a/artoa.ini.example b/artoa.ini.example index c4c0f9dd85f6dbdc4e5d9286f1b4980c3891712f..0ab4eb6f539ad5e2f99728ab64d4b2f0d26f8a13 100644 --- a/artoa.ini.example +++ b/artoa.ini.example @@ -5,6 +5,7 @@ -floatfile ..\HAFOS.flo % not used in artoa4 yet -bathyfile % not used in artoa4 yet -etopo /your/filepath/here/data/etopo1_bed_c.flt +-ibcso /your/filepath/here/data/contours_Grid5000_Step50.mat [directory] -interim /your/filepath/here/ @@ -56,7 +57,10 @@ -pressure 9999 -temperature 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] 1 1 diff --git a/lib/+artoa/+controller/+file/loadArtoaIni.m b/lib/+artoa/+controller/+file/loadArtoaIni.m index 69ac60da322917b35ad7b68d229aab9d9a2eea77..4769fc04795d5e499bda618c1b93791bd652c065 100644 --- a/lib/+artoa/+controller/+file/loadArtoaIni.m +++ b/lib/+artoa/+controller/+file/loadArtoaIni.m @@ -2,7 +2,7 @@ function [] = loadArtoaIni(~, ~) %RELOADARTOAINI Loads the artoa.ini file and copies the required values to workspace. % -global artoaConfig artoaWorkspace; +global artoaConfig artoaWorkspace artoaDataInput; try artoaConfig = artoa.load.tomlini('artoa.ini'); @@ -16,6 +16,15 @@ if isempty(artoaConfig) error([mfilename ': artoa.ini has been found but is empty. Please use a valid artoa.ini!']); 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.edit.updateAvailablePlots(); diff --git a/lib/+artoa/+controller/+track/+trajectoryOutput/plotTopographicalLines.m b/lib/+artoa/+controller/+track/+trajectoryOutput/plotTopographicalLines.m index 5143680ec769b5821601361f9a22690fd2def9a6..551b44b768a7431b8ebcdd79bcc477bc429ecf4f 100644 --- a/lib/+artoa/+controller/+track/+trajectoryOutput/plotTopographicalLines.m +++ b/lib/+artoa/+controller/+track/+trajectoryOutput/plotTopographicalLines.m @@ -14,7 +14,8 @@ if ~artoa.controller.file.loadEtopoFile( ... end %% 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 @@ -22,9 +23,10 @@ topographical_line_values = artoaConfig.defaults.topographical_lines; axes(pAxesHandle); 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)) ... | (ischar(topographical_line_values(o)) && strcmp(strip(topographical_line_values(o)), '')) continue; @@ -35,13 +37,42 @@ for o = 1:length(topographicalLineHandles) else lineValue = topographical_line_values(o); end - [~, topographicalLineHandles{o}] = contourm( ... - artoaDataInput.etopo.Z, ... - artoaDataInput.etopo.refvec, ... - [lineValue, lineValue], ... - 'ShowText', 'on', ... - 'LabelSpacing', 400 ... - ); + + if use_ibcso + depth_index = find(artoaDataInput.ibcso.contourLevels == lineValue, 1); + if isempty(depth_index) + 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.']); + 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 warning('There was an error on plotting topographical lines. Kindly ignore this warning if your zoomed area does not contain any topograpical lines.'); end diff --git a/lib/+artoa/+controller/+track/+trajectoryOutput/tableTopographicalLinesEdit.m b/lib/+artoa/+controller/+track/+trajectoryOutput/tableTopographicalLinesEdit.m index 4a697344e2d8d4b231f652210421eb90bb02bb96..d49721e53be2b22c952f5a527d7663fdeb98d708 100644 --- a/lib/+artoa/+controller/+track/+trajectoryOutput/tableTopographicalLinesEdit.m +++ b/lib/+artoa/+controller/+track/+trajectoryOutput/tableTopographicalLinesEdit.m @@ -2,10 +2,10 @@ function [] = tableTopographicalLinesEdit(~, ~) %UPDATETABLEGENERATEDTRACKS Summary of this function goes here % Detailed explanation goes here -global artoaGui artoaWorkspace; +global artoaGui artoaWorkspace artoaConfig; %% Save to workspace -artoaWorkspace.trajectoryOutput.topographicalLines = artoaGui.trajectoryOutput.tableTopographicalLines.Data; +artoaConfig.topographical_lines.depth = artoaGui.trajectoryOutput.tableTopographicalLines.Data'; %% Plot if required if ~artoaWorkspace.trajectoryOutput.showTopographicalLines diff --git a/lib/+artoa/+controller/+track/+trajectoryOutput/updateGui.m b/lib/+artoa/+controller/+track/+trajectoryOutput/updateGui.m index 402917c5332b28fb4f4e30bbb07a58dad6a6950a..f25f9f72a8a9babda3ceeed7f690152a7b227455 100644 --- a/lib/+artoa/+controller/+track/+trajectoryOutput/updateGui.m +++ b/lib/+artoa/+controller/+track/+trajectoryOutput/updateGui.m @@ -2,7 +2,7 @@ function [] = updateGui() %UPDATEGUI Summary of this function goes here % Detailed explanation goes here -global artoaWorkspace artoaGui; +global artoaWorkspace artoaGui artoaConfig; if artoa.data.hasMember(artoaWorkspace, {'trajectoryOutput', 'updateTrackParameterWindow'}) artoaGui.trajectoryOutput.checkboxUpdateTrackParameterWindow.Value = ... @@ -42,7 +42,7 @@ else end if artoa.data.hasMember(artoaWorkspace, {'trajectoryOutput', 'topographicalLines'}) artoaGui.trajectoryOutput.tableTopographicalLines.Data = ... - artoaWorkspace.trajectoryOutput.topographicalLines; + artoaConfig.topographical_lines.depth'; else artoaGui.trajectoryOutput.checkboxShowTopographicalLines.Value = false; end