Config¶
Config is the XBeach model configuration. It gathers the grid, bathymetry, forcing and model settings, and writes params.txt and the input files. It subclasses rompy's BaseConfig.
XBEACH Rompy config.
WBCTYPE_WAVEMODELS
module-attribute
¶
WBCTYPE_WAVEMODELS = {
"parametric": {"surfbeat", "nonh"},
"swan": {"surfbeat", "nonh"},
"vardens": {"surfbeat", "nonh"},
"reuse": {"surfbeat", "nonh"},
"ts_1": {"surfbeat"},
"ts_2": {"surfbeat"},
"ts_nonh": {"nonh"},
}
WindType
module-attribute
¶
WindType = Annotated[
Union[load_entry_points("xbeach.data", etype="wind")],
Field(
description="Wind input data",
discriminator="model_type",
),
]
WaveType
module-attribute
¶
WaveType = Annotated[
Union[load_entry_points("xbeach.data", etype="wave")],
Field(
description="Wave input data",
discriminator="model_type",
),
]
TideType
module-attribute
¶
TideType = Annotated[
Union[load_entry_points("xbeach.data", etype="tide")],
Field(
description="Tide input data",
discriminator="model_type",
),
]
DataInterface
pydantic-model
¶
DataInterface(**data: Any)
Bases: RompyBaseModel
XBeach forcing data: waves, wind and tide.
Each field takes a data interface, which writes its forcing files into the workspace and returns the XBeach parameters that point to them.
Examples¶
from rompy_xbeach.config import DataInterface
from rompy_xbeach.data.boundary import BoundaryParams
print(DataInterface(wave=BoundaryParams(Hrms=1.0, Trep=10.0, dir0=270.0)))
DataInterface:
model_type: data
wave:
nmax: None
wbcevarreduce: None
bclwonly: None
swkhmin: None
wbcRemoveStokes: None
wbcScaleEnergy: None
cyclicdiradjust: None
taper: None
ARC: None
freewave: None
thetamin: None
thetamax: None
dtheta: None
dtheta_s: None
thetanaut: None
order: None
id: params
model_type: params
Hrms: 1.0
Trep: 10.0
Tlong: None
dir0: 270.0
m: 10
wind: None
tide: None
Fields:
-
model_type(Literal['data']) -
wave(Optional[WaveType]) -
wind(Optional[WindType]) -
tide(Optional[TideType])
get
¶
get(
staging_dir: Path, grid: RegularGrid, period: TimeRange
)
Generate each input data and return the XBeach params.
check_for_typos
classmethod
¶
Suggest the closest field name for an unknown input key.
A field can be given by its name or, like in pydantic, by its alias.
Config
pydantic-model
¶
Config(**data: Any)
Bases: XBeachBaseConfig
XBeach model configuration.
Gathers the grid, bathymetry, forcing and model settings. When a
ModelRun generates the workspace, the configuration
writes the input files and params.txt: the data interfaces (bathy and
input) write their files and return the parameters that point to them, and
the components (physics, sediment, output, the boundaries, mpi and
hotstart) add their parameters.
The validators reject combinations XBeach refuses, such as a wave boundary type that does not suit the wave model.
Fields:
-
checkout(Optional[str]) -
model_type(Literal['xbeach']) -
template(str) -
grid(RegularGrid) -
bathy(XBeachBathy) -
input(Optional[DataInterface]) -
physics(Physics) -
sediment(Optional[Sediment]) -
mpi(Optional[Mpi]) -
output(Output) -
flow_boundary(Optional[FlowBoundaryConditions]) -
tide_boundary(Optional[TideBoundaryConditions]) -
hotstart(Optional[Union[bool, Hotstart]]) -
tunits(Optional[str])
Validators:
template
pydantic-field
¶
The model config template
input
pydantic-field
¶
input: Optional[DataInterface] = None
Input data including wave, wind, and tide boundary conditions
physics
pydantic-field
¶
physics: Physics
Physical processes configuration, including the required wave model
flow_boundary
pydantic-field
¶
flow_boundary: Optional[FlowBoundaryConditions] = None
Flow boundary conditions for shallow water equations
tide_boundary
pydantic-field
¶
tide_boundary: Optional[TideBoundaryConditions] = None
Tide and surge boundary conditions
hotstart
pydantic-field
¶
Hotstart configuration. Set to True to enable hotstart with files already in run directory, or provide a Hotstart object to specify source directory and file number.
tunits
pydantic-field
¶
Time units in udunits format, if not provided it is constructed based on the simulation start time (XBeach default: s)
checkout
pydantic-field
¶
The git branch to use if the template is a git repo
set_dtheta_if_surfbeat
pydantic-validator
¶
set_dtheta_if_surfbeat() -> Config
Placeholder validator for future dtheta logic.
check_wave_boundary_for_wavemodel
pydantic-validator
¶
check_wave_boundary_for_wavemodel() -> Config
Raise if the wave boundary type cannot be used with the wave model.
XBeach stops at start-up for these combinations, see WBCTYPE_WAVEMODELS. Bichromatic waves (wbctype=params with Tlong) require the surfbeat model.
warn_wave_direction_params_without_swave
pydantic-validator
¶
warn_wave_direction_params_without_swave() -> Config
Warn if wave directional parameters are set but swave is disabled.
The wave directional grid parameters (thetamin, thetamax, dtheta, dtheta_s, thetanaut) are only used when short waves are enabled (swave=1). Setting these when swave=0 has no effect.
check_for_typos
classmethod
¶
Suggest the closest field name for an unknown input key.
A field can be given by its name or, like in pydantic, by its alias.
render
¶
Render the configuration template to the output directory.
This method orchestrates the template rendering process. The default implementation uses cookiecutter rendering with the template and checkout defined on this config. Subclasses can override this method to implement alternative rendering strategies (e.g., direct file writing, Jinja2, custom logic).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
dict
|
Full context dictionary. Expected to contain at least 'runtime' and 'config' keys. |
required |
output_dir
|
Path | str
|
Target directory for rendered output. |
required |