%% make plots of the monthly profiles and profile changes for each survey
Mpath='F:\check_outs\tudelft\vlugtenburg'

% figures save in folders per survey, and per profile

savefigs=1; %Toggle to save the images

%% load data
load([Mpath '\AllVbeachsurveys.mat'])
%%
for i_transect=1:3%22;
i_transect
for i_date=1:length(Vsurvey)
timestack(i_date,:)=Vsurvey(i_date).transects.elevation2(:,i_transect)';
x=Vsurvey(i_date).transects.cr_sh(:)    ;
date(i_date)=Vsurvey(i_date).matlabdate;
end

 % Timestack profile
for i_date=2%:length(Vsurvey);
i_date
    figure(13)
 set(gcf,'PaperPosition',[0  0  40 20])
 set(gcf,'Position',[20          160       1680/2         944/2])
plot(x,timestack(i_date-1,:),'b')
grid on

hold all
plot(x,timestack(i_date,:),'k')
SedEro=timestack(i_date,:)-timestack(i_date-1,:);
Sed=NaN(size(SedEro));
Sed(SedEro>=0.1)=SedEro(SedEro>=0.1);
Ero=NaN(size(SedEro));
Ero(SedEro<=-0.1)=SedEro(SedEro<=-0.1);
plot(x,SedEro,'Color',[0.6 0.6 0.6])
plot(x,Sed,'g','LineWidth',2)
plot(x,Ero,'r','LineWidth',2)


legend(['Profile ' datestr(date(i_date-1))],['Profile ' datestr(date(i_date))],'Monthly change','Accretion','Erosion')
title([ 'Profile ' num2str(i_transect) ', monthly change'])
set (gca,'Ytick',[-10:1:5])
ylim([-10 5])
xlim([0 1200])



xlabel('Cross-shore distance [m]')
ylabel('Elevation [m]')
pause(1)
hold off

if savefigs==1
dirname=['PerSurvey\' datestr(date(i_date),'YYYYmmdd') '\'];
filename=[ 'ProfileMonthlyChange' num2str(i_transect,'%02.0f') ];
print ([ Mpath '\scripts\Matthieu\ProfileAnalysis\images\' dirname filename '.jpg'],'-djpeg')

dirname=['PerProfile\' num2str(i_transect) '\'];
filename=[ 'ProfileMonthlyChange' datestr(date(i_date),'YYYYmmdd') ];
print ([ Mpath '\scripts\Matthieu\ProfileAnalysis\images\' dirname filename '.jpg'],'-djpeg')
end

end
end
