function slinger(A,B,D)
% Let op: De slinger wordt alleen geplot als er in siltprofiler_new_main.m
% als input file slingerplot.xls wordt opgegeven;
% in plaats van siltprofiler_main.xls. 

close all
z    = [-50:0.2:5];
t    = [];
c    = [];
sal  = [];
spm  = [];
chlo = [];
temp = [];
cbas = [4+26.0519/60 ;52+15.1497/60];

for k =37:81
    t     = [t,A(k).datenum];
    c     = [c,(cbas-[D(k).lon(1);D(k).lat(1)]).*100];
    sal   = [sal;  nan B(k).salt];
    spm   = [spm;  nan B(k).spm ];
    chlo  = [chlo; nan B(k).chlo];
    temp  = [temp; nan B(k).temp];

end
cc =  sqrt(abs(c(1,:)).^2+abs(c(2,:)).^2);
z  =  repmat(z,[length(t) 1]);
t  =  repmat(t,[length(z) 1])';
cc =  repmat(cc(1,:),[length(z) 1])';

%% Salinity

figure,
surf(t,cc,z,sal)
hold on
xlabel('time');datetick('x')
ylabel('cross shore [m]')
zlabel('z [m]')
title('Cross shore Salinity Profile near Noordwijk 30 July 2009')
shading interp
set(gca,'ydir','reverse')
colorbarwithvtext('salinity [psu]')
view(135,20)
Axis([t(2) t(end) 0 30 -20 0])
set(gcf,'renderer','zbuffer'); % default opengl rounds time
%tickmap('y')
%% Chlorophyl

figure,
surf(t,cc,z,chlo)
hold on
Axis([t(2) t(end) 0 30 -20 0])
xlabel('time');datetick('x')
ylabel('cross shore [m]')
zlabel('z [m]')
title('Cross shore Chlorophyl Profile near Noordwijk 30 July 2009')
shading interp
set(gca,'ydir','reverse')
colorbarwithvtext('Cholorphyl [ug/l]')
view(135,20)
set(gcf,'renderer','zbuffer'); 
%% Temperature

figure,
surf(t,cc,z,temp)
hold on
Axis([t(2) t(end) 0 30 -20 0])
xlabel('time');datetick('x')
ylabel('cross shore [m]')
zlabel('z [m]')
title('Cross shore Temperature Profile near Noordwijk 30 July 2009')
shading interp
set(gca,'ydir','reverse')
colorbarwithvtext('Temperature [degC]')
view(135,20)
set(gcf,'renderer','zbuffer'); 
%% SPM
figure,
myscale=[1e0 1e2];
surf(t,cc,z,log10(spm))
hold on
Axis([t(2) t(end) 0 30 -20 0])
xlabel('time');datetick('x')
ylabel('cross shore [m]')
zlabel('z [m]')
title('Cross shore SPM Concentrations [mg/l] near Noordwijk 30 July 2009')
shading interp
set(gca,'ydir','reverse')
colorbarwithvtext('SPM [mg/l]')
view(135,20)
set(gcf,'renderer','zbuffer'); 
h=colorbar;
caxis(myscale)
ticks_wanted=unique([myscale(1),get(h,'YTick'),myscale(2)]);
caxis(log10(myscale))
set(h,'YTick',log10(ticks_wanted));
set(h,'YTickLabel',ticks_wanted)
