% Monthly Sed erosion plots

savefigs=1

%% Load
Mpath='F:\check_outs\tudelft\vlugtenburg\scripts\Matthieu'
Mpath='C:\Madeschipper\check_out\OpenEarthRawData\tudelft\vlugtenburg\scripts\Matthieu'

load([Mpath '\MakeTopo\AllVbeachsurveys.mat'])
load([Mpath '\MakeTopo\datesandpairs.mat'])



%% sed/Eros between consecutive surveys
for i_date=2:length(Vsurvey)

Vsurvey(i_date).SedEro.transects=Vsurvey(i_date).transects.elevation-Vsurvey(i_date-1).transects.elevation;
end

for i_date=2:length(Vsurvey)
 
figure(17)
set(gcf,'PaperPosition',[0  0  40 20])
 set(gcf,'Position',[1          31        1680         944])
 
 bw=30;
% survey line
plot([Vsurvey(i_date).transects.y(1) Vsurvey(i_date).transects.y(1)] ,[0  1200],':k')
hold all
for i_t=2:22
   plot([Vsurvey(i_date).transects.y(i_t) Vsurvey(i_date).transects.y(i_t)] ,[0  1200],':k')
end


for i_t=1:22
    x=Vsurvey(i_date).transects.cr_sh    ;
y=[Vsurvey(i_date).transects.y(i_t)-bw Vsurvey(i_date).transects.y(i_t)+bw]  ;
sedero=[Vsurvey(i_date).SedEro.transects(:,i_t) Vsurvey(i_date).SedEro.transects(:,i_t)];
pcolor(y,x,sedero)

end
shading interp
axis equal

x=Vsurvey(i_date).transects.cr_sh    ;
y=[Vsurvey(i_date).transects.y]  ;
z=[Vsurvey(i_date).transects.elevation(:,:) ];
[C,h] = contour(y,x,z,[-9:1:5],'--k');
clabel(C,h,'LabelSpacing',72,'FontSize',10,'Color','k','Rotation',0) ;


hold on
 
 
set(gca,'Xtick',[flipud(Vsurvey(i_date).transects.y)])
set(gca,'Xticklabel',num2str([flipud(Vsurvey(i_date).transects.y)],'%4.0f'))




%set(gca, 'XDir', 'reverse')
xlim([-50 1800])
xlabel('Alongshore distance [m]')

ylim([0 1200])
ylabel('Cross shore distance [m]')

caxis([-1 1])
ca=colormap(jet)
ca(29:35,:)=1
colormap(ca)
colorbar

set(gca,'position',[0.1300    0.1100    0.7750    0.8150])
legend('sed (r) /eros (b) [m]',[ 'contour ' Vsurvey(i_date).date([4:6 1:3 7:10])] )
title([ 'Sed Erosion survey  ' Vsurvey(i_date).date([1:3 7:10]) ' - ' Vsurvey(i_date-1).date([1:3 7:10]) ' , based on the transects'])


x0=30;           y0=1050;
    theta0 =-131.65534968173412+90;
h=100
w=100  
[x_ds3,y_ds3]=northarrow(h,w,x0,y0,theta0);



set(gcf,'renderer','zbuffer')
pause(0.1)
hold off

if savefigs==1
filename=[ 'Sed Erosion survey  ' Vsurvey(i_date).date([7:10]) '_' Vsurvey(i_date).date([1:2]) '_' Vsurvey(i_date).date([4:5]) ]
print ([ Mpath '\SedErosion\images\' filename '.jpg'],'-djpeg')
end
end