clear data;
tableHeader = {'CastNum', 'DateNum', 'CTDPress', 'CTDTemp', 'CTDSal', 'InternalTemp', ...
          'InternalHumidity', 'SystemPowerV', 'SystemPowerI', ...
          'BackupBattV', 'Vrs', 'stdVrs', 'Vk', 'stdVk', 'Ik', 'Ib', 'pHTotal'};

data = array2table(merge_pH);
data.Properties.VariableNames = tableHeader;

DateTime = datetime(data.DateNum, 'ConvertFrom', 'datenum');
data = addvars(data,DateTime,'Before', 1);

numProfiles = max(data.CastNum);
% figure
% ax = gca;
% ax.YDir = 'reverse';
% hold on;
% for i=1:numProfiles
%     index = find(data.CastNum == i);
%     plot(data.pHTotal(index), data.CTDPress(index))
%     label(i) = "Profile " + compose("%2d", i);
% end
% legend(label)
% hold off

for i=1:numProfiles
    index = find(data.CastNum == i);
    pH = data.pHTotal(index);
    depth = data.CTDPress(index);
    dateNum = data.DateNum(index(1));
    hold on
    waterfall(pH', dateNum, depth')
end
ax = gca;
ax.ZDir = 'reverse'
