% Timeseries plots from Diadema-2016
%
caminho='C:\A\Diadema2016\processados\plots\';
caminho1='C:\A\Diadema2016\processados\avg5min\';
caminho2='C:\A\Diadema2016\processados\avg1h\';
lev0=true;
%
% Input data files
if (lev0)
C=load('C:\A\Diadema2016\processados\O3\Diadema-2016_ozone_clean.mat');
o3=C.outdata;
C=load('C:\A\Diadema2016\processados\SO2\Diadema-2016_SO2_clean.mat');
so2=C.outdata;
C=load('C:\A\Diadema2016\processados\NO2_CAPS\Diadema-2016_NO2_clean.mat');
no2=C.raw;
C=load('C:\A\Diadema2016\processados\CO_INNOVA\Diadema-2016_CO_clean.mat');
co=C.raw;
C=load('C:\A\Diadema2016\processados\CPC3772\Diadema-2016_cpc3772_clean.mat');
cpc=C.alldata;
C=load('C:\A\Diadema2016\processados\neph_aurora\Diadema-2016_neph_clean.mat');
scat=C.alldatang;
C=load('C:\A\Diadema2016\processados\maap\Diadema-2016_maap_clean.mat');
maap=C.data;
C=load('C:\A\Diadema2016\processados\smps\Diadema-2016_smps_clean.mat');
smps=C.alldata;
end
%
% Médias a cada 5 min ----------------------------------------------
disp('Médias a cada 5 min')
disp('--- Nephelometer')
first=datenum(2016,11,22,12,0,0);
last=ceil(scat(length(scat),1));
delta=5/60/24;
tol=0;
%
scat(1:53,:)=[];
data=[scat(:,1),scat(:,2:4),scat(:,5)./scat(:,2),scat(:,12)];
[~,scat5min]=fmedia_qualquer_coisa2(data,first,last,delta,tol);
scat5min(:,7:41)=[]; % time, scat450, scat525, scat635, bscatratio450, angstrom
%
disp('--- MAAP')
data=[maap(:,1),maap(:,7)];
[~,maap5min]=fmedia_qualquer_coisa2(data,first,last,delta,tol);
maap5min(:,3:8)=[];
maap5min(:,3)=maap5min(:,2)*6.6; % time, bc(ug/m3), abs(Mm-1)
%
scat5min(:,7)=nan(length(scat5min),1);
for i=1:length(scat5min)
if (mod(i,100)==0)
disp(i)
end
if(scat5min(i,4)>0)
p=polyfit(log10([450 525 635]),log10(scat5min(i,2:4)),1);
scat5min(i,7)=10^polyval(p,log10(637));
end
end
%
ssa(:,1)=scat5min(:,1);
ssa(:,2)=scat5min(:,7)./(scat5min(:,7)+maap5min(:,3));
ssa(maap5min(:,3)<0,2)=NaN;
ssa(scat5min(:,7)<0,2)=NaN;
%
disp('--- CPC')
data=cpc(:,1:2);
[~,cpc5min]=fmedia_qualquer_coisa2(data,first,last,delta,tol);
cpc5min(:,3:9)=[]; % time, cpc
%
disp('--- NO2')
data=no2(:,1:2);
[~,no25min]=fmedia_qualquer_coisa2(data,first,last,delta,tol);
no25min(:,3:9)=[]; % time, no2(ppb)
%
disp('--- SO2')
data=[so2(:,1),so2(:,8)];
[~,so25min]=fmedia_qualquer_coisa2(data,first,last,delta,tol);
so25min(:,3:9)=[]; % time, so2(ppb)
%
disp('--- O3')
data=[o3(:,1),o3(:,8)];
[~,o35min]=fmedia_qualquer_coisa2(data,first,last,delta,tol);
o35min(:,3:9)=[]; % time, so2(ppb)
%
disp('--- CO')
data=[co(:,1),co(:,2:4)];
[~,co5min]=fmedia_qualquer_coisa2(data,first,last,delta,tol);
co5min(:,5:size(co5min,2))=[]; % time, co2(ppm), co(ppm), ethanol
%
disp('--- SMPS')
data=[smps(:,1),smps(:,5),smps(:,2)];
[~,smps5min]=fmedia_qualquer_coisa2(data,first,last,delta,tol);
smps5min(:,4:size(smps5min,2))=[]; % time, N(cm-3), Dpg(nm)
%
% save([caminho1,'scat5min.mat'],'scat5min')
% save([caminho1,'maap5min.mat'],'maap5min')
% save([caminho1,'cpc5min.mat'],'cpc5min')
% save([caminho1,'smps5min.mat'],'smps5min')
% save([caminho1,'no25min.mat'],'no25min')
% save([caminho1,'so25min.mat'],'so25min')
% save([caminho1,'o35min.mat'],'o35min')
% save([caminho1,'co5min.mat'],'co5min')
%
% Médias horárias -----------------
disp('Médias horárias')
disp('--- Nephelometer')
first=datenum(2016,11,22,12,0,0);
last=ceil(scat(length(scat),1));
delta=1/24;
tol=0;
%
scat(1:53,:)=[];
data=[scat(:,1),scat(:,2:4),scat(:,5)./scat(:,2),scat(:,12)];
[~,scat1h]=fmedia_qualquer_coisa2(data,first,last,delta,tol);
scat1h(:,7:41)=[]; % time, scat450, scat525, scat635, bscatratio450, angstrom
%
disp('--- MAAP')
data=[maap(:,1),maap(:,7)];
[~,maap1h]=fmedia_qualquer_coisa2(data,first,last,delta,tol);
maap1h(:,3:8)=[];
maap1h(:,3)=maap1h(:,2)*6.6; % time, bc(ug/m3), abs(Mm-1)
%
scat1h(:,7)=nan(length(scat1h),1);
for i=1:length(scat1h)
if (mod(i,100)==0)
disp(i)
end
if(scat1h(i,4)>0)
p=polyfit(log10([450 525 635]),log10(scat1h(i,2:4)),1);
scat1h(i,7)=10^polyval(p,log10(637));
end
end
%
ssa1h(:,1)=scat1h(:,1);
ssa1h(:,2)=scat1h(:,7)./(scat1h(:,7)+maap1h(:,3));
ssa1h(maap1h(:,3)<0,2)=NaN;
ssa1h(scat1h(:,7)<0,2)=NaN;
%
disp('--- CPC')
data=cpc(:,1:2);
[~,cpc1h]=fmedia_qualquer_coisa2(data,first,last,delta,tol);
cpc1h(:,3:9)=[]; % time, cpc
%
disp('--- NO2')
data=no2(:,1:2);
[~,no21h]=fmedia_qualquer_coisa2(data,first,last,delta,tol);
no21h(:,3:9)=[]; % time, no2(ppb)
%
disp('--- SO2')
data=[so2(:,1),so2(:,8)];
[~,so21h]=fmedia_qualquer_coisa2(data,first,last,delta,tol);
so21h(:,3:9)=[]; % time, so2(ppb)
%
disp('--- O3')
data=[o3(:,1),o3(:,8)];
[~,o31h]=fmedia_qualquer_coisa2(data,first,last,delta,tol);
o31h(:,3:9)=[]; % time, so2(ppb)
%
disp('--- CO')
data=[co(:,1),co(:,2:4)];
[~,co1h]=fmedia_qualquer_coisa2(data,first,last,delta,tol);
co1h(:,5:size(co1h,2))=[]; % time, co2(ppm), co(ppm), ethanol
%
disp('--- SMPS')
data=[smps(:,1),smps(:,5),smps(:,2)];
[~,smps1h]=fmedia_qualquer_coisa2(data,first,last,delta,tol);
smps1h(:,4:size(smps1h,2))=[]; % time, N(cm-3), Dpg(nm)
%
% save([caminho2,'scat1h.mat'],'scat1h')
% save([caminho2,'maap1h.mat'],'maap1h')
% save([caminho2,'cpc1h.mat'],'cpc1h')
% save([caminho2,'smps1h.mat'],'smps1h')
% save([caminho2,'no21h.mat'],'no21h')
% save([caminho2,'so21h.mat'],'so21h')
% save([caminho2,'o31h.mat'],'o31h')
% save([caminho2,'co1h.mat'],'co1h')
%
%
% Mean diurnal cycle -------------------------
disp('Mean diurnal cycle')
data=[mod(o35min(:,1)-2/24,1),o35min(:,2),no25min(:,2),so25min(:,2),co5min(:,2:4)];
[~,dcycle]=fmedia_qualquer_coisa2(data,0,23.5/24,30/60/24,0);
%
lin=2:length(smps);
data=[mod(smps(lin,1)-2/24,1),smps(lin,5),smps(lin,2)];
[~,dcyclesmps]=fmedia_qualquer_coisa2(data,0,23.5/24,30/60/24,0);
%
data=[mod(maap5min(:,1)-2/24,1),maap5min(:,2)];
[~,dcyclebc]=fmedia_qualquer_coisa2(data,0,23.5/24,30/60/24,0);
%
% Plots ------------------------------------------------------
figure,subplot(3,1,1),plot(o35min(:,1),o35min(:,2),'g.'),grid on
ylabel('O_3 (ppb)','FontSize',12)
dynamicDateTicks
set(gca,'XLim',[first last])
set(gca,'YLim',[0 110])
title('Diadema 2016','FontSize',14)
subplot(3,1,2),plot(no25min(:,1),no25min(:,2),'b.'),grid on
ylabel('NO_2 (ppb)','FontSize',12)
dynamicDateTicks
set(gca,'XLim',[first last])
set(gca,'YLim',[0 50])
subplot(3,1,3),plot(so25min(:,1),so25min(:,2),'r.'),grid on
ylabel('SO_2 (ppb)','FontSize',12)
dynamicDateTicks
set(gca,'XLim',[first last])
set(gca,'YLim',[0 10])
saveas(gcf,[caminho,'Diadema_O3_NO2_SO2_tseries'],'jpg')
hgsave(gcf,[caminho,'Diadema_O3_NO2_SO2_tseries'])
%
figure,subplot(3,1,1),plot(co5min(:,1),co5min(:,2),'g.'),grid on
ylabel('CO_2 (ppm)','FontSize',12)
dynamicDateTicks
set(gca,'XLim',[first last])
set(gca,'YLim',[450 600])
title('Diadema 2016','FontSize',14)
subplot(3,1,2),plot(co5min(:,1),co5min(:,3),'k.'),grid on
ylabel('CO (ppm)','FontSize',12)
dynamicDateTicks
set(gca,'XLim',[first last])
set(gca,'YLim',[0.8 3.7])
subplot(3,1,3),plot(co5min(:,1),co5min(:,4),'b.'),grid on
ylabel('Ethanol (ppm)','FontSize',12)
dynamicDateTicks
set(gca,'XLim',[first last])
set(gca,'YLim',[-0.5 0.5])
saveas(gcf,[caminho,'Diadema_CO2_CO_ethanol_tseries'],'jpg')
hgsave(gcf,[caminho,'Diadema_CO2_CO_ethanol_tseries'])
%
figure
subplot(1,3,1),errorbar(dcycle(:,1),dcycle(:,2),dcycle(:,8),'g.'),grid on
title('Diadema 2016','FontSize',14)
%dynamicDateTicks
set(gca,'XLim',[0 1])
set(gca,'XTick',0:0.25:1)
set(gca,'XTickLabel',{'0:00','6:00','12:00','18:00','24:00'})
ylabel('O_3 (ppb)','FontSize',12),xlabel('Local Time','FontSize',12)
subplot(1,3,2),errorbar(dcycle(:,1),dcycle(:,3),dcycle(:,9),'b.'),grid on
%dynamicDateTicks
set(gca,'XLim',[0 1])
set(gca,'XTick',0:0.25:1)
set(gca,'XTickLabel',{'0:00','6:00','12:00','18:00','24:00'})
ylabel('NO_2 (ppb)','FontSize',12),xlabel('Local Time','FontSize',12)
subplot(1,3,3),errorbar(dcycle(:,1),dcycle(:,4),dcycle(:,10),'r.'),grid on
%dynamicDateTicks
set(gca,'XLim',[0 1])
set(gca,'XTick',0:0.25:1)
set(gca,'XTickLabel',{'0:00','6:00','12:00','18:00','24:00'})
ylabel('SO_2 (ppb)','FontSize',12),xlabel('Local Time','FontSize',12)
saveas(gcf,[caminho,'Diadema_O3_NO2_SO2_dcycle'],'jpg')
hgsave(gcf,[caminho,'Diadema_O3_NO2_SO2_dcycle'])
%
figure
subplot(1,2,1),errorbar(dcycle(:,1),dcycle(:,5),dcycle(:,11),'g.'),grid on
title('Diadema 2016','FontSize',14)
%dynamicDateTicks
set(gca,'XLim',[0 1])
set(gca,'XTick',0:0.25:1)
set(gca,'XTickLabel',{'0:00','6:00','12:00','18:00','24:00'})
ylabel('CO_2 (ppm)','FontSize',12),xlabel('Local Time','FontSize',12)
subplot(1,2,2),errorbar(dcycle(:,1),dcycle(:,6),dcycle(:,12),'k.'),grid on
%dynamicDateTicks
set(gca,'XLim',[0 1])
set(gca,'XTick',0:0.25:1)
set(gca,'XTickLabel',{'0:00','6:00','12:00','18:00','24:00'})
ylabel('CO (ppm)','FontSize',12),xlabel('Local Time','FontSize',12)
saveas(gcf,[caminho,'Diadema_CO2_CO_dcycle'],'jpg')
hgsave(gcf,[caminho,'Diadema_CO2_CO_dcycle'])
%
figure
subplot(1,3,1),errorbar(dcyclesmps(:,1),dcyclesmps(:,2),dcyclesmps(:,4),'m.'),grid on
title('Diadema 2016','FontSize',14)
set(gca,'YLim',[0 20000])
set(gca,'XLim',[0 1])
set(gca,'XTick',0:0.25:1)
set(gca,'XTickLabel',{'0:00','6:00','12:00','18:00','24:00'})
ylabel('SMPS Conc (cm^-^3)','FontSize',12),xlabel('Local Time','FontSize',12)
subplot(1,3,2),errorbar(dcyclesmps(:,1),dcyclesmps(:,3),dcyclesmps(:,5),'b.'),grid on
set(gca,'XLim',[0 1])
set(gca,'XTick',0:0.25:1)
set(gca,'XTickLabel',{'0:00','6:00','12:00','18:00','24:00'})
ylabel('MeanGeomDiam (nm)','FontSize',12),xlabel('Local Time','FontSize',12)
subplot(1,3,3),errorbar(dcyclebc(:,1),dcyclebc(:,2),dcyclebc(:,3),'k.'),grid on
set(gca,'XLim',[0 1])
set(gca,'XTick',0:0.25:1)
set(gca,'XTickLabel',{'0:00','6:00','12:00','18:00','24:00'})
ylabel('BC (ug/m^-^3)','FontSize',12),xlabel('Local Time','FontSize',12)
saveas(gcf,[caminho,'Diadema_SMPS_BC_dcycle'],'jpg')
hgsave(gcf,[caminho,'Diadema_SMPS_BC_dcycle'])
%
figure,subplot(3,1,1),plot(scat5min(:,1),scat5min(:,2),'b.'),grid on,hold on
plot(scat5min(:,1),scat5min(:,3),'g.')
plot(scat5min(:,1),scat5min(:,4),'r.'),hold off
ylabel('Scat (Mm^-^1)','FontSize',12)
dynamicDateTicks
set(gca,'XLim',[first last])
set(gca,'YLim',[0 500])
title('Diadema 2016','FontSize',14)
subplot(3,1,2),plot(maap5min(:,1),maap5min(:,2),'k.'),grid on
ylabel('BC (ug/m^3)','FontSize',12)
dynamicDateTicks
set(gca,'XLim',[first last])
set(gca,'YLim',[0 8])
subplot(3,1,3),plot(ssa(:,1),ssa(:,2),'m.'),grid on
ylabel('SSA','FontSize',12)
dynamicDateTicks
set(gca,'XLim',[first last])
set(gca,'YLim',[0.5 1])
saveas(gca,[caminho,'Diadema_neph_maap_tseries'],'jpg')
hgsave(gca,[caminho,'Diadema_neph_maap_tseries'])
%
figure,subplot(2,1,1),plot(scat5min(:,1),scat5min(:,6),'g.'),grid on
ylabel('Angstrom','FontSize',12)
dynamicDateTicks
set(gca,'XLim',[first last])
set(gca,'YLim',[0 3])
title('Diadema 2016','FontSize',14)
subplot(2,1,2),plot(scat5min(:,1),scat5min(:,5),'c.'),grid on
ylabel('BScatRatio 450','FontSize',12)
dynamicDateTicks
set(gca,'XLim',[first last])
set(gca,'YLim',[0 0.8])
saveas(gcf,[caminho,'Diadema_ang_bscat_tseries'],'jpg')
hgsave(gcf,[caminho,'Diadema_ang_bscat_tseries'])
%
dens=1.6; % particle density, in g/cm3
aux=find(diff(smps(:,1))>=0.5);
smps2(1,:)=smps(1,:);
for i=2:length(aux) % insere linhas em branco em períodos com mais de 12h sem dados
smps2=cat(1,smps2,smps(aux(i-1)+1:aux(i),:),nan(1,size(smps,2)));
end
smps2=cat(1,smps2,smps(aux(length(aux))+1:size(smps,1),:));
aux=find(isnan(smps2(:,1)));
smps2(aux,1)=smps2(aux-1,1)+0.4;
lin=2:length(smps2);
timesec=smps2(lin,1);
Z=smps2(lin,8:112);
diam=smps2(1,8:112);
[r,c]=find(Z<0); % replace negative values per 0
for k=1:length(r)
Z(r(k),c(k))=0;
end
clear r c
Znorm=Z;
for ii=1:size(Z,1)
Znorm(ii,:)=Z(ii,:)./max(Z(ii,:));
end
figure,subplot(3,1,1)
contourf(timesec,diam,Znorm','LineStyle','none'),grid on
set(gca,'YScale','log')
set(gca,'YTick',[20 50 100 200 400])
legend('normalized')%,colorbar
legend('Location','northwest')
title('Diadema 2016','FontSize',14)
ylabel('Diameter (nm)','FontSize',12)
dynamicDateTicks
set(gca,'XLim',[first last])
subplot(3,1,2),plot(smps2(lin,1),smps2(lin,5),'mo'),grid on,hold on
plot(cpc5min(:,1),cpc5min(:,2),'b.')
set(gca,'YLim',[0 30000])
legend('SMPS','CPC')
legend('Location','northwest')
dynamicDateTicks
set(gca,'XLim',[first last])
ylabel('Conc (cm^-^3)');
subplot(3,1,3),plot(smps2(lin,1),smps2(lin,7)*dens,'k.'),grid on
dynamicDateTicks
set(gca,'XLim',[first last])
set(gca,'YLim',[0 50])
ylabel('SMPS Mass (ug/m^-^3)','FontSize',12)
saveas(gcf,[caminho,'Diadema_SMPS_CPC_tseries'],'jpg')
hgsave(gcf,[caminho,'Diadema_SMPS_CPC_tseries'])
%
% Correlation plots
figure
subplot(2,2,1),plot(no25min(:,2),maap5min(:,2),'b.'),grid on,axis tight,hold on
data=[no25min(:,2),maap5min(:,2)];
data(isnan(data(:,1)),:)=[];
data(isnan(data(:,2)),:)=[];
set(gca,'YLim',[0 10])
p=polyfit(data(:,1),data(:,2),1);
x1=[0 45];
y1=polyval(p,x1);
plot(x1,y1,'-y')
legend('data',['y=', num2str(p(1),0),'*x + ', num2str(p(2),0)],'Location','southeast')
title('Diadema 2016','FontSize',14)
xlabel('NO_2 (ppb)','FontSize',12),ylabel('BC (ug.m^-^3)','FontSize',12)
subplot(2,2,2),plot(co5min(:,3),maap5min(:,2),'k.'),grid on,axis tight,hold on
data=[co5min(:,3),maap5min(:,2)];
data(isnan(data(:,1)),:)=[];
data(isnan(data(:,2)),:)=[];
set(gca,'YLim',[0 10])
p=polyfit(data(:,1),data(:,2),1);
x1=[1 3];
y1=polyval(p,x1);
plot(x1,y1,'-y')
legend('data',['y=', num2str(roundn(p(1),-2)),'*x + ', num2str(roundn(p(2),-1))],'Location','southeast')
xlabel('CO (ppm)','FontSize',12),ylabel('BC (ug.m^-^3)','FontSize',12)
subplot(2,2,3),plot(cpc5min(:,2),smps5min(:,2),'r.'),grid on,axis tight,hold on
set(gca,'XLim',[0 40000]),set(gca,'YLim',[0 40000])
data=[cpc5min(:,2),smps5min(:,2)];
data(isnan(data(:,1)),:)=[];
data(isnan(data(:,2)),:)=[];
p=polyfit(data(:,1),data(:,2),1);
x1=[0 40000];
y1=polyval(p,x1);
plot(x1,y1,'-y')
legend('data',['y=', num2str(roundn(p(1),-1)),'*x + ', num2str(roundn(p(2),0))],'Location','southeast')
ylabel('SMPS (cm^-^3)','FontSize',12),xlabel('CPC (cm^-^3)','FontSize',12)
saveas(gcf,[caminho,'Diadema_correlations'],'jpg')
hgsave(gcf,[caminho,'Diadema_correlations'])
%
%
% Data coverage plot
% O gráfico feito com base temporal de 5min fica muito pesado, até para o
% matlab. Melhor fazer médias horárias sobre as médias de 5 min.
if(datacoverage)
%filtros= % colar horarios da planilha de filtros
filtros(:,1)=datenum(filtros(:,2:7))+2/24;
% ascm times estimated from patrick's plot!
acsm(:,1)=cat(1,[datenum(2016,12,14,16,0,0):1/24:datenum(2016,12,17,8,0,0)]', ...
[datenum(2016,12,17,19,30,0):1/24:datenum(2016,12,18,14,45,0)]', ...
[datenum(2016,12,26,21,20,0):1/24:datenum(2016,12,30,06,15,0)]', ...
[datenum(2017,01,01,20,30,0):1/24:datenum(2017,01,02,21,30,0)]', ...
[datenum(2017,01,05,11,30,0):1/24:datenum(2017,01,17,09,45,0)]', ...
[datenum(2017,01,18,10,40,0):1/24:datenum(2017,01,25,17,00,0)]', ...
[datenum(2017,01,26,21,00,0):1/24:datenum(2017,01,27,12,00,0)]', ...
[datenum(2017,01,27,19,00,0):1/24:datenum(2017,01,28,18,00,0)]', ...
[datenum(2017,02,01,19,00,0):1/24:datenum(2017,02,06,04,00,0)]');
figure
plot(co1h(~isnan(co1h(:,2)),1),10,'ko'),grid on, hold on
plot(so21h(~isnan(so21h(:,2)),1),9,'ro')
plot(no21h(~isnan(no21h(:,2)),1),8,'bo')
plot(o31h(~isnan(o31h(:,2)),1),7,'go')
plot(filtros(:,1),6,'m*','MarkerSize',5)
plot(acsm(:,1),5,'c.')
plot(smps1h(~isnan(smps1h(:,2)),1),4,'r.')
plot(cpc1h(~isnan(cpc1h(:,2)),1),3,'g.')
plot(maap1h(~isnan(maap1h(:,2)),1),2,'k.')
plot(scat1h(~isnan(scat1h(:,2)),1),1,'b.')
dynamicDateTicks
legend('10-co','09-so2','08-no2','07-o3','06-filters','05-acsm','04-smps','03-cpc','02-maap','01-neph')
set(gca,'XLim',[datenum(2016,11,22) datenum(2017,2,16)],'FontSize',14)
saveas(gcf,[caminho,'Diadema_datacoverage'],'jpg')
hgsave(gcf,[caminho,'Diadema_datacoverage'])
end