function [soundvelocity] = selectSoundspeed()
%SELECTSOUNDSPEED Summary of this function goes here
%   Detailed explanation goes here

global artoaWorkspace;

%% Get required variables
soundsourceNames = fieldnames(artoaWorkspace.filteredSoundsources);
trackParameter = artoa.data.getMember(artoaWorkspace, {'trackParameter'}, false);
soundspeedTable = artoa.data.getMember(artoaWorkspace, {'editOffsets', 'soundspeed'}, false);

%% Get used method
if ~islogical(trackParameter)
    method = trackParameter.soundspeedMethodString;
else
    method = 'del grosso';
end

%% Fill with manual values or NaN
if ~islogical(soundspeedTable)
    initMatrix = repmat(soundspeedTable{'Soundspeed', 'Empirical'}, length(soundsourceNames), 1);
else
    initMatrix = NaN(length(soundsourceNames), 1);
end

%% Initialize table
soundvelocity = table(initMatrix, 'RowNames', soundsourceNames);

%% If manual has been chosen, we are ready
if strcmpi(method, 'manual')
    return;
end

%% Get every velocity for each soundsource
if strcmpi(method, 'soundsource file')
    for i = 1:length(soundsourceNames)
        soundvelocity{soundsourceNames{i}, 1} = ...
            artoaWorkspace.filteredSoundsources.(soundsourceNames{i}).sound_speed;
    end
    return;
end

soundvelocity{:, :} = artoa.data.calculateSoundVelocity( ...
    artoaWorkspace.temperature(artoaWorkspace.statusTemperature == 1), ...
    artoaWorkspace.pressure(artoaWorkspace.statusPressure == 1), ...
    method ...
);


end

