XBEACH declarative example¶
In this notebook we will define a XBEACH workspace entirely from yaml file
In [1]:
Copied!
%load_ext autoreload
%autoreload 2
%load_ext autoreload
%autoreload 2
In [2]:
Copied!
from pathlib import Path
from datetime import datetime, timedelta
import yaml
import pandas as pd
import xarray as xr
import matplotlib.pyplot as plt
import warnings
warnings.filterwarnings("ignore")
from pathlib import Path
from datetime import datetime, timedelta
import yaml
import pandas as pd
import xarray as xr
import matplotlib.pyplot as plt
import warnings
warnings.filterwarnings("ignore")
Instantiate model¶
Use a fully-defined config from yaml to instantiate ModelRun with the runtime parameters and the config definition
In [3]:
Copied!
# Uncoment below to view the contents of the yaml file
# !cat example_declarative.yml
# Uncoment below to view the contents of the yaml file
# !cat example_declarative.yml
In [4]:
Copied!
from rompy.model import ModelRun
conf = yaml.load(open("example_declarative.yml"), Loader=yaml.Loader)
modelrun = ModelRun(**conf)
from rompy.model import ModelRun
conf = yaml.load(open("example_declarative.yml"), Loader=yaml.Loader)
modelrun = ModelRun(**conf)
QC config¶
Plot model grid and data to QC before generating the workspace
In [5]:
Copied!
# Model grid
ax = modelrun.config.grid.plot(scale="f")
# Model grid
ax = modelrun.config.grid.plot(scale="f")
In [6]:
Copied!
# Model bathy
tmpdir = Path("tmp")
tmpdir.mkdir(exist_ok=True)
# Generate the bathymetry data
xfile, yfile, depfile, grid_extended = modelrun.config.bathy.get(
destdir=tmpdir, grid=modelrun.config.grid
)
# Load the bathymetry data
dset = xr.Dataset.xbeach.from_xbeach(depfile, grid_extended)
# Plot the bathymetry data
dset.xbeach.plot_model_bathy(grid_extended, posdwn=False)
# Model bathy
tmpdir = Path("tmp")
tmpdir.mkdir(exist_ok=True)
# Generate the bathymetry data
xfile, yfile, depfile, grid_extended = modelrun.config.bathy.get(
destdir=tmpdir, grid=modelrun.config.grid
)
# Load the bathymetry data
dset = xr.Dataset.xbeach.from_xbeach(depfile, grid_extended)
# Plot the bathymetry data
dset.xbeach.plot_model_bathy(grid_extended, posdwn=False)
Generate the workspace¶
In [7]:
Copied!
modelrun()
modelrun()
2025-10-02 13:26:16 [INFO] rompy.model : ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
2025-10-02 13:26:16 [INFO] rompy.model : ┃ MODEL RUN CONFIGURATION ┃
2025-10-02 13:26:16 [INFO] rompy.model : ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
2025-10-02 13:26:16 [INFO] rompy.model : Run ID : run1
2025-10-02 13:26:16 [INFO] rompy.model : Model Type : Config
2025-10-02 13:26:16 [INFO] rompy.model : Start Time : 2023-01-01T00:00:00
2025-10-02 13:26:16 [INFO] rompy.model : End Time : 2023-01-02T00:00:00
2025-10-02 13:26:16 [INFO] rompy.model : Duration : 1 day
2025-10-02 13:26:16 [INFO] rompy.model : Time Interval : 0:00:01
2025-10-02 13:26:16 [INFO] rompy.model : Output Directory : example-declarative
2025-10-02 13:26:16 [INFO] rompy.model : ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
2025-10-02 13:26:16 [INFO] rompy.model : ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
2025-10-02 13:26:16 [INFO] rompy.model :
2025-10-02 13:26:16 [INFO] root : ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
2025-10-02 13:26:16 [INFO] root : ┃ MODEL CONFIGURATION (Config) ┃
2025-10-02 13:26:16 [INFO] root : ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
2025-10-02 13:26:16 [INFO] root :
2025-10-02 13:26:16 [INFO] rompy.model : Config:
2025-10-02 13:26:16 [INFO] rompy.model : model_type: xbeach
2025-10-02 13:26:16 [INFO] rompy.model : template: /source/csiro/rompy-xbeach/src/rompy_xbeach/templates/base
2025-10-02 13:26:16 [INFO] rompy.model : checkout: main
2025-10-02 13:26:16 [INFO] rompy.model : grid:
2025-10-02 13:26:16 [INFO] rompy.model : grid_type: base
2025-10-02 13:26:16 [INFO] rompy.model : model_type: regular
2025-10-02 13:26:16 [INFO] rompy.model : ori:
2025-10-02 13:26:16 [INFO] rompy.model : x: 115.594239
2025-10-02 13:26:16 [INFO] rompy.model : y: -32.641104
2025-10-02 13:26:16 [INFO] rompy.model : crs: EPSG:4326
2025-10-02 13:26:16 [INFO] rompy.model : alfa: 347.0
2025-10-02 13:26:16 [INFO] rompy.model : dx: 10.0
2025-10-02 13:26:16 [INFO] rompy.model : dy: 15.0
2025-10-02 13:26:16 [INFO] rompy.model : nx: 230
2025-10-02 13:26:16 [INFO] rompy.model : ny: 220
2025-10-02 13:26:16 [INFO] rompy.model : crs: EPSG:28350
2025-10-02 13:26:16 [INFO] rompy.model : bathy:
2025-10-02 13:26:16 [INFO] rompy.model : model_type: xbeach_bathy
2025-10-02 13:26:16 [INFO] rompy.model : id: data
2025-10-02 13:26:16 [INFO] rompy.model : source:
2025-10-02 13:26:16 [INFO] rompy.model : model_type: geotiff
2025-10-02 13:26:16 [INFO] rompy.model : filename: /source/csiro/rompy-xbeach/tests/data/bathy.tif
2025-10-02 13:26:16 [INFO] rompy.model : band: 1
2025-10-02 13:26:16 [INFO] rompy.model : kwargs: {}
2025-10-02 13:26:16 [INFO] rompy.model : filter:
2025-10-02 13:26:16 [INFO] rompy.model : sort: {}
2025-10-02 13:26:16 [INFO] rompy.model : subset: {}
2025-10-02 13:26:16 [INFO] rompy.model : crop: {}
2025-10-02 13:26:16 [INFO] rompy.model : timenorm: {}
2025-10-02 13:26:16 [INFO] rompy.model : rename: {}
2025-10-02 13:26:16 [INFO] rompy.model : derived: {}
2025-10-02 13:26:16 [INFO] rompy.model : variables:
2025-10-02 13:26:16 [INFO] rompy.model : [0]: data
2025-10-02 13:26:16 [INFO] rompy.model : coords:
2025-10-02 13:26:16 [INFO] rompy.model : t: time
2025-10-02 13:26:16 [INFO] rompy.model : x: longitude
2025-10-02 13:26:16 [INFO] rompy.model : y: latitude
2025-10-02 13:26:16 [INFO] rompy.model : z: None
2025-10-02 13:26:16 [INFO] rompy.model : s: None
2025-10-02 13:26:16 [INFO] rompy.model : crop_data: True
2025-10-02 13:26:16 [INFO] rompy.model : buffer: 0.0
2025-10-02 13:26:16 [INFO] rompy.model : time_buffer:
2025-10-02 13:26:16 [INFO] rompy.model : [0]: 0
2025-10-02 13:26:16 [INFO] rompy.model : [1]: 0
2025-10-02 13:26:16 [INFO] rompy.model : interpolator:
2025-10-02 13:26:16 [INFO] rompy.model : model_type: scipy_regular_grid
2025-10-02 13:26:16 [INFO] rompy.model : kwargs:
2025-10-02 13:26:16 [INFO] rompy.model : method: linear
2025-10-02 13:26:16 [INFO] rompy.model : fill_value: None
2025-10-02 13:26:16 [INFO] rompy.model : posdwn: False
2025-10-02 13:26:16 [INFO] rompy.model : left: 3
2025-10-02 13:26:16 [INFO] rompy.model : right: 3
2025-10-02 13:26:16 [INFO] rompy.model : extension:
2025-10-02 13:26:16 [INFO] rompy.model : model_type: linear
2025-10-02 13:26:16 [INFO] rompy.model : depth: 25.0
2025-10-02 13:26:16 [INFO] rompy.model : slope: 0.3
2025-10-02 13:26:16 [INFO] rompy.model : interpolate_na: True
2025-10-02 13:26:16 [INFO] rompy.model : interpolate_na_kwargs: {}
2025-10-02 13:26:16 [INFO] rompy.model : input:
2025-10-02 13:26:16 [INFO] rompy.model : model_type: data
2025-10-02 13:26:16 [INFO] rompy.model : wave:
2025-10-02 13:26:16 [INFO] rompy.model : model_type: station_param_jonstable
2025-10-02 13:26:16 [INFO] rompy.model : id: jonstable
2025-10-02 13:26:16 [INFO] rompy.model : source:
2025-10-02 13:26:16 [INFO] rompy.model : model_type: file
2025-10-02 13:26:16 [INFO] rompy.model : uri: /source/csiro/rompy-xbeach/tests/data/smc-params-20230101.nc
2025-10-02 13:26:16 [INFO] rompy.model : kwargs: {}
2025-10-02 13:26:16 [INFO] rompy.model : variable: None
2025-10-02 13:26:16 [INFO] rompy.model : crs: EPSG:4326
2025-10-02 13:26:16 [INFO] rompy.model : x_dim: x
2025-10-02 13:26:16 [INFO] rompy.model : y_dim: y
2025-10-02 13:26:16 [INFO] rompy.model : filter:
2025-10-02 13:26:16 [INFO] rompy.model : sort: {}
2025-10-02 13:26:16 [INFO] rompy.model : subset: {}
2025-10-02 13:26:16 [INFO] rompy.model : crop: {}
2025-10-02 13:26:16 [INFO] rompy.model : timenorm: {}
2025-10-02 13:26:16 [INFO] rompy.model : rename: {}
2025-10-02 13:26:16 [INFO] rompy.model : derived: {}
2025-10-02 13:26:16 [INFO] rompy.model : variables: []
2025-10-02 13:26:16 [INFO] rompy.model : coords:
2025-10-02 13:26:16 [INFO] rompy.model : t: time
2025-10-02 13:26:16 [INFO] rompy.model : x: longitude
2025-10-02 13:26:16 [INFO] rompy.model : y: latitude
2025-10-02 13:26:16 [INFO] rompy.model : z: None
2025-10-02 13:26:16 [INFO] rompy.model : s: seapoint
2025-10-02 13:26:16 [INFO] rompy.model : crop_data: True
2025-10-02 13:26:16 [INFO] rompy.model : buffer: 0.0
2025-10-02 13:26:16 [INFO] rompy.model : time_buffer:
2025-10-02 13:26:16 [INFO] rompy.model : [0]: 1
2025-10-02 13:26:16 [INFO] rompy.model : [1]: 1
2025-10-02 13:26:16 [INFO] rompy.model : location: offshore
2025-10-02 13:26:16 [INFO] rompy.model : sel_method: idw
2025-10-02 13:26:16 [INFO] rompy.model : sel_method_kwargs: {}
2025-10-02 13:26:16 [INFO] rompy.model : dbtc: 1.0
2025-10-02 13:26:16 [INFO] rompy.model : hm0: phs1
2025-10-02 13:26:16 [INFO] rompy.model : tp: ptp1
2025-10-02 13:26:16 [INFO] rompy.model : mainang: pdir1
2025-10-02 13:26:16 [INFO] rompy.model : gammajsp: ppe1
2025-10-02 13:26:16 [INFO] rompy.model : dspr: pspr1
2025-10-02 13:26:16 [INFO] rompy.model : wind:
2025-10-02 13:26:16 [INFO] rompy.model : model_type: wind_station
2025-10-02 13:26:16 [INFO] rompy.model : id: wind
2025-10-02 13:26:16 [INFO] rompy.model : source:
2025-10-02 13:26:16 [INFO] rompy.model : model_type: file
2025-10-02 13:26:16 [INFO] rompy.model : uri: /source/csiro/rompy-xbeach/tests/data/smc-params-20230101.nc
2025-10-02 13:26:16 [INFO] rompy.model : kwargs: {}
2025-10-02 13:26:16 [INFO] rompy.model : variable: None
2025-10-02 13:26:16 [INFO] rompy.model : crs: EPSG:4326
2025-10-02 13:26:16 [INFO] rompy.model : x_dim: x
2025-10-02 13:26:16 [INFO] rompy.model : y_dim: y
2025-10-02 13:26:16 [INFO] rompy.model : filter:
2025-10-02 13:26:16 [INFO] rompy.model : sort: {}
2025-10-02 13:26:16 [INFO] rompy.model : subset: {}
2025-10-02 13:26:16 [INFO] rompy.model : crop: {}
2025-10-02 13:26:16 [INFO] rompy.model : timenorm: {}
2025-10-02 13:26:16 [INFO] rompy.model : rename: {}
2025-10-02 13:26:16 [INFO] rompy.model : derived: {}
2025-10-02 13:26:16 [INFO] rompy.model : variables:
2025-10-02 13:26:16 [INFO] rompy.model : [0]: longitude
2025-10-02 13:26:16 [INFO] rompy.model : [1]: latitude
2025-10-02 13:26:16 [INFO] rompy.model : [2]: uwnd
2025-10-02 13:26:16 [INFO] rompy.model : [3]: vwnd
2025-10-02 13:26:16 [INFO] rompy.model : coords:
2025-10-02 13:26:16 [INFO] rompy.model : t: time
2025-10-02 13:26:16 [INFO] rompy.model : x: longitude
2025-10-02 13:26:16 [INFO] rompy.model : y: latitude
2025-10-02 13:26:16 [INFO] rompy.model : z: None
2025-10-02 13:26:16 [INFO] rompy.model : s: seapoint
2025-10-02 13:26:16 [INFO] rompy.model : crop_data: True
2025-10-02 13:26:16 [INFO] rompy.model : buffer: 0.0
2025-10-02 13:26:16 [INFO] rompy.model : time_buffer:
2025-10-02 13:26:16 [INFO] rompy.model : [0]: 1
2025-10-02 13:26:16 [INFO] rompy.model : [1]: 1
2025-10-02 13:26:16 [INFO] rompy.model : location: centre
2025-10-02 13:26:16 [INFO] rompy.model : sel_method: idw
2025-10-02 13:26:16 [INFO] rompy.model : sel_method_kwargs: {}
2025-10-02 13:26:16 [INFO] rompy.model : wind_vars:
2025-10-02 13:26:16 [INFO] rompy.model : model_type: wind_vector
2025-10-02 13:26:16 [INFO] rompy.model : u: uwnd
2025-10-02 13:26:16 [INFO] rompy.model : v: vwnd
2025-10-02 13:26:16 [INFO] rompy.model : tide:
2025-10-02 13:26:16 [INFO] rompy.model : model_type: tide_cons_grid
2025-10-02 13:26:16 [INFO] rompy.model : id: tide
2025-10-02 13:26:16 [INFO] rompy.model : source:
2025-10-02 13:26:16 [INFO] rompy.model : model_type: oceantide
2025-10-02 13:26:16 [INFO] rompy.model : reader: read_otis_binary
2025-10-02 13:26:16 [INFO] rompy.model : kwargs:
2025-10-02 13:26:16 [INFO] rompy.model : gfile: /source/csiro/rompy-xbeach/tests/data/swaus_tide_cons/grid_m2s2n2k2k1o1p1q1mmmf
2025-10-02 13:26:16 [INFO] rompy.model : hfile: /source/csiro/rompy-xbeach/tests/data/swaus_tide_cons/h_m2s2n2k2k1o1p1q1mmmf
2025-10-02 13:26:16 [INFO] rompy.model : ufile: /source/csiro/rompy-xbeach/tests/data/swaus_tide_cons/u_m2s2n2k2k1o1p1q1mmmf
2025-10-02 13:26:16 [INFO] rompy.model : crs: EPSG:4326
2025-10-02 13:26:16 [INFO] rompy.model : x_dim: lon
2025-10-02 13:26:16 [INFO] rompy.model : y_dim: lat
2025-10-02 13:26:16 [INFO] rompy.model : filter:
2025-10-02 13:26:16 [INFO] rompy.model : sort: {}
2025-10-02 13:26:16 [INFO] rompy.model : subset: {}
2025-10-02 13:26:16 [INFO] rompy.model : crop: {}
2025-10-02 13:26:16 [INFO] rompy.model : timenorm: {}
2025-10-02 13:26:16 [INFO] rompy.model : rename: {}
2025-10-02 13:26:16 [INFO] rompy.model : derived: {}
2025-10-02 13:26:16 [INFO] rompy.model : variables:
2025-10-02 13:26:16 [INFO] rompy.model : [0]: h
2025-10-02 13:26:16 [INFO] rompy.model : coords:
2025-10-02 13:26:16 [INFO] rompy.model : t: time
2025-10-02 13:26:16 [INFO] rompy.model : x: lon
2025-10-02 13:26:16 [INFO] rompy.model : y: lat
2025-10-02 13:26:16 [INFO] rompy.model : z: None
2025-10-02 13:26:16 [INFO] rompy.model : s: None
2025-10-02 13:26:16 [INFO] rompy.model : crop_data: True
2025-10-02 13:26:16 [INFO] rompy.model : buffer: 0.0
2025-10-02 13:26:16 [INFO] rompy.model : time_buffer:
2025-10-02 13:26:16 [INFO] rompy.model : [0]: 1
2025-10-02 13:26:16 [INFO] rompy.model : [1]: 1
2025-10-02 13:26:16 [INFO] rompy.model : location: offshore
2025-10-02 13:26:16 [INFO] rompy.model : sel_method: sel
2025-10-02 13:26:16 [INFO] rompy.model : sel_method_kwargs:
2025-10-02 13:26:16 [INFO] rompy.model : method: nearest
2025-10-02 13:26:16 [INFO] rompy.model : tideloc: 1
2025-10-02 13:26:16 [INFO] rompy.model : freq: 1h
2025-10-02 13:26:16 [INFO] rompy.model : zs0: 0.0
2025-10-02 13:26:16 [INFO] rompy.model : front: abs_2d
2025-10-02 13:26:16 [INFO] rompy.model : back: abs_2d
2025-10-02 13:26:16 [INFO] rompy.model : left: neumann
2025-10-02 13:26:16 [INFO] rompy.model : right: neumann
2025-10-02 13:26:16 [INFO] rompy.model : lateralwave: wavecrest
2025-10-02 13:26:16 [INFO] rompy.model : rugdepth: None
2025-10-02 13:26:16 [INFO] rompy.model : tunits: None
2025-10-02 13:26:16 [INFO] rompy.model : breaktype: roelvink_daly
2025-10-02 13:26:16 [INFO] rompy.model : scheme: warmbeam
2025-10-02 13:26:16 [INFO] rompy.model : order: 1
2025-10-02 13:26:16 [INFO] rompy.model : random: 1
2025-10-02 13:26:16 [INFO] rompy.model : hmin: 0.01
2025-10-02 13:26:16 [INFO] rompy.model : wci: 0
2025-10-02 13:26:16 [INFO] rompy.model : alpha: 1.0
2025-10-02 13:26:16 [INFO] rompy.model : delta: 0.0
2025-10-02 13:26:16 [INFO] rompy.model : n: 10.0
2025-10-02 13:26:16 [INFO] rompy.model : rho: 1025.0
2025-10-02 13:26:16 [INFO] rompy.model : g: 9.81
2025-10-02 13:26:16 [INFO] rompy.model : thetamin: -80.0
2025-10-02 13:26:16 [INFO] rompy.model : thetamax: 80.0
2025-10-02 13:26:16 [INFO] rompy.model : dtheta: 10.0
2025-10-02 13:26:16 [INFO] rompy.model : beta: 0.1
2025-10-02 13:26:16 [INFO] rompy.model : roller: 1
2025-10-02 13:26:16 [INFO] rompy.model : gamma: 0.55
2025-10-02 13:26:16 [INFO] rompy.model : gammax: 1.0
2025-10-02 13:26:16 [INFO] rompy.model : sedtrans: 0
2025-10-02 13:26:16 [INFO] rompy.model : morfac: 1.0
2025-10-02 13:26:16 [INFO] rompy.model : morphology: 0
2025-10-02 13:26:16 [INFO] rompy.model : cf: 0.01
2025-10-02 13:26:16 [INFO] rompy.model : eps: 0.01
2025-10-02 13:26:16 [INFO] rompy.model : epsi: 0.001
2025-10-02 13:26:16 [INFO] rompy.model : cfl: 0.8
2025-10-02 13:26:16 [INFO] rompy.model : umin: 0.1
2025-10-02 13:26:16 [INFO] rompy.model : oldhu: 1
2025-10-02 13:26:16 [INFO] rompy.model : outputformat: netcdf
2025-10-02 13:26:16 [INFO] rompy.model : ncfilename: xboutput_test.nc
2025-10-02 13:26:16 [INFO] rompy.model : tstart: 0.0
2025-10-02 13:26:16 [INFO] rompy.model : tintc: None
2025-10-02 13:26:16 [INFO] rompy.model : tintg: None
2025-10-02 13:26:16 [INFO] rompy.model : tintm: 3600.0
2025-10-02 13:26:16 [INFO] rompy.model : tintp: None
2025-10-02 13:26:16 [INFO] rompy.model : paulrevere: land
2025-10-02 13:26:16 [INFO] rompy.model :
2025-10-02 13:26:16 [INFO] rompy.model : ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
2025-10-02 13:26:16 [INFO] rompy.model : ┃ STARTING MODEL GENERATION ┃
2025-10-02 13:26:16 [INFO] rompy.model : ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
2025-10-02 13:26:16 [INFO] rompy.model : Preparing input files in example-declarative
2025-10-02 13:26:16 [INFO] rompy.model : Processing model configuration...
2025-10-02 13:26:16 [INFO] rompy.model : Running configuration callable...
2025-10-02 13:26:16 [INFO] rompy_xbeach.config : Generating wave boundary data
2025-10-02 13:26:17 [INFO] rompy_xbeach.config : Generating wind forcing data
2025-10-02 13:26:17 [INFO] rompy_xbeach.config : Generating tide forcing data
2025-10-02 13:26:19 [INFO] rompy.model : Rendering model templates to example-declarative/run1...
2025-10-02 13:26:19 [INFO] rompy.core.render : Template source: /source/csiro/rompy-xbeach/src/rompy_xbeach/templates/base
2025-10-02 13:26:19 [INFO] rompy.core.render : Output directory: example-declarative
2025-10-02 13:26:19 [INFO] rompy.core.render : Using template version: main
2025-10-02 13:26:19 [INFO] rompy.core.render : • Locating template repository...
2025-10-02 13:26:19 [INFO] rompy.core.render : Template repository located at: /source/csiro/rompy-xbeach/src/rompy_xbeach/templates/base
2025-10-02 13:26:19 [INFO] rompy.core.render : • Generating files from template...
2025-10-02 13:26:19 [INFO] rompy.core.render : • Rendering time: 0.02 seconds
2025-10-02 13:26:19 [INFO] rompy.core.render : • Total process time: 0.02 seconds
2025-10-02 13:26:19 [INFO] rompy.core.render : • Files created: 7
2025-10-02 13:26:19 [INFO] rompy.core.render : • Output location: /source/csiro/rompy-notebooks/notebooks/xbeach/example-declarative/run1
2025-10-02 13:26:19 [INFO] rompy.model :
2025-10-02 13:26:19 [INFO] rompy.model : ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
2025-10-02 13:26:19 [INFO] rompy.model : ┃ MODEL GENERATION COMPLETE ┃
2025-10-02 13:26:19 [INFO] rompy.model : ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
2025-10-02 13:26:19 [INFO] rompy.model : Model files generated at: /source/csiro/rompy-notebooks/notebooks/xbeach/example-declarative/run1
Out[7]:
'/source/csiro/rompy-notebooks/notebooks/xbeach/example-declarative/run1'
Check the workspace¶
In [8]:
Copied!
modeldir = Path(modelrun.output_dir) / modelrun.run_id
sorted(modeldir.glob("*"))
modeldir = Path(modelrun.output_dir) / modelrun.run_id
sorted(modeldir.glob("*"))
Out[8]:
[PosixPath('example-declarative/run1/bathy.txt'),
PosixPath('example-declarative/run1/jonstable-20230101T000000-20230102T000000.txt'),
PosixPath('example-declarative/run1/params.txt'),
PosixPath('example-declarative/run1/tide-20230101T000000-20230102T000000.txt'),
PosixPath('example-declarative/run1/wind-20230101T000000-20230102T000000.txt'),
PosixPath('example-declarative/run1/xdata.txt'),
PosixPath('example-declarative/run1/ydata.txt')]
In [9]:
Copied!
params = modeldir / "params.txt"
print(params.read_text())
params = modeldir / "params.txt"
print(params.read_text())
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% XBeach parameter settings input file %%% %%% Date: 2025-10-02 00:26:16.327971+00:00 %%% User: rguedes-XPS-13-9350 %%% Template: /source/csiro/rompy-xbeach/src/rompy_xbeach/templates/base %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% zs0 = 0.0 front = abs_2d back = abs_2d left = neumann right = neumann lateralwave = wavecrest break = roelvink_daly scheme = warmbeam order = 1 random = 1 hmin = 0.01 wci = 0 alpha = 1.0 delta = 0.0 n = 10.0 rho = 1025.0 g = 9.81 thetamin = -80.0 thetamax = 80.0 dtheta = 10.0 beta = 0.1 roller = 1 gamma = 0.55 gammax = 1.0 sedtrans = 0 morfac = 1.0 morphology = 0 cf = 0.01 eps = 0.01 epsi = 0.001 cfl = 0.8 umin = 0.1 oldhu = 1 outputformat = netcdf ncfilename = xboutput_test.nc tstart = 0.0 tintm = 3600.0 paulrevere = land tstop = 86400.0 tunits = seconds since 2023-01-01 00:00:00 wbctype = jonstable bcfile = jonstable-20230101T000000-20230102T000000.txt windfile = wind-20230101T000000-20230102T000000.txt zs0file = tide-20230101T000000-20230102T000000.txt tideloc = 1 tidelen = 25 posdwn = -1 nx = 233 ny = 225 dx = 10.0 dy = 15.0 xori = 368095.9047500096 yori = 6387591.740656142 alfa = 347.0 projection = +proj=utm +zone=50 +south +ellps=GRS80 +units=m +no_defs +type=crs depfile = bathy.txt nmeanvar = 14 H thetamean hh u v D R k ue ve urms Qb zb zs
Check the input¶
In [10]:
Copied!
def read_xbeach_input(modelrun: ModelRun, filetype: str, cols: list[str]) -> pd.DataFrame:
"""Read XBeach input file."""
filename = Path(modelrun.output_dir) / modelrun.run_id / modelrun.config.namelist[filetype]
df = pd.read_csv(filename, header=None, sep="\s+", names=cols)
if "tsec" in cols:
df.index = [modelrun.period.start + timedelta(seconds=s) for s in df.tsec]
elif "duration" in cols:
df.index = pd.date_range(modelrun.period.start, periods=df.shape[0], freq=f"{df.duration.iloc[0]}s")
return df
def plot_xbeach_input(df, cols):
fig, axs = plt.subplots(len(cols), 1, figsize=(15, 2.5*len(cols)))
if len(cols) == 1:
axs = [axs]
for ax, col in zip(axs, cols):
ax.plot(df.index, df[col], "k", linewidth=2)
ax.set_ylabel(col)
ax.grid()
if col != cols[-1]:
ax.set_xticklabels([])
ax.set_xlim(df.index[0], df.index[-1])
def read_xbeach_input(modelrun: ModelRun, filetype: str, cols: list[str]) -> pd.DataFrame:
"""Read XBeach input file."""
filename = Path(modelrun.output_dir) / modelrun.run_id / modelrun.config.namelist[filetype]
df = pd.read_csv(filename, header=None, sep="\s+", names=cols)
if "tsec" in cols:
df.index = [modelrun.period.start + timedelta(seconds=s) for s in df.tsec]
elif "duration" in cols:
df.index = pd.date_range(modelrun.period.start, periods=df.shape[0], freq=f"{df.duration.iloc[0]}s")
return df
def plot_xbeach_input(df, cols):
fig, axs = plt.subplots(len(cols), 1, figsize=(15, 2.5*len(cols)))
if len(cols) == 1:
axs = [axs]
for ax, col in zip(axs, cols):
ax.plot(df.index, df[col], "k", linewidth=2)
ax.set_ylabel(col)
ax.grid()
if col != cols[-1]:
ax.set_xticklabels([])
ax.set_xlim(df.index[0], df.index[-1])
Wave boundary¶
In [11]:
Copied!
df = read_xbeach_input(modelrun, "bcfile", ["hm0", "tp", "mainang", "gammajsp", "s", "duration", "dtbc"])
display(df)
plot_xbeach_input(df, ["hm0", "tp", "mainang", "gammajsp", "s"])
df = read_xbeach_input(modelrun, "bcfile", ["hm0", "tp", "mainang", "gammajsp", "s", "duration", "dtbc"])
display(df)
plot_xbeach_input(df, ["hm0", "tp", "mainang", "gammajsp", "s"])
| hm0 | tp | mainang | gammajsp | s | duration | dtbc | |
|---|---|---|---|---|---|---|---|
| 2023-01-01 00:00:00 | 0.875435 | 13.1659 | 251.114 | 2.68225 | 21.95140 | 3600 | 1 |
| 2023-01-01 01:00:00 | 0.909496 | 13.1292 | 251.203 | 2.71106 | 22.14170 | 3600 | 1 |
| 2023-01-01 02:00:00 | 0.802303 | 14.8497 | 259.002 | 3.33514 | 37.51500 | 3600 | 1 |
| 2023-01-01 03:00:00 | 0.869525 | 14.4893 | 258.311 | 3.04059 | 32.56840 | 3600 | 1 |
| 2023-01-01 04:00:00 | 0.950949 | 15.9315 | 261.311 | 3.07464 | 34.76650 | 3600 | 1 |
| 2023-01-01 05:00:00 | 1.116260 | 15.5877 | 259.663 | 2.69405 | 31.39360 | 3600 | 1 |
| 2023-01-01 06:00:00 | 1.248320 | 15.3719 | 258.318 | 2.43367 | 29.18680 | 3600 | 1 |
| 2023-01-01 07:00:00 | 1.291500 | 15.2017 | 258.212 | 2.38952 | 29.76960 | 3600 | 1 |
| 2023-01-01 08:00:00 | 1.320870 | 15.0475 | 258.130 | 2.34202 | 29.70590 | 3600 | 1 |
| 2023-01-01 09:00:00 | 1.347160 | 14.9010 | 258.004 | 2.27363 | 30.11310 | 3600 | 1 |
| 2023-01-01 10:00:00 | 1.363910 | 14.7604 | 257.864 | 2.20969 | 30.46960 | 3600 | 1 |
| 2023-01-01 11:00:00 | 1.372720 | 14.6115 | 257.669 | 2.14844 | 30.54930 | 3600 | 1 |
| 2023-01-01 12:00:00 | 1.377590 | 14.4630 | 257.518 | 2.09117 | 30.62930 | 3600 | 1 |
| 2023-01-01 13:00:00 | 1.381050 | 14.2690 | 257.456 | 2.02922 | 31.01480 | 3600 | 1 |
| 2023-01-01 14:00:00 | 1.361030 | 14.1080 | 257.462 | 2.07818 | 31.48240 | 3600 | 1 |
| 2023-01-01 15:00:00 | 1.375200 | 13.9806 | 257.093 | 2.02888 | 31.16670 | 3600 | 1 |
| 2023-01-01 16:00:00 | 1.366970 | 13.8793 | 257.134 | 2.03995 | 31.70880 | 3600 | 1 |
| 2023-01-01 17:00:00 | 1.375870 | 13.7939 | 256.577 | 1.99534 | 31.21980 | 3600 | 1 |
| 2023-01-01 18:00:00 | 1.545250 | 13.7111 | 251.695 | 1.68450 | 18.38430 | 3600 | 1 |
| 2023-01-01 19:00:00 | 1.519940 | 13.6568 | 252.072 | 1.71864 | 18.87130 | 3600 | 1 |
| 2023-01-01 20:00:00 | 1.492070 | 13.6108 | 252.472 | 1.75470 | 19.46020 | 3600 | 1 |
| 2023-01-01 21:00:00 | 1.745520 | 13.5657 | 242.543 | 1.19823 | 7.53764 | 3600 | 1 |
| 2023-01-01 22:00:00 | 1.698140 | 13.5257 | 243.694 | 1.24290 | 8.06533 | 3600 | 1 |
| 2023-01-01 23:00:00 | 1.655350 | 13.4808 | 244.737 | 1.27681 | 8.75955 | 3600 | 1 |
| 2023-01-02 00:00:00 | 1.718340 | 13.4390 | 246.080 | 1.31954 | 9.75852 | 3600 | 1 |
Wind¶
In [12]:
Copied!
df = read_xbeach_input(modelrun, "windfile", ["tsec", "wspd", "wdir"])
display(df)
plot_xbeach_input(df, ["wspd", "wdir"])
df = read_xbeach_input(modelrun, "windfile", ["tsec", "wspd", "wdir"])
display(df)
plot_xbeach_input(df, ["wspd", "wdir"])
| tsec | wspd | wdir | |
|---|---|---|---|
| 2023-01-01 00:00:00 | 0.0 | 7.15 | 186.92 |
| 2023-01-01 01:00:00 | 3600.0 | 7.49 | 192.82 |
| 2023-01-01 02:00:00 | 7200.0 | 7.96 | 198.03 |
| 2023-01-01 03:00:00 | 10800.0 | 8.24 | 203.33 |
| 2023-01-01 04:00:00 | 14400.0 | 8.91 | 208.57 |
| 2023-01-01 05:00:00 | 18000.0 | 9.69 | 210.79 |
| 2023-01-01 06:00:00 | 21600.0 | 10.09 | 210.59 |
| 2023-01-01 07:00:00 | 25200.0 | 10.29 | 210.61 |
| 2023-01-01 08:00:00 | 28800.0 | 10.20 | 209.83 |
| 2023-01-01 09:00:00 | 32400.0 | 10.26 | 209.25 |
| 2023-01-01 10:00:00 | 36000.0 | 10.74 | 209.04 |
| 2023-01-01 11:00:00 | 39600.0 | 11.03 | 204.15 |
| 2023-01-01 12:00:00 | 43200.0 | 10.76 | 199.61 |
| 2023-01-01 13:00:00 | 46800.0 | 10.26 | 196.27 |
| 2023-01-01 14:00:00 | 50400.0 | 10.26 | 191.46 |
| 2023-01-01 15:00:00 | 54000.0 | 10.15 | 187.72 |
| 2023-01-01 16:00:00 | 57600.0 | 9.93 | 184.77 |
| 2023-01-01 17:00:00 | 61200.0 | 9.39 | 180.76 |
| 2023-01-01 18:00:00 | 64800.0 | 8.55 | 173.11 |
| 2023-01-01 19:00:00 | 68400.0 | 7.90 | 169.79 |
| 2023-01-01 20:00:00 | 72000.0 | 7.51 | 167.97 |
| 2023-01-01 21:00:00 | 75600.0 | 7.25 | 168.36 |
| 2023-01-01 22:00:00 | 79200.0 | 7.04 | 165.81 |
| 2023-01-01 23:00:00 | 82800.0 | 6.78 | 168.83 |
| 2023-01-02 00:00:00 | 86400.0 | 6.99 | 178.25 |
Tide¶
In [13]:
Copied!
df = read_xbeach_input(modelrun, "zs0file", ["tsec", "zs"])
display(df)
plot_xbeach_input(df, ["zs"])
df = read_xbeach_input(modelrun, "zs0file", ["tsec", "zs"])
display(df)
plot_xbeach_input(df, ["zs"])
| tsec | zs | |
|---|---|---|
| 2023-01-01 00:00:00 | 0.0 | -0.12 |
| 2023-01-01 01:00:00 | 3600.0 | -0.10 |
| 2023-01-01 02:00:00 | 7200.0 | -0.07 |
| 2023-01-01 03:00:00 | 10800.0 | -0.04 |
| 2023-01-01 04:00:00 | 14400.0 | 0.00 |
| 2023-01-01 05:00:00 | 18000.0 | 0.05 |
| 2023-01-01 06:00:00 | 21600.0 | 0.09 |
| 2023-01-01 07:00:00 | 25200.0 | 0.14 |
| 2023-01-01 08:00:00 | 28800.0 | 0.17 |
| 2023-01-01 09:00:00 | 32400.0 | 0.20 |
| 2023-01-01 10:00:00 | 36000.0 | 0.21 |
| 2023-01-01 11:00:00 | 39600.0 | 0.21 |
| 2023-01-01 12:00:00 | 43200.0 | 0.19 |
| 2023-01-01 13:00:00 | 46800.0 | 0.14 |
| 2023-01-01 14:00:00 | 50400.0 | 0.09 |
| 2023-01-01 15:00:00 | 54000.0 | 0.03 |
| 2023-01-01 16:00:00 | 57600.0 | -0.04 |
| 2023-01-01 17:00:00 | 61200.0 | -0.10 |
| 2023-01-01 18:00:00 | 64800.0 | -0.16 |
| 2023-01-01 19:00:00 | 68400.0 | -0.19 |
| 2023-01-01 20:00:00 | 72000.0 | -0.22 |
| 2023-01-01 21:00:00 | 75600.0 | -0.22 |
| 2023-01-01 22:00:00 | 79200.0 | -0.21 |
| 2023-01-01 23:00:00 | 82800.0 | -0.19 |
| 2023-01-02 00:00:00 | 86400.0 | -0.17 |
Run the model¶
To be implemented
Plot outputs¶
To be implemented
Cleanup¶
Uncomment below to clean up the test workspace directory
In [14]:
Copied!
# import shutil
# shutil.rmtree(run.output_dir, ignore_errors=True)
# import shutil
# shutil.rmtree(run.output_dir, ignore_errors=True)