for irun = 24

    ncfile = ['p:\1002266-xbeach\coastal_curvature\simulations\00000000\xbeach\run' num2str(irun) '\radius01900\xboutput.nc'];
    xb = xb_read_output(ncfile,...
        'vars', {'DIMS' 'Susg_mean' 'Svsg_mean' 'Subg_mean' 'Svbg_mean' 'zb' 'dzav'},...
        'length', 6);
    save(fullfile('d:\heijer\sources\dune_erosion_coastline_curvature\matlab\', sprintf('run%02i.mat', irun)), 'xb');
end
%%
for irun = 24
    load(fullfile('d:\heijer\sources\dune_erosion_coastline_curvature\matlab\', sprintf('run%02i.mat', irun)));
    xbo = xb_get_sedbal(xb, 'margin', 1, 't', 3610);
    fprintf('\nrun%02i\n', irun)
%     xb_show(xbo)
    x   = xb_get(xb, 'DIMS.globalx_DATA');
    y   = xb_get(xb, 'DIMS.globaly_DATA');
    c = xb_get(xbo, 'bal_DATA.cell');
    
    for var = {'tstart' 'time' 'bal' 'sed' 'ero' 'trans'}
        fprintf('%s & %.0f \\\\\n', var{1}, xb_get(xbo, var{1}));
    end
    
    figure
    pcolor(x,y,c);
    shading flat;
    colorbar
    title(sprintf('sediment balance run%02i @t = 1000 s', irun))
    fname = sprintf('sb_run%02i', irun);
%     saveas(gcf, [fname '.fig'])
end
% xbo = xb_get_sedbal(xb);
% xb_show(xbo)