function [rafosLimits, pressureLimits] = getPressureLimits(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
    selection = pWorkspace.statusPressure ~= 2;
else
    selection = true(size(pWorkspace.statusPressure));
end

nanFilter = ~isnan(pWorkspace.rafosDate) & ~isnan(pWorkspace.pressure);

selection = selection & nanFilter;

pressureLimits = [min(pWorkspace.pressure(selection)), max(pWorkspace.pressure(selection))];
rafosLimits = [min(pWorkspace.rafosDate(selection)), max(pWorkspace.rafosDate(selection))];

end

