function [rafosLimits, toaLimits] = getToaLimits(pWorkspace, pIncludeDeleted)
%GETTOALIMITS Finds the maximum and minimum of toa data.
%   If pIncludeDeleted equals to true, all values that are either selected or
%   manually deleted are used for estimation.

if nargin == 1
    pIncludeDeleted = false;
end

if pIncludeDeleted
    temperatureSelection = pWorkspace.statusTemperature ~= 0;
    pressureSelection = pWorkspace.statusPressure ~= 0;
else
    temperatureSelection = pWorkspace.statusTemperature == 1;
    pressureSelection = pWorkspace.statusPressure == 1;
end

selection = repmat(temperatureSelection & pressureSelection, pWorkspace.float.toaperphase, 1);

toaLimits = [min(pWorkspace.toaData.toa(selection)), max(pWorkspace.toaData.toa(selection))];
rafosLimits = [min(pWorkspace.toaData.toaDate(selection)), max(pWorkspace.toaData.toaDate(selection))];

end