%% Open data file
datafs2 = importdata('FigS2.csv');
timefs2 = duration(datafs2.textdata(2:end,1),"InputFormat","hh:mm");
prec_freq_event = datafs2.data(:,1);
prec_freq_nonevent = datafs2.data(:,2);
med_deltatheta_event = datafs2.data(:,3);
perc25_deltatheta_event = datafs2.data(:,4);
perc75_deltatheta_event = datafs2.data(:,5);
med_deltatheta_nonevent = datafs2.data(:,6);
perc25_deltatheta_nonevent = datafs2.data(:,7);
perc75_deltatheta_nonevent = datafs2.data(:,8);
%% Call new figure
figure("Position",[747,365,897,346])
figs2til = tiledlayout(1,2,"TileSpacing","compact","Padding","compact");
%% Prec. frequency comparison between day types
nexttile(1)
plot(timefs2,prec_freq_event,'r-','LineWidth',2.5)
hold on
plot(timefs2,prec_freq_nonevent,'b-','LineWidth',2.5)
ylabel('Prec. Frequency')
text(-0.22,0.97,'(a)','Units','normalized','FontSize',16,'FontWeight','bold');
box on
ytickformat('%.2f')
xtickformat('hh:mm')
xticks(hours(0:6:24))
xlim([hours(0) hours(24)])
grid on
%% Delta potential temperature comparison between day types
nexttile(2)
plot(timefs2,med_deltatheta_event,'-','LineWidth',2.5,'Color','r');
hold on
plot(timefs2,med_deltatheta_nonevent,'-','LineWidth',2.5,'Color','b');
fill([timefs2' fliplr(timefs2')],[perc25_deltatheta_event' fliplr(perc75_deltatheta_event')],'r','LineStyle','none','EdgeAlpha',0.3);
fill([timefs2' fliplr(timefs2')],[perc25_deltatheta_nonevent' fliplr(perc75_deltatheta_nonevent')],'b','LineStyle','none','EdgeAlpha',0.3);
alpha(0.4)
xticks(hours(0:6:24))
xtickformat('hh:mm')
xlim([hours(0) hours(24)])
text(-0.18,0.97,'(b)','Units','normalized','FontSize',16,'FontWeight','bold');
legend({'Event days','Non-event days'},'Location','best','Box','off')
ylabel('\Delta\theta_e (K)')
grid on