clear all; close all;
%% Load 's' and 'Cal' from a deployment
basepath = '\\atlas.shore.mbari.org\ProjectLibrary\901805_Coastal_Biogeochemical_Sensing\Spray_Data';
missionID = '24A03401';
fileName = fullfile(basepath,missionID,'QC',[missionID,'_QC.mat']);
load(fileName);

%% Adjust pH correction
try
    s.pHcorr = (-Cal.deltapHfit.*s.Tadj) + s.pHin; % flipped sign of Cal.deltapHfit
catch
    s.pHcorr = (-s.deltapHfit.*s.Tadj) + s.pHin; % sometimes the var is saved to s not Cal
    disp('deltapHfit in s struct')
end
disp('Correction made successfully')
%% Save to new file location

savepath = 'C:\Users\bwerb\Documents\SprayDataCorrections\CorrectedQCFiles';
saveName = fullfile(savepath,[missionID,'_QC.mat']);

save(saveName,'s', 'Cal','CHL','missionID')
%%
clear all; close all;