From 2b62443c863d9e2432b85d7c6cb33f93e06e3f54 Mon Sep 17 00:00:00 2001
From: Lewin Probst <info@emirror.de>
Date: Sun, 3 Nov 2019 10:33:16 +0100
Subject: [PATCH] Adjusted soundspeed calculations.

---
 lib/+artoa/+controller/+track/run.m       | 19 +++++++++----------
 lib/+artoa/+data/calculateSoundVelocity.m |  4 +---
 2 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/lib/+artoa/+controller/+track/run.m b/lib/+artoa/+controller/+track/run.m
index 495ad66..d00abfa 100644
--- a/lib/+artoa/+controller/+track/run.m
+++ b/lib/+artoa/+controller/+track/run.m
@@ -30,10 +30,6 @@ for i = 1:size(soundVelocity, 1)
     if strcmpi( ...
             artoaWorkspace.trackParameter.soundspeedMethodString, ...
             'manual' ...
-            ) ...
-        && strcmpi( ...
-            artoaWorkspace.trackParameter.trackingMethodString, ...
-            'hyperbolic' ...
             )
         soundVelocity(i, :) = [ ...
             artoaWorkspace.trackParameter.soundsourceCombinations.soundspeed1(i), ...
@@ -42,17 +38,20 @@ for i = 1:size(soundVelocity, 1)
         ];
     elseif strcmpi( ...
         artoaWorkspace.trackParameter.soundspeedMethodString, ...
-        'manual' ...
+        'soundsource file' ...
         )
-        soundVelocity(i, :) = ...
-            artoaWorkspace.trackParameter.soundsourceCombinations.soundspeed1(i);
+        % get soundsource names
+        soundsourceNames = strsplit(artoaWorkspace.trackParameter.soundsourceCombinations.soundsources{i});
+        % get soundspeed for every soundsource
+        for oName = 1:length(soundsourceNames)
+            soundVelocity(i, oName) = ...
+                artoaWorkspace.filteredSoundsources.(soundsourceNames{oName}).sound_speed;
+        end
     else
-        fnames = fieldnames(artoaWorkspace.filteredSoundsources);
         soundVelocity(i, :) = artoa.data.calculateSoundVelocity( ...
             artoaWorkspace.temperature(artoaWorkspace.statusTemperature == 1), ...
             artoaWorkspace.pressure(artoaWorkspace.statusPressure == 1), ...
-            artoaWorkspace.trackParameter.soundspeedMethodString, ...
-            artoaWorkspace.filteredSoundsources.(fnames{1}) ... % WHICH SOUNDSOURCE TO USE IF "soundsource" IS SELECTED??
+            artoaWorkspace.trackParameter.soundspeedMethodString ...
         );
     % TODO: IMPLEMENT OTHER SOUNDVELOCITY OPTIONS
     end
diff --git a/lib/+artoa/+data/calculateSoundVelocity.m b/lib/+artoa/+data/calculateSoundVelocity.m
index dd302a6..06499f6 100644
--- a/lib/+artoa/+data/calculateSoundVelocity.m
+++ b/lib/+artoa/+data/calculateSoundVelocity.m
@@ -1,4 +1,4 @@
-function [calculatedSoundVelocity] = calculateSoundVelocity(pTemperature, pPressure, pMethod, pSoundSource)
+function [calculatedSoundVelocity] = calculateSoundVelocity(pTemperature, pPressure, pMethod)
 %CALCULATESOUNDVELOCITY Calculates the sound velocity based on the given values.
 %   Parameters:
 %       pTemperature    The temperature array.
@@ -23,8 +23,6 @@ switch lower(pMethod) % del grosso is default
             calculatedSoundVelocity = 1490;
         end
         clear indices;
-    case 'soundsource'
-        calculatedSoundVelocity = pSoundSource.sound_speed;
     otherwise
         calculatedSoundVelocity = artoa.vendor.oceanstoolbox.sndspd( ...
             35, mean(pTemperature(~isnan(pTemperature))), mean(pPressure(~isnan(pPressure))), 'del grosso' ...
-- 
GitLab