function [sz]=kh_beta_sz(si,sf,ti,tf,pi,pf)
% function [sz]=kh_beta_sz(si,sf,ti,tf,pi,pf)
%
% Caluclates beta*Salinity'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 (adapted equation 13)
%
% Written by Kieran Helm (17-5-2007)

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

% Calculate beta
bet=sw_beta(sm,tm,pm,'ptmp');

% Calculate final and inital salinity at mid point
% kh_interp removes or interpolated over NaNs
si_pm=kh_interp(pi,si,pm); % intial s at middle pressure
sf_pm=kh_interp(pf,sf,pm); % final s at middle pressure

% Multiple alpha*diffence in salinity at mid pressure
sz=bet.*[sf_pm-si_pm];