clearvars -except cmaps
clear global
close all

global_var

load('../indiv_proc/amp_struct_condonly_dist.mat')
load('../indiv_proc/bin_struct_condonly_dist.mat')

time = amp_struct.time;
z = amp_struct.z;
dt = time(2) - time(1);

close all
tplot = 45.5/dt;
zplot = 15;

figure('position', [0 0 800 400])
tl = tiledlayout(1, 5);

nexttile([1 2])
bar([amp_struct.mass_dist_init(tplot+1,:,zplot); bin_struct.mass_dist(tplot,:,zplot)]', ...
   'FaceAlpha', .7, 'LineWidth', 1)

xlim([0 5])
xticks([1:4])
xlabel('Bin number')
ylabel('Mass conc. [kg/kg/dlogD]')
legend('AMP-SBM', 'bin-SBM')
set(gca, 'FontSize', 16)
title('            (a) PSD','FontSize',18)

nexttile([1 3])
nanimagesc(time(1:9000), z, amp_struct.oflagc(1:9000,:)')
xlabel('Time [s]')
ylabel('Altitude [m]')
set(gca, 'YDir', 'normal')
cbar = colorbar;
cbar.Ticks = [-2/3 0 2/3];
cbar.TickLabels = {'No cloud', 'Success', 'Failure'}; 
colormap(cmaps.flag3)
set(gca, 'FontSize', 16)
title('               (b) # conc. conservation flags','fontsize',18)
%-.008 -.012
annotation('ellipse', [.462 .208 .025 .050], 'LineWidth', 2, ...
   'color', [.6 .6 .6])
annotation('line', [.4835 .356], [.251 .920], 'LineWidth', 2, ...
   'LineStyle', '--', 'color', [.6 .6 .6])
annotation('line', [.4745 .356], [.208 .140], 'LineWidth', 2, ...
   'LineStyle', '--', 'color', [.6 .6 .6])

% exportgraphics(gcf,'plots/pngs/8 condonly_dist.png', 'Resolution', 300)
exportgraphics(gcf,'plots/8 condonly_dist.pdf')
