%% Track spectral weight across the transition

set(0,'defaulttextInterpreter','latex')
set(groot, 'defaultAxesTickLabelInterpreter','latex'); set(groot, 'defaultLegendInterpreter','latex');

format long

font          = 'Bahnschrift';

% Load data
Data                       = load('D:/Results - Experiment/B2.42G/DropletsToStripes.mat', 'unique_scan_parameter_values', 'mean_sc', 'stderr_sc', 'mean_sw', 'stderr_sw');

dts_scan_parameter_values  = Data.unique_scan_parameter_values;
dts_mean_sc                = Data.mean_sc;
dts_stderr_sc              = Data.stderr_sc;
dts_mean_sw                = Data.mean_sw;
dts_stderr_sw              = Data.stderr_sw;

Data                       = load('D:/Results - Experiment/B2.42G/StripesToDroplets.mat', 'unique_scan_parameter_values', 'mean_sc', 'stderr_sc', 'mean_sw', 'stderr_sw');

std_scan_parameter_values  = Data.unique_scan_parameter_values;
std_mean_sw                = Data.mean_sw;
std_stderr_sw              = Data.stderr_sw;
std_mean_sc                = Data.mean_sc;
std_stderr_sc              = Data.stderr_sc;

% Normalize dts data
dts_min = min(dts_mean_sw);
dts_max = max(dts_mean_sw);
dts_range = dts_max - dts_min;
dts_mean_sw_norm = (dts_mean_sw - dts_min) / dts_range;
dts_stderr_sw_norm = dts_stderr_sw / dts_range;

% Normalize std data
std_min = min(std_mean_sw);
std_max = max(std_mean_sw);
std_range = std_max - std_min;
std_mean_sw_norm = (std_mean_sw - std_min) / std_range;
std_stderr_sw_norm = std_stderr_sw / std_range;

figure(1);
set(gcf,'Position',[100 100 950 750])
errorbar(dts_scan_parameter_values, dts_mean_sc, dts_stderr_sc, 'o--', ...
    'LineWidth', 1.5, 'MarkerSize', 6, 'CapSize', 5, 'DisplayName' , 'Droplets to Stripes');
hold on
errorbar(std_scan_parameter_values, std_mean_sc, std_stderr_sc, 'o--', ...
    'LineWidth', 1.5, 'MarkerSize', 6, 'CapSize', 5, 'DisplayName', 'Stripes to Droplets');
set(gca, 'FontSize', 14);   % For tick labels only
hXLabel = xlabel('\alpha (degrees)', 'Interpreter', 'tex');
hYLabel = ylabel('Spectral Contrast', 'Interpreter', 'tex');
hTitle = title('B = 2.42 G', 'Interpreter', 'tex');
legend
set([hXLabel, hYLabel], 'FontName', font)
set([hXLabel, hYLabel], 'FontSize', 14)
set(hTitle, 'FontName', font, 'FontSize', 16, 'FontWeight', 'bold');  % Set font and size for title
grid on

figure(2);
set(gcf,'Position',[100 100 950 750])
errorbar(dts_scan_parameter_values, dts_mean_sw, dts_stderr_sw, 'o--', ...
    'LineWidth', 1.5, 'MarkerSize', 6, 'CapSize', 5, 'DisplayName' , 'Droplets to Stripes');
hold on
errorbar(std_scan_parameter_values, std_mean_sw, std_stderr_sw, 'o--', ...
    'LineWidth', 1.5, 'MarkerSize', 6, 'CapSize', 5, 'DisplayName', 'Stripes to Droplets');
set(gca, 'FontSize', 14);   % For tick labels only
hXLabel = xlabel('\alpha (degrees)', 'Interpreter', 'tex');
hYLabel = ylabel('Spectral Weight', 'Interpreter', 'tex');
hTitle = title('B = 2.42 G', 'Interpreter', 'tex');
legend
set([hXLabel, hYLabel], 'FontName', font)
set([hXLabel, hYLabel], 'FontSize', 14)
set(hTitle, 'FontName', font, 'FontSize', 16, 'FontWeight', 'bold');  % Set font and size for title
grid on