data = readtable("\\atlas.shore.mbari.org\ProjectLibrary\901805_Coastal_Biogeochemical_Sensing\Wetlab_Sensor_Calibration\NanoFet\K0\02_10_26_id_10_6_16.csv");
%%
% Remove first n minutes of data
min_time = min(data.datetime);
cutoff_time = min_time + minutes(200);
data_filtered = data(data.datetime >= cutoff_time, :);

% Create figure
figure;

% Get unique gliderfet_id values
unique_ids = unique(data_filtered.gliderfet_id);

% Plot data for each gliderfet_id
hold on;
for i = 1:length(unique_ids)
    % Filter data for current gliderfet_id
    idx = data_filtered.gliderfet_id == unique_ids(i);
    
    % Plot
    plot(data_filtered.datetime(idx), data_filtered.vrse(idx), '-o', ...
         'DisplayName', sprintf('GliderFET %d', unique_ids(i)));
end
hold off;

% Add labels and formatting
xlabel('Date/Time');
ylabel('vrse');
title('vrse vs Time by GliderFET ID (First 5 min removed)');
legend('Location', 'best');
grid on;

% Optional: Rotate x-axis labels for better readability
xtickangle(45);
%%
% Remove first 200 minutes of data
min_time = min(data.datetime);
cutoff_time = min_time + minutes(200);
data_filtered = data(data.datetime >= cutoff_time, :);

% FIGURE 1: Raw data
figure;
unique_ids = unique(data_filtered.gliderfet_id);

hold on;
for i = 1:length(unique_ids)
    idx = data_filtered.gliderfet_id == unique_ids(i);
    plot(data_filtered.datetime(idx), data_filtered.vrse(idx), '.', ...
         'DisplayName', sprintf('GliderFET %d', unique_ids(i)));
end
hold off;

xlabel('Date/Time');
ylabel('vrse');
title('vrse vs Time by GliderFET ID (First 200 min removed)');
legend('Location', 'best');
grid on;
xtickangle(45);

% FIGURE 2: Normalized data (subtract first value from each sensor)
figure;

hold on;
for i = 1:length(unique_ids)
    % Filter data for current gliderfet_id
    idx = data_filtered.gliderfet_id == unique_ids(i);
    subset = data_filtered(idx, :);
    
    % Get first value and normalize
    first_value = subset.vrse(1);
    vrse_normalized = subset.vrse - first_value;
    
    % Plot normalized data
    plot(subset.datetime, vrse_normalized, '-.', ...
         'DisplayName', sprintf('GliderFET %d', unique_ids(i)));
end
hold off;

xlabel('Date/Time');
ylabel('vrse - vrse(t_0)');
title('Normalized vrse vs Time (First Value Subtracted)');
legend('Location', 'best');
grid on;
xtickangle(45);