function out = ttFromLR04(d)

% This function generates an exposure history by thresholding the LR04
% stack at a particular delta-o-18 threshold value. 
%
% See forwardTB.m for how the exposure history is defined. 
% one input arg -- the threshold d18O value
% output arg is suitable to be td.tt (see forwardTB.m). 
%
% Greg Balco -- Berkeley Geochronology Center -- May 2016

load LR04;

intt = [];

isb = lr04.d > d; % buried if delta-O-18 > threshold
for a = 2:length(isb);
    if isb(a) ~= isb(a-1);
        % A change occurred
        if isempty(intt) && isb(a); 
            % Case first intercept and burial is ending, 
            % suppress because site is buried now
            % do nothing
        else
            intt(end+1) = (lr04.t(a) + lr04.t(a-1))./2; 
        end;
    end;
end;

if mod(length(intt),2) == 1;
    % odd number of elements
    intt(end + 1) = intt(end) + 1; % random
end;

out = fliplr(intt.*1000); % Make in real years
    




