%pressure-recovery
clear

load p_salinity_Kehua_Liu_NaCl.mat
pressureSeries=load('pressureSeries.csv');
T_salinity=(0:0.2:20);
salinity=(0:0.5:40)/100;
T=(0:0.2:20);
N=length(pressureSeries);



for i=1:N
    phaseBoundaryS(i)=interpolation2(p_salinity,T_salinity,salinity,pressureSeries(i,2),1.1);
end

smoothS=rbsp(pressureSeries(:,1),phaseBoundaryS',0.1);
outputS=phaseBoundaryS'*100;

figure(1)
subplot(2,1,1)
semilogx(pressureSeries(:,1),pressureSeries(:,2))
xlabel('Time (hr)')
ylabel('Sample pressure (MPa)')
subplot(2,1,2)
semilogx(pressureSeries(:,1),phaseBoundaryS)%,pressureSeries(:,1),smoothS)
xlabel('Time (hr)')
ylabel('Phase boundary salinity (wt%)')

