Calculations/Data-Analyzer/+Scripts/BECToDroplets/plotAnalysisResults.m

188 lines
7.7 KiB
Matlab

% --- User chooses which dataset to load ---
datasetIdx = 1; % <-- change this to 1, 2, 3, ...
datasetName = sprintf('Dataset_%d', datasetIdx);
% Detect the folder where this script is located and set that as the Base Directory
thisScriptPath = mfilename('fullpath');
[thisScriptDir, ~, ~] = fileparts(thisScriptPath);
baseDir = thisScriptDir; % override if needed
% Build path to dataset file
dataFile = fullfile(baseDir, "Results", "SavedData", datasetName + ".mat");
data = load(dataFile);
% Access dataset struct dynamically
datasetStruct = data.(datasetName);
compiled_results = datasetStruct.results;
scan_parameter_values = datasetStruct.scan_parameter_values;
% Load the original options used during analysis
options = datasetStruct.options; % exact options used for this dataset
options.font = 'Bahnscrift'; % override if needed
options.skipSaveFigures = false; % override if needed
%% ------------------ Create dataset-specific figure folder ------------------
figSaveDir = fullfile(baseDir,'Results', 'SavedFigures', datasetName);
if ~exist(figSaveDir, 'dir')
mkdir(figSaveDir);
end
%% ------------------ 1. Mean ± Std Plots ------------------
% Plot Radial Spectral Contrast
Plotter.plotMeanWithSE(scan_parameter_values, compiled_results.spectral_analysis_results.radial_spectral_contrast, ...
'Title', options.titleString, ...
'XLabel', 'B (G)', ...
'YLabel', 'Radial Spectral Contrast', ...
'FigNum', 1, ...
'FontName', options.font, ...
'SaveFileName', 'RadialSpectralContrast.fig', ...
'SaveDirectory', figSaveDir, ... % save figures inside dataset-specific folder
'SkipSaveFigures', options.skipSaveFigures);
% Plot Angular Spectral Weight
Plotter.plotMeanWithSE(scan_parameter_values, compiled_results.spectral_analysis_results.angular_spectral_weight, ...
'Title', options.titleString, ...
'XLabel', 'B (G)', ...
'YLabel', 'Angular Spectral Weight', ...
'FigNum', 2, ...
'FontName', options.font, ...
'SaveFileName', 'AngularSpectralWeight.fig', ...
'SaveDirectory', figSaveDir, ...
'SkipSaveFigures', options.skipSaveFigures);
% Plot Peak Offset Angular Correlation
Plotter.plotMeanWithSE(options.scan_reference_values, compiled_results.custom_g_results.max_g2_all_per_scan_parameter_value, ...
'Title', options.titleString, ...
'XLabel', 'B (G)', ...
'YLabel', '$\mathrm{max}[g^{(2)}_{[50,70]}(\delta\theta)]$', ...
'FigNum', 3, ...
'YLim', [0 1], ...
'FontName', options.font, ...
'SaveFileName', 'PeakOffsetAngularCorrelation.fig', ...
'SaveDirectory', figSaveDir, ...
'SkipSaveFigures', options.skipSaveFigures);
%% ------------------ 2. g²(θ) across transition ------------------
Plotter.plotG2(compiled_results.full_g2_results.g2_all, ...
compiled_results.full_g2_results.g2_error_all, ...
compiled_results.full_g2_results.theta_values, ...
options.scan_reference_values, ...
'rot_mag_field', ...
'Title', options.titleString, ...
'XLabel', '$\delta\theta / \pi$', ...
'YLabel', '$g^{(2)}(\delta\theta)$', ...
'FigNum', 4, ...
'FontName', options.font, ...
'SkipSaveFigures', options.skipSaveFigures, ...
'SaveFileName', 'G2ThetaAcrossTransition.fig', ...
'SaveDirectory', figSaveDir, ...
'Colormap', @Colormaps.coolwarm);
%% ------------------ 3. PDF of max g² across transition ------------------
Plotter.plotPDF(compiled_results.custom_g_results.max_g2_all_per_scan_parameter_value, options.scan_reference_values, ...
'Title', options.titleString, ...
'XLabel', 'B (G)', ...
'YLabel', '$\mathrm{max}[g^{(2)}]$', ...
'FigNum', 5, ...
'FontName', options.font, ...
'SkipSaveFigures', options.skipSaveFigures, ...
'SaveFileName', 'PDF_MaxG2AcrossTransition.fig', ...
'SaveDirectory', figSaveDir, ...
'NumPoints', 200, ...
'DataRange', [0 1.5], ...
'Colormap', @Colormaps.coolwarm, ...
'XLim', [min(options.scan_reference_values) max(options.scan_reference_values)]);
%% ------------------ 4. Cumulants across transition ------------------
Plotter.plotCumulants(options.scan_reference_values, ...
{compiled_results.custom_g_results.mean_max_g2, compiled_results.custom_g_results.var_max_g2, compiled_results.custom_g_results.skew_max_g2_angle, compiled_results.custom_g_results.fourth_order_cumulant_max_g2}, ...
'Title', 'Cumulants of Peak Offset Angular Correlation', ...
'XLabel', 'B (G)', ...
'FigNum', 6, ...
'FontName', options.font, ...
'MarkerSize', 6, ...
'LineWidth', 1.5, ...
'SkipSaveFigures', options.skipSaveFigures, ...
'SaveFileName', 'CumulantOfPeakOffsetAngularCorrelation.fig', ...
'SaveDirectory', figSaveDir);
%{
%% ------------------ 6. Average of Spectra Plots ------------------
Plotter.plotAverageSpectra(scan_parameter_values, ...
spectral_analysis_results, ...
'ScanParameterName', scan_parameter, ...
'FigNum', 7, ...
'ColormapPS', Colormaps.coolwarm(), ...
'Font', 'Bahnschrift', ...
'SaveFileName', 'avgSpectra.fig', ...
'SaveDirectory', figSaveDir, ...
'SkipSaveFigures', options.skipSaveFigures);
%% ------------------ 7. Compare quantities ------------------
% Load Droplets → Stripes data
Data = load(dtsFile, ...
'unique_scan_parameter_values', ...
'mean_max_g2_values', ...
'std_error_g2_values');
dts_scan_parameter_values = Data.unique_scan_parameter_values;
dts_mean_mg2 = Data.mean_max_g2_values;
dts_stderr_mg2 = Data.std_error_g2_values;
% Load Stripes → Droplets data
Data = load(stdFile, ...
'unique_scan_parameter_values', ...
'mean_max_g2_values', ...
'std_error_g2_values');
std_scan_parameter_values = Data.unique_scan_parameter_values;
std_mean_mg2 = Data.mean_max_g2_values;
std_stderr_mg2 = Data.std_error_g2_values;
% Prepare cell arrays for multiple datasets
scanValsCell = {dts_scan_parameter_values, std_scan_parameter_values};
meanValsCell = {dts_mean_mg2, std_mean_mg2};
stderrValsCell = {dts_stderr_mg2, std_stderr_mg2};
% Compare datasets
compareMultipleDatasets(scanValsCell, meanValsCell, stderrValsCell, ...
'FigNum', 8, ...
'FontName', 'Bahnschrift', ...
'MarkerSize', 6, ...
'LineWidth', 1.5, ...
'CapSize', 5, ...
'YLim', [0 1], ...
'Labels', {'Droplets → Stripes', 'Stripes → Droplets'}, ...
'Title', 'AngularCorrelation_Comparison', ...
'XLabel', 'B (G)', ...
'YLabel', '$\mathrm{max}[g^{(2)}_{[50,70]}(\delta\theta)]$', ...
'SkipSaveFigures', options.skipSaveFigures, ...
'SaveDirectory', figSaveDir, ...
'SaveFileName', 'AngularCorrelation_Comparison.fig');
%% ------------------ 8. Heatmaps ------------------
BFields = [2.35, 2.15, 2.0, 1.85, 1.7, 1.55, 1.4, 1.35];
% Heatmap of mean_max_g2_values
Plotter.plotHeatmap(compiled_results, options.scan_groups, BFields, 'mean_max_g2_values', ...
'Colormap', @sky, ...
'CLim', [0 1], ...
'XLabel', '\alpha (degrees)', ...
'YLabel', 'BField (G)', ...
'Title', '$\mathrm{max}[g^{(2)}_{[50,70]}(\delta\theta)]$', ...
'FigNum', 9, ...
'SaveFileName', 'Heatmap_MaxG2.fig', ...
'SaveDirectory', options.resultsDir);
% Heatmap of radial_spectral_contrast
Plotter.plotHeatmap(compiled_results, options.scan_groups, BFields, 'radial_spectral_contrast', ...
'Colormap', @sky, ...
'CLim', [0 0.008], ...
'XLabel', '\alpha (degrees)', ...
'YLabel', 'BField (G)', ...
'Title', 'Radial Spectral Contrast', ...
'FigNum', 10, ...
'SaveFileName', 'Heatmap_RadialSpectralContrast.fig', ...
'SaveDirectory', options.resultsDir);
%}