%%
OPT = struct(...
    'maindir_decc', 'd:\cornelisdenheijer\sources\dune_erosion_coastline_curvature\simulations\00000000\xbeach\',...
    'regexp_select_decc', 'run(40).*?0\\xb_sum\.nc' ...
    );

reference_erosion = 162.0591;
%% curvature
[~, ~, files] = dirlisting(OPT.maindir_decc);

ncfiles = files(~cellfun(@isempty, regexp(files, OPT.regexp_select_decc)));

for iradii = 1:length(ncfiles)
    ncfile = ncfiles{iradii};
    
    result(iradii) = decc_analyse(ncfile,...
        'phi_resolution', 1,...
        's', false,...
        'zb', true,...
        'contour', -2.2);
end

radii_decc = cellfun(@(x,y) repmat(x, size(y)), {result.radius}, {result.Ero}, 'UniformOutput', false);
radii_decc = [result.radius];
Ero = cellfun(@(x) nanmax([x; fliplr(x)]), {result.Ero},...
    'uniformoutput', false);
phi_decc = {result.phi};
ero_decc = horzcat(Ero{:})/reference_erosion;
