clearvars -except cmaps
clear global
close all

load('../indiv_proc/amp_struct_evaponly_dist.mat')
load('../indiv_proc/bin_struct_evaponly_dist.mat')

global_var

figure('Position',[0 0 1000 280])
tl=tiledlayout(1,2,'TileSpacing','compact');

binmean = load('ext_funs/sbm_binmean.txt')*2*1e6;
nkr=33;
krdrop=14;

time=amp_struct.time;
dt=time(2)-time(1);
t1=int32(1/dt);
t2=int32(10/dt);
t3=int32(20/dt);

bin_dist_t1=bin_struct.mass_dist(t1,1:nkr,24);
amp_dist_t1=amp_struct.mass_dist_init(t1+1,1:nkr,24);

bin_dist_t2=bin_struct.mass_dist(t2,1:nkr,24);
amp_dist_t2=amp_struct.mass_dist_init(t2+1,1:nkr,24);

bin_dist_t3=bin_struct.mass_dist(t3,1:nkr,24);
amp_dist_t3=amp_struct.mass_dist_init(t3+1,1:nkr,24);

nexttile
hold on

%shaded region
xx=binmean(13:krdrop)';
yy1=amp_dist_t1(13:krdrop);
yy2=amp_dist_t3(13:krdrop);
pt=patch([xx fliplr(xx)], [yy1 fliplr(yy2)], [.8 .8 .8],'edgecolor','none');
set(get(get(pt,'Annotation'),'LegendInformation'),'IconDisplayStyle','off');

plot(binmean,amp_dist_t1,'Color',color_order{3},'LineWidth',2)
plot(binmean,amp_dist_t2,'Color',color_order{3},...
   'LineWidth',2,'LineStyle','--')
plot(binmean,amp_dist_t3,'Color',color_order{3},...
   'LineWidth',2,'LineStyle',':')
hold off

title('(a) AMP-SBM')
l = legend('t = 1 s','t = 10 s','t = 20 s',...
   'Location','best');
l.FontWeight='bold';
rectangle('position',[binmean(13),amp_dist_t1(krdrop)/1.2,binmean(krdrop)-binmean(13),amp_dist_t1(13)*1.2],'facecolor',[0.1 0.1 0.1 0.1])

xlim([0 binmean(krdrop)])
ylim([1e-8 1e-3])
set(gca,'YScale','log')
set(gca,'fontsize',16)
grid

nexttile
hold on
%shaded region
xx=binmean(13:krdrop)';
yy1=bin_dist_t1(13:krdrop);
yy2=bin_dist_t3(13:krdrop);
pt=patch([xx fliplr(xx)], [yy1 fliplr(yy2)], [.8 .8 .8],'edgecolor','none');
set(get(get(pt,'Annotation'),'LegendInformation'),'IconDisplayStyle','off');
plot(binmean,bin_dist_t1,'Color',color_order{2},'LineWidth',2)
plot(binmean,bin_dist_t2,'Color',color_order{2},...
   'LineWidth',2,'LineStyle','--')
plot(binmean,bin_dist_t3,'Color',color_order{2},...
   'LineWidth',2,'LineStyle',':')

xlim([0 binmean(krdrop)])
ylim([1e-8 1e-3])
set(gca,'YScale','log')
hold off

title('(b) bin-SBM')
l = legend('t = 1 s','t = 10 s','t = 20 s',...
   'Location','best');
l.FontWeight='bold';
rectangle('position',[binmean(13),bin_dist_t3(krdrop)/1.2,binmean(krdrop)-binmean(13),bin_dist_t1(13)*1.2],'facecolor',[0.1 0.1 0.1 0.1])

xlabel(tl,'Diameter [\mum]','fontsize',18)
ylabel(tl,'Mass conc. [kg/kg/dlogD]    ','fontsize',18)
set(gca,'fontsize',16)
grid

% exportgraphics(gcf,'plots/10 evaponly_dist.png','Resolution',300)
exportgraphics(gcf,['plots/10 evaponly_dist.pdf'],'Resolution',300)
