%% Art3_v6_Fig4.m

% (C) Roeland C. van de Vijsel
% NIOZ Yerseke, The Netherlands
% Script to make the subplots Fig. 4i and 4j.
% V1 - 19/04/2021: first complete version
% V2 - 28/09/2021: adjusted plots: y-axis starts at 0

clear all
close all
clc

%%

Diam = 35*10^-3; % Syringe inner diameter (m)
Area = pi*(Diam/2)^2; % Sampled surface area (m^2)

%%
VAR = 'CHLA';
summary = csvread(['output/',VAR,'_summary.csv'],1,2);

% Convert total content (micro-gram) into gram per m2
Con_mea = summary(1,2)/Area/10^6;
Fla_mea = summary(2,2)/Area/10^6;
Hol_mea = summary(3,2)/Area/10^6;
Hum_mea = summary(4,2)/Area/10^6;

Con_sem = summary(1,4)/Area/10^6;
Fla_sem = summary(2,4)/Area/10^6;
Hol_sem = summary(3,4)/Area/10^6;
Hum_sem = summary(4,4)/Area/10^6;

X1 = [0.5 1.5 2.5 3.5];
Y1 = [Hol_mea,Fla_mea,Hum_mea,Con_mea];
Z1 = [Hol_sem,Fla_sem,Hum_sem,Con_sem];

disp([VAR, ' Hollow: ', num2str(Y1(1)),' +- ',num2str(Z1(1))])
disp([VAR, ' Flat: ',   num2str(Y1(2)),' +- ',num2str(Z1(2))])
disp([VAR, ' Hummock: ',num2str(Y1(3)),' +- ',num2str(Z1(3))])
disp([VAR,' Control: ', num2str(Y1(4)),' +- ',num2str(Z1(4))])
%%
VAR = 'orgC';
summary = csvread(['output/',VAR,'_summary.csv'],1,2);

% Convert total content (gram) into gram per m2
Con_mea = summary(1,2)/Area;
Fla_mea = summary(2,2)/Area;
Hol_mea = summary(3,2)/Area;
Hum_mea = summary(4,2)/Area;

Con_sem = summary(1,4)/Area;
Fla_sem = summary(2,4)/Area;
Hol_sem = summary(3,4)/Area;
Hum_sem = summary(4,4)/Area;

X2 = [0.5 1.5 2.5 3.5];
Y2 = [Hol_mea,Fla_mea,Hum_mea,Con_mea];
Z2 = [Hol_sem,Fla_sem,Hum_sem,Con_sem];

disp([VAR, ' Hollow: ', num2str(Y2(1)),' +- ',num2str(Z2(1))])
disp([VAR, ' Flat: ',   num2str(Y2(2)),' +- ',num2str(Z2(2))])
disp([VAR, ' Hummock: ',num2str(Y2(3)),' +- ',num2str(Z2(3))])
disp([VAR,' Control: ', num2str(Y2(4)),' +- ',num2str(Z2(4))])
%%
lw = 2;
fs = 17;

%% Plot CHLA
close(figure(1));figure(1)
bar(X1,Y1,'FaceColor',[0.6 0.6 0.6],'EdgeColor',[0 0 0]); hold on
errorbar(X1,Y1,Z1,'.k','LineWidth',lw)
set(gca,'xtick',X1,'xticklabel',{'hollow','flat','hummock','control'},'FontSize',fs)
% axis([0 4 1 2.])
axis([0 4 0 2.])
grid minor
ylabel('Chl-a density [g/m^2]')
% legend('Chlorophyll-a','Location','NorthWest')
pbaspect([3 1 1])
saveas(gcf,'Art3_v6_Fig4_CHLA.pdf')

%% Plot orgC
close(figure(2));figure(2)
bar(X2,Y2/1000,'FaceColor',[0.6 0.6 0.6],'EdgeColor',[0 0 0]); hold on
errorbar(X2,Y2/1000,Z2/1000,'.k','LineWidth',lw)
set(gca,'xtick',X2,'xticklabel',{'hollow','flat','hummock','control'},'FontSize',fs)
% axis([0 4 1.05e3 1.35e3])
axis([0 4 0 1.4])
grid minor
% ylabel('Org. C density [g/m^2]')
ylabel('Org. C density [kg/m^2]')
% legend('Organic carbon','Location','NorthWest')
pbaspect([3 1 1])
saveas(gcf,'Art3_v6_Fig4_orgC.pdf')
