%Run allSites.m

%% Define Colors For Figures
blue = [57 106 177]./255;
red = [204 37 41]./255;
black = [83 81 84]./255;
green = [62 150 81]./255;
brown = [146 36 40]./255;
purple = [107 76 154]./255;
pretty_colors = [black;red;blue;green;brown;purple];
clear blue red black green brown purple

%% Fits Figure
figure;
tiledlayout("Vertical", "Padding","compact", "TileSpacing","compact")
%x points
x = 0:0.0002:(pi/ 2);
deg_x = rad2deg(x);

nexttile;%Plot Single Layer Figure
ff(1) = gca;
hold on

f = fits.exp{1};
plot(deg_x, 10.*log10(exponential_bscatter(x,f.diel,f.s,f.A)))

f = fits.gauss{1};
plot(deg_x, 10.*log10(gaussian_bscatter(x,f.diel,f.s,f.A)))
% [chi_squared_reduced, chi_squared] = chi_square(model_func, s, num_params);

f = fits.hagfors{1};
plot(deg_x, 10.*log10(hagfors(x,f.diel,f.s,f.A)))

plotBlackPoints

legend("Exp", "Gauss", "Hag")
fixaxes


nexttile %Plot Two Layer Breakdown Figure
ff(2) = gca;
hold on

f = fits.simpleTwoLayer{1};
[s_total, surf_specular, sub_specular, volume] = simple_two_layer(x,f.eps1,f.eps2,f.s1,f.s2,f.A);

plot(deg_x,10.*log10(s_total), 'k-')
plot(deg_x,10.*log10(surf_specular), '--', 'LineWidth', 1)
plot(deg_x,10.*log10(sub_specular), '-.', 'LineWidth', 1)
plot(deg_x,10.*log10(volume), ':', 'LineWidth', 1)

plotBlackPoints;

legend("Total Reflection", "Surface", "Subsurface", "Diffuse")
fixaxes

% nexttile %Plot Two Layer Prediction with limited data figure
% hold on
% ff(3) = gca;
% 
% f = fits.simpleTwoLayer{1,1};
% alt = simple_two_layer(x,f.eps1,f.eps2,f.s1,f.s2,f.A);
% f = fits.simpleTwoLayer{1,2};
% limited = simple_two_layer(x,f.eps1,f.eps2,f.s1,f.s2,f.A);
% 
% plot(deg_x,10.*log10(alt), 'k-')
% plot(deg_x,10.*log10(limited), ':')
% plotLimitedPoints(s, [2 25]);
% 
% legend("Complete Data Fit", "Limited Data Fit")
% fixaxes

%% Power_Phase_Plot figure



function fixaxes 
    xlabel('Incidence Angle (°)')
    ylabel('\sigma^{0} (dB)')
    xlim([0, 76]);
    ylim([-20, 17]);
    % xscale("log")
    fixfig
end
