A demonstration repository showcasing the use of Rompy for configuring and running SWAN (Simulating WAves Nearshore) models. This project provides tools and examples for ocean wave modeling with a focus on procedural and declarative configuration approaches.
This repository contains example configurations and code for running SWAN models using Rompy, a Python library that provides programmatic interfaces for ocean modeling. SWAN is a third-generation wave model that computes random, short-crested wind-generated waves in coastal regions and estuaries.
The project includes:
- Procedural configuration examples using Python code
- Declarative configuration examples using YAML
- Integration with ocean data sources (bathymetry, winds, wave spectra)
- Docker-based execution environment
- Jupyter notebooks for interactive modeling
- Python 3.8+
- Docker (for containerized execution)
- JupyterLab or Jupyter Notebook
- Clone the repository:
git clone <repository-url>
cd rompy-perth-demo- Create a virtual environment:
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate- Install dependencies:
pip install -r requirements.txtThe project includes both procedural and declarative examples:
-
Procedural Example: The notebook
examples/example_perth.ipynbdemonstrates how to programmatically build a SWAN model configuration using Python. -
Declarative Example: The YAML file
examples/example_perth.yamlshows how to configure a model using a declarative approach.
To run the notebook:
jupyter lab examples/example_perth.ipynbThe project includes a Dockerfile for containerized execution of SWAN models:
- Located at
docker/Dockerfile - Contains the SWAN model executable built from source
- Uses Ubuntu 20.04 as the base image
- Includes all necessary dependencies for execution
├── prax-notebook.yaml # Prax notebook configuration
├── docker/ # Docker configuration
│ └── Dockerfile # SWAN model Docker image
├── examples/ # Example notebooks and configurations
│ ├── example_perth.ipynb # Procedural example notebook
│ ├── example_perth.py # Procedural example as Python script
│ └── example_perth.yaml # Declarative example configuration
├── requirements.txt # Python dependencies
└── tests/ # Test data
- Configurable SWAN Models: Define and customize SWAN model parameters programmatically
- Multiple Configuration Approaches: Both procedural and declarative methods
- Data Integration: Connect with various oceanographic data sources
- Model Grid Management: Tools for defining and working with model grids
- Execution Backends: Support for local, Docker, and HPC execution
- Visualization: Built-in plotting and visualization capabilities
The Rompy library provides Python components that map to SWAN commands:
- Grid Configuration: CGRID component for defining model grids
- Physics: Components for wave generation, breaking, friction, and triads
- Boundary Conditions: Support for various boundary condition types
- Output Configuration: Define outputs including grids, points, and spectra
- Initial Conditions: Support for default, zero, parametric, and hotstart conditions
The project supports multiple execution backends:
- Local: Direct execution on the local machine
- Docker: Containerized execution for reproducibility
- HPC: High-performance computing cluster integration
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the terms specified in the repository.
- SWAN model developers for the underlying wave modeling engine
- Rompy developers for the Python interface to SWAN
- The oceanographic modeling community for providing valuable data sources