function [tz]=kh_alpha_tz(si,sf,ti,tf,pi,pf)
% function [tz]=kh_alpha_tz(si,sf,ti,tf,pi,pf)
%
% Caluclates alpha*ptmp'z (alpha*potential tempe change on pressure surfaces
% All terms need to be on neutral density levels.
%
% si=salinity initial (neutral density levels*profiles)
% sf=salinity final etc.
% ti= initial potnetial temperature (needs to be potential temperature)
%
% Designed for use in calculating terms from Bindoff and McDougall (1994).
% Equation from B&M (1994) p1143 (equation 13)
%
% Written by Kieran Helm (17-5-2007)

% Get midpoints
[sm tm pm]=kh_mid_points(si,sf,ti,tf,pi,pf);

% Calculate alpha
al=sw_alpha(sm,tm,pm,'ptmp');

% Calculate final and inital temperatures at mid point
% kh_interp removes or interpolated over NaNs
ti_pm=kh_interp(pi,ti,pm); % intial t at middle pressure
tf_pm=kh_interp(pf,tf,pm); % final t at middle pressure

% Multiple alpha*diffence in temp at mid pressure
tz=al.*[tf_pm-ti_pm];