function analyze_this(info, dirs)

% dimensions and grid
d = xb_read_dims;

% read input
xbi         = xb_read_input;

t           = d.t/3600;
t2          = cumsum(xs_get(xbi, 'bcfile.duration'))/3600;
tp          = 1./xs_get(xbi, 'bcfile.fp');
hrms        = xs_get(xbi, 'bcfile.Hm0')./sqrt(2);

% read output
xbo1        = xb_read_output(pwd, 'vars', {'H' 'zs'}, 'start', [0 1 0], 'length', [-1 1 1]);
xbo2        = xb_read_output(pwd, 'vars', {'zb'}, 'index', [0 d.globaltime-1]);
xbo3        = xb_read_output(pwd, 'vars', {'zb'}, 'stride', 100);
            
xbb         = xb_get_morpho(xbo3, 'level', 25);
xbp         = xs_peel(xbo1);

% convert to NAP
zsmax       = 3.9;
zsmin       = 0.93;
zs          = load('surge2.dat');
dz          = max(zs(:,2))-zsmax;

%% figure 1
f1=figure;

subplot(311);
plot(t,squeeze(xbp.zs(:,1,1))-dz,'k'); hold on;
plot(zs(:,1)/3600,zs(:,2)-dz,'color',[0.6 0.6 0.6],'LineWidth',3);
xlabel('time [h]'); ylabel('\eta [m]'); axis([0 t2(end) 0 5]); 

subplot(312);
plot(t,xbp.H(:,1,1),'k'); hold on;
plot(t2,hrms,'color',[0.6 0.6 0.6],'LineWidth',3);
xlabel('time [h]'); ylabel('H_{rms} [m]'); axis([0 t2(end) 0 12]);

subplot(313);
plot(t2,tp,'color',[0.6 0.6 0.6],'LineWidth',3);
xlabel('time [h]'); ylabel('T_p [s]'); axis([0 t2(end) 8 12]);

xb_write_plot(f1, dirs.output, 'fig1');

%% other figures

%xb_plot_profile(xbo2);

%xb_write_plot(gcf, dirs.output, 'fig2');

%set(gca,'XLim',[1000 1400]);

xb_plot_morpho(xbb);

xb_write_plot(gcf, dirs.output, 'fig3');

% remove all but the first and last outputs
for iv = 2:length(xbo2.data)
    if length(size(xbo2.data(iv).value)) == 3
        xbo2.data(iv).value = xbo2.data(iv).value([1 end],:,:);
    end
end

xb_plot_profile(xbo2)
title(['profiles ' info.test ], 'interpreter', 'none')
xb_write_plot(gcf, dirs.output, 'final_profiles')
end



