geoscatter(s.lat_(1,:),s.lon(1,:))
hold on
geoscatter(s.lat_(1,1),s.lon(1,1),'red')

%

BOG = loadBOG();

%

load('\\atlas.shore.mbari.org\projectlibrary\901805_Coastal_Biogeochemical_Sensing\Spray_Data\24802901\QC\24802901_QC.mat');

%

profile = 20;
trex = CO2SYSv3(s.ta_canb(:,profile), s.pHin(:,profile), 1, 3, s.psal(:,profile), s.tc(:,profile), 20, s.pres(:,profile), 0, s.sil_canb(:,profile), s.po4_canb(:,profile), 0, 0, 1, 10, 1, 2, 2); % convert from pHin to pH20atm
s.pH20atm = reshape(trex(:,20), size(s.pres(:,profile)));
s.pH20atm(s.pH20atm == -999) = NaN;

%

trex = CO2SYSv3(s.ta_canb(:,profile), s.pHin_canb(:,profile), 1, 3, s.psal(:,profile), s.tc(:,profile), 20, s.pres(:,profile), 0, s.sil_canb(:,profile), s.po4_canb(:,profile), 0, 0, 1, 10, 1, 2, 2); % convert from pHincanb to pH20atmcanb
s.pH20atm_canb = reshape(trex(:,20), size(s.pres(:,profile)));
s.pH20atm_canb(s.pH20atm == -999) = NaN;

%

BOGidx = 14211:14222;
figure(1)
TL = tiledlayout(1,4);
title(TL,'Spray x BOG Crossover','FontSize',12)

nexttile
% Plot Spray: GDF033 with a distinct color
plot(s.pH20atm,-s.depth(:,profile),'Color',[0.85 0.33 0.1],'LineStyle','-','LineWidth',1.5)
hold on

% Plot CanB in a nice blue color
plot(s.pH20atm_canb,-s.depth(:,profile),"Color",[0 0.45 0.74],'LineStyle','-','LineWidth',1.5)

% Scatter plot for MTBS Crossover with customized marker
scatter(BOG.pH20atm(BOGidx),BOG.DEPTH(BOGidx),15,'MarkerEdgeColor',[0.47 0.67 0.19],'MarkerFaceColor',[0.47 0.67 0.19],'LineWidth',1.5)

% Set Y-axis direction to reverse
set(gca,"Ydir","reverse")

% Add a legend with better readability
legend('Spray: GDF033', 'CanB','MTBS Crossover (>2km)', 'Location','southoutside')

% Add a title to the plot
title('pH20atm')

% Add grid for better readability
grid on

nexttile
plot(s.doxy(:,profile),-s.depth(:,profile),'Color',[0.85 0.33 0.1],'LineStyle','-','LineWidth',1.5)
hold on
scatter(BOG.doxy(BOGidx),BOG.DEPTH(BOGidx),15,'MarkerEdgeColor',[0.47 0.67 0.19],'MarkerFaceColor',[0.47 0.67 0.19],'LineWidth',1.5)
set(gca,"Ydir","reverse")
grid on
title('Doxy')
legend('\mumol/kg','Location','southoutside')

nexttile
plot(s.psal(:,profile),-s.depth(:,profile),'Color',[0.85 0.33 0.1],'LineStyle','-','LineWidth',1.5)
hold on
scatter(BOG.psal(BOGidx),BOG.DEPTH(BOGidx),15,'MarkerEdgeColor',[0.47 0.67 0.19],'MarkerFaceColor',[0.47 0.67 0.19],'LineWidth',1.5)
set(gca,"Ydir","reverse")
grid on
title('Salinity')
legend('PSU','Location','southoutside')

nexttile
plot(s.tc(:,profile),-s.depth(:,profile),'Color',[0.85 0.33 0.1],'LineStyle','-','LineWidth',1.5)
hold on
scatter(BOG.tc(BOGidx),BOG.DEPTH(BOGidx),15,'MarkerEdgeColor',[0.47 0.67 0.19],'MarkerFaceColor',[0.47 0.67 0.19],'LineWidth',1.5)
set(gca,"Ydir","reverse")
grid on
title('Temperature')
legend('^oC','Location','southoutside')

%

figure(1)
clf

% Define Super Mario theme colors
mario_red = [228, 0, 0]/255;         % Mario's hat
luigi_green = [78, 154, 6]/255;      % Luigi's shirt
peach_pink = [255, 182, 193]/255;    % Princess Peach's dress
mushroom_yellow = [252, 231, 3]/255; % Super Mushroom

% Plot with Super Mario-themed colors
plot(s.pH20atm, -s.depth(:,profile), 'Color', mario_red, 'LineWidth', 2)
hold on
plot(s.pH20atm_canb, -s.depth(:,profile), 'Color', luigi_green, 'LineWidth', 2)
scatter(BOG.pH20atm(BOGidx), BOG.DEPTH(BOGidx), 50, mushroom_yellow, 'filled')

% Set y-axis direction and legend
set(gca, 'YDir', 'reverse')
legend('Spray: GDF033', 'CanB', 'MTBS Crossover (>2km)', 'Location', 'southeast')

% Optionally, add a title
% title('pH20atm Comparison')

%

BOG2 = readtable('\\atlas\BOG_Archive\DataArchives\Regions\NortheastPacific\CruiseData\NutrientAnalysisRFA\RFA_DATA\All_2018.xlsx');% \\atlas\BOG_Archive\DataArchives\Regions\NortheastPacific\CruiseData\NutrientAnalysisRFA\RFA_DATA\all_2018.xls
BOG2.DATE_TIME.TimeZone = "UTC";

%

% pre adjustment
BOG2idx = 10343:10354;
figure(2)
clf
plot(s.opt(:,profile), -s.depth(:,profile), 'Color', mario_red, 'LineWidth', 2)
hold on
scatter(BOG2.FLUOR(BOG2idx), BOG2.DEPTH(BOG2idx), 50, mushroom_yellow, 'filled')
set(gca, 'YDir', 'reverse')
legend('Spray 029', 'MTBS Crossover (>2km)', 'Location', 'southeast')
title('FLOUR')

%

BOGidx = 14211:14222;
figure(3)
clf
plot(s.doxy(:,profile),-s.depth(:,profile),"Color",'k','LineStyle','-','LineWidth',1)
hold on
% plot(s.pH20atm_canb,-s.depth(:,profile),"Color",'blue','LineStyle','-','LineWidth',1)
scatter(BOG.doxy(BOGidx),BOG.DEPTH(BOGidx),'.')
set(gca,"Ydir","reverse")
legend('Spray: doxy','MTBS Crossover (>2km)',Location='southeast')
% title('pH20atm Comparison')

%

doxy_lag = s.doxy(:,20);
doxy_lag = circshift(doxy_lag,4,1);
doxy_lag = doxy_lag(5:end)
depth_lag = s.depth(:,20);
depth_lag = depth_lag(1:end-4);

%

figure(4)
clf
plot(doxy_lag,-depth_lag,"Color",'k','LineStyle','-','LineWidth',1)
hold on
scatter(BOG.doxy(BOGidx),BOG.DEPTH(BOGidx),'.')
plot(s.doxy(:,20),-s.depth(:,20),"Color",'r','LineStyle','--','LineWidth',1)
set(gca,"Ydir","reverse")
legend('Spray: doxy (lag -4)','MTBS Crossover (>2km)','no lag',Location='southeast')
title('O2 Lag Comparison')