Visualize results

Once your model finished running, it is time to have a look at the model output. Two types of output can be generated: Fortran and netCDF. The former type generates a series of DAT files as output, while the latter generates a single NC file with all data in it. The Matlab Toolbox supports both and there are no significant differences in the usage of the commands shown.

To have a quick view on your model output, use the xb_view command. This command works as well while the model is still running. Just run the command in the model directory, supply the model directory or supply the result structure from the xb_run command:

 xb_view;
xb_view('MyFirstXBeachModel/');
xb_view(xbr);

The result will be somethink like this:

xb_view

If you need to manipulate the output data or the visualization a bit more than the xb_view command offers, you will need to load the output data. The output is read using the xb_read_output command, which stores the data in an XBeach structure. The xb_peel command converts this structure to a regular structure with matrices with dimensions time, y and x. The dimensions itself are read by the xb_read_dims command. Try the following commands to figure out how it all works:

 xbo = xb_read_output;
xbo = xb_read_output('MyFirstXBeachModel/');
xbo = xb_read_output(xbr);

xbo = xb_read_output(pwd, 'vars', 'H');
xbo = xb_read_output(pwd, 'vars', {'H' 'zb'});
xbo = xb_read_output(pwd, 'vars', {'H' 'zb'}, 'length', 1);
xbo = xb_read_output(pwd, 'vars', {'H' 'zb'}, 'length', [1 1 -1]);
xbo = xb_read_output(pwd, 'vars', {'H' 'zb'}, 'length', [1 1 -1], 'start', 100);
xbo = xb_read_output(pwd, 'vars', {'H' 'zb'}, 'length', [1 1 -1], 'start', [100 2 1]);
xbo = xb_read_output(pwd, 'vars', {'H' 'zb'}, 'length', [1 1 -1], 'start', [100 2 1], 'stride', [1 1 5]);
xbo = xb_read_output(pwd, 'vars', '*_mean');

xbp = xb_peel(xbo);
xb_peel(xbo);

xbd = xb_read_dims;
xbd = xb_read_dims('MyFirstXBeachModel/');
xbd = xb_peel(xbp.DIMS);

plot(xbd.x, squeeze(xbp(end,1,:)));