idx = 539;
[B] = loadBOG();
BOG2Plot = filterBOG(B, psaloffset.s, idx, 5, 1, 5, 1, 1, 1);
for idx = 1:546
    figure(1)
    clf
    plot(psaloffset.s.pHin(:,idx),psaloffset.s.pres(:,idx),Color='red')
    hold on
    plot(psaloffset.s.pHin_canb(:,idx),psaloffset.s.pres(:,idx),Color='blue')
    plot(nopsaloffset.s.pHin(:,idx),nopsaloffset.s.pres(:,idx),Color='red',LineStyle='--')
    plot(nopsaloffset.s.pHin_canb(:,idx),nopsaloffset.s.pres(:,idx),Color='blue',LineStyle='--')
    scatter(BOG2Plot.pHin,BOG2Plot.pres,Color='green')
    set(gca,'YDir','reverse')
    title(['prof ',num2str(idx)])
    ylim([0 600])
    legend('spray','CanB','Spray (no offset)','CanB (no offset)','BOG',Location='southeast')    %is the BOG data phtot or free??
    pause(.05)
end
%%
idx = 539;
[B] = loadBOG();
BOG2Plot = filterBOG(B, psaloffset.s, idx, 5, 1, 5, 1, 1, 1);
for idx = 1:546
    figure(2)
    clf
    tiledlayout(1,1)
    nexttile
    plot(nopsaloffset.s.pHin(:,idx),nopsaloffset.s.pres(:,idx),Color='red')
    hold on
    plot(nopsaloffset.s.pHcorr(:,idx),nopsaloffset.s.pres(:,idx),Color='blue')
    plot(psaloffset.s.pHin(:,idx),psaloffset.s.pres(:,idx),Color='red',LineStyle='--')
    plot(psaloffset.s.pHcorr_flipped(:,idx),psaloffset.s.pres(:,idx),Color='blue',LineStyle='--')
    plot(psaloffset.s.pHin_canb(:,idx),psaloffset.s.pres(:,idx),Color='black')
    legend('Spray pHin (nopsaloffset)','Spray pHin_corr (nopsaloffset)','Spray pHin','Spray pHin_corr','canb psal offset')
    title(['prof ',num2str(idx),' pHin'])
    % legend('Spray pHin','BOG (5 km, 5 years, May)',Location='southeast')
    ylim([0 600])
    set(gca,'YDir','reverse')
end