
load Data_Validation/RioBranco-noBG-data_val_diel.mat
%%
%Creating a mat file with the processed data

label  = {label_45; label_59; label_69; label_71; label_73};
var_median_BVOCs = var_median(:,[4,6,7,8,9]);
file_name_mat = strcat(station,'teste_corr_plot','.mat');
save (file_name_mat, 'time_diel', 'var_median_BVOCs' , 'label' );

%%
%Creating a table with the results that will be the inputs for the corrplot
%function

 Results_Table = table(time_diel, var_median_BVOCs);
 file_name = strcat(station,'teste_corr_plot','.txt');
 writetable(Results_Table,file_name,'Delimiter','\t');
 
 Results_Table2 = table(var_median_BVOCs);
 file_name2 = strcat(station,'teste_corr_plot2','.txt');
 writetable(Results_Table2,file_name2,'Delimiter','\t');

% %  %teste
% %  Results_Table = table(Results_time,Results_date,Results_VOCs);
% %  file_name2 = strcat(station,'_2','.txt');
% %  writetable(Results_Table,file_name2,'Delimiter','\t'); 

%%
%Creating a table with variables that will be the inputs for the corrplot
%function

label_var  = {label_69; label_45; label_59; label_71; label_73};
Isoprene  = var_median(:,Idx69);
Acetaldehyde = var_median(:,Idx45);
Acetone = var_median(:,Idx59);
MVK = var_median(:,Idx71);
MEK = var_median(:,Idx73);
MTerp = var_median(:,Idx81);
Benzene = var_median(:,Idx79);
Toluene = var_median(:,Idx93);
Frags_A = var_median(:,Idx107);
time_stamp = num2str(time_diel);
TT = table(Isoprene, Acetaldehyde, Acetone, MVK, MEK, MTerp,Benzene, Toluene, Frags_A);

%%
corrplot(TT, 'testR','on')
[R,PValue] = corrplot(TT,'testR','on','tail','right');
% p-values for Pearson's correlation by transforming the correlation to create a t-statistic with numObs – 2 degrees of freedom. The transformation is exact when X is normal.
% PValue has pairwise p-values all less than the default 0.05 significance level
%%
%Creating a mask for the other plots
%mask = (time_PTRMS >= datenum(2018,10,7,0,0,0) & time_PTRMS < datenum(2018,10,10,0,0,0)); 
 mask = (time_PTRMS>= datenum(2018,11,1,0,0,0) & time_PTRMS < datenum(2018,11,7,0,0,0));
%%
label_var  = {label_69; label_45; label_59; label_71; label_73};
Isoprene  = vocs(mask,7);
Acetaldehyde = vocs(mask,4);
Acetone = vocs(mask,6);
MVK = vocs(mask,8);
MEK = vocs(mask,Idx73);
%time_stamp = num2str(time_diel);
TTT = table(Isoprene, Acetaldehyde, Acetone, MVK);
%TTT = table(time_diel, var_median(:,7),var_median(:,4), var_median(:,6),var_median(:,8),var_median(:,9));


%%
figure
scatter(Isoprene,Acetaldehyde,[],hour(time_PTRMS(mask)-datenum(0,0,0,5,0,0)))
colorbar
day_mask = datestr(datenum(2018,11,5,0,0,0));
title(['VOCs correlation','-',day_mask])
xlabel('Isoprene (ppb)')
ylabel('Acetaldehyde (ppb)')

%%
figure
scatter(Isoprene,MEK,[],hour(time_PTRMS(mask)-datenum(0,0,0,5,0,0)))
colorbar
day_mask = datestr(datenum(2018,11,5,0,0,0));
title(['VOCs correlation','-',day_mask])
xlabel('Isoprene (ppb)')
ylabel('MEK (ppb)')

%%
figure

scatter3(Isoprene,Acetaldehyde,hour(time_PTRMS(mask)-datenum(0,0,0,5,0,0)))

%%



