%% XBeach advanced course: non-hydrostatic modelling
% Modeling of port hydrodyanmics with XBeach-NH
% v1.0  Nederhoff    Nov-18
clear all
close all
clc

%% 0. Settings
destout         = 'd:\TMP\runs\run_s100\';

%% 1. Read parameters
% Retrieve values from netcdf
fname            = [destout, 'xboutput.nc'];
point_zs         = nc_varget(fname, 'point_zs'); 
var_zs           = nc_varget(fname, 'zs_var'); 
zb               = nc_varget(fname, 'zb'); zb = squeeze(zb(1,1,:));
globalx          = nc_varget(fname, 'globalx'); 
globaly          = nc_varget(fname, 'globaly'); 
pointtime        = nc_varget(fname, 'pointtime');

% Compute Hrms
Hrms            = squeeze(real(sqrt(8 * var_zs)));

%% 2. Plot wave height along one transect
figure;
plot(globalx(132,:), Hrms(132,:)); 
hold on
xlabel('cross-shore distance [m]');
ylabel('elevation [m]')

%% 3. Plot spatially-varying wave height
figure;
pcolor(globalx, globaly, Hrms); shading flat;
hold on
xlabel('cross-shore distance [m]');
ylabel('longshore distance [m]')
colorbar; caxis([0 2]); 
