Skip to content

SWAN learning tutorial

These notebooks show how to set up and run SWAN with rompy-swan, which extends rompy with everything specific to SWAN.

The collection has two parts:

  • Tutorial: an ordered path from zero to a nonstationary hindcast. Start here if you are new to rompy or rompy-swan.
  • Examples: self-contained notebooks on specific features. Pick the one you need and adapt it to your data.

All notebooks model the coast off Perth, Western Australia, on 1 January 2023, with ETOPO bathymetry, ERA5 winds and WAVEWATCH III boundary spectra.

Getting started

You need Python with rompy, rompy-swan, Jupyter, cartopy and wavespectra. See the installation guide.

The example data is in notebooks/swan/data/, so the notebooks run from a clone of this repository without further setup. Each notebook writes its files to a local _output/ folder, which is safe to delete.

To run SWAN, the notebooks use the public Docker image ghcr.io/rom-py/swan, built with NetCDF output, so you only need Docker installed and running. Cells that run SWAN are skipped if Docker is not available, and everything else still works. If you have your own SWAN installation, see Running SWAN.

Note

The pages on this site show the outputs stored in the notebooks, including the results of the SWAN runs. The documentation build does not run the notebooks or SWAN.

Tutorial

Work through these in order:

# Notebook You will learn
1 Your first SWAN model The whole workflow: grid, bathymetry, a wave boundary, physics, generate and run
2 The computational grid and spectrum Placing the grid, coordinates, the spectral grid and direction conventions
3 Input grids: bathymetry and wind Bathymetry and wind from datasets, and SWAN's stationary and nonstationary modes
4 Wave boundaries Parametric boundaries and spectra from a regional wave model
5 Choosing model settings Startup, physics and numerics, SWAN's defaults and rompy-swan's checks
6 A nonstationary hindcast A day of waves off Perth: time steps, output, checking the run and plotting results
7 Configuration as YAML and the rompy CLI The same model as a YAML file, generated and run from the command line

Examples

Grids and inputs

Notebook Shows
Grid types Rotated Cartesian grids, curvilinear and unstructured grids, grid geometry
Input grids Data sources, currents, water levels and other fields, data selection, hand-written input grids

Wave boundaries

Notebook Shows
Parametric boundaries Spectral shapes, sides and segments, varying parameters and TPAR files
Boundaries from spectra Boundnest1, BoundspecSide and BoundspecSegmentXY, selection options and checks
Nesting A coarse parent run providing the boundary of a finer child run

Model settings

Notebook Shows
Physics Source-term packages, breaking, friction, triads, set-up, obstacles, vegetation
Numerics Propagation schemes, convergence, and choosing the time step
Output Output locations, maps, tables and spectra, output times and quantities

Workflows

Notebook Shows
Stationary and nonstationary computations SWAN's modes and computations, and how their results differ
Hotstart and chained runs Continuing a run from a saved wave field
Running SWAN Local and Docker backends, MPI, and checking a run
Physics sensitivity Generating and comparing variants with different source-term packages