%% 26221001
g = Spray2Data('26221001');
g.getpHCal;
g.forceProcess = 1;
g.recalccarb = 1; % temp
g.downloadSat = 0;
g.savefigure = 0;
g.sendEmails = 0;
g.updateODSS = 0;
g.applyphcorr = 1;
g.process_full_pipeline;
%%
%%
phin_delta_esper = s.pHin - s.pHin_esper;
phin_delta_canb = s.pHin - s.pHin_canb;
%%
depth = mean(s.depth,2,"omitmissing");
phin_delta_esper_mn = mean(phin_delta_esper,2,"omitmissing");
phin_delta_canb_mn = mean(phin_delta_canb,2,"omitmissing");
%%
fig = figure;
scatter(phin_delta_esper_mn,depth)
hold on
scatter(phin_delta_canb_mn,depth)
axis ij
legend('esper','canb')
title('pHin - pHin_Estimate','Interpreter','none')
subtitle('GFET005, DF432, Spray2 SN210')
%%
k2 = g.pHcal.k2_fp_c0;
Pcoefs = [g.pHcal.fp_k1,g.pHcal.fp_k2,g.pHcal.fp_k3,...
    g.pHcal.fp_k4,g.pHcal.fp_k5,g.pHcal.fp_k6]';
d = 800;
prof = 70;
idepth = s.depth == d;
vrse = s.vrse(idepth);
pres = s.pres(idepth);
tc = s.tc(idepth);
psal = s.psal(idepth);
pHin_esper = s.pHin_esper(idepth);
pHin_canb = s.pHin_canb(idepth);
for prof = 1:length(s.lat)
    k0_esper(prof) = k0frompH(vrse(prof),pres(prof),tc(prof),psal(prof),pHin_esper(prof),k2,Pcoefs);
    k0_canb(prof) = k0frompH(vrse(prof),pres(prof),tc(prof),psal(prof),pHin_canb(prof),k2,Pcoefs);
end
k0_esper_mn = mean(k0_esper,"omitmissing");
k0_canb_mn = mean(k0_canb,"omitmissing");

sprintf('ESPER mean k0: %d',k0_esper_mn)
sprintf('CANB mean k0: %d',k0_canb_mn)
