API Documentation#

Core Classes#

Model#

pydantic model rompy.model.ModelRun[source]

A model run.

It is intented to be model agnostic. It deals primarily with how the model is to be run, i.e. the period of the run and where the output is going. The actual configuration of the run is provided by the config object.

Further explanation is given in the rompy.core.Baseconfig docstring.

Fields:
field config: BaseConfig | SwanConfig | SwanConfigComponents | SchismCSIROConfig [Optional]

The configuration object

field output_dir: Path = './simulations'

The output directory

field period: TimeRange = TimeRange(start=datetime.datetime(2020, 2, 21, 4, 0), end=datetime.datetime(2020, 2, 24, 4, 0), duration=datetime.timedelta(days=3), interval=datetime.timedelta(seconds=900), include_end=True)

The time period to run the model

field run_id: str = 'run_id'

The run id

generate() str[source]

Generate the model input files

Returns:

staging_dir

Return type:

str

zip() str[source]

Zip the input files for the model run

This function zips the input files for the model run and returns the name of the zip file. It also cleans up the staging directory leaving only the settings.json file that can be used to repoducte the run.

Returns:

zip_fn

Return type:

str

property staging_dir

The directory where the model is staged for execution

Returns:

staging_dir

Return type:

str

Config#

pydantic model rompy.core.config.BaseConfig[source]

Base class for model templates.

The template class provides the object that is used to set up the model configuration. When implemented for a given model, can move along a scale of complexity to suit the application.

In its most basic form, as implemented in this base object, it consists of path to a cookiecutter template with the class providing the context for the {{config}} values in that template. Note that any {{runtime}} values are filled from the ModelRun object.

If the template is a git repo, the checkout parameter can be used to specify a branch or tag and it will be cloned and used.

If the object is callable, it will be colled prior to rendering the template. This mechanism can be used to perform tasks such as fetching exteral data, or providing additional context to the template beyond the arguments provided by the user..

Fields:
  • checkout (str | None)

  • model_type (Literal['base'])

  • template (str | None)

field checkout: str | None = 'main'

The git branch to use if the template is a git repo

field model_type: Literal['base'] = 'base'
field template: str | None = '/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/rompy/templates/base'

The path to the model template

Time#

pydantic model rompy.core.time.TimeRange[source]

A time range object

Examples

>>> from rompy import TimeRange
>>> tr = TimeRange(start="2020-01-01", end="2020-01-02")
>>> tr
TimeRange(start=datetime.datetime(2020, 1, 1, 0, 0), end=datetime.datetime(2020, 1, 2, 0, 0), duration=None, interval=None, include_end=True)
>>> tr = TimeRange(start="2020-01-01", duration="1d")
>>> tr
TimeRange(start=datetime.datetime(2020, 1, 1, 0, 0), end=datetime.datetime(2020, 1, 2, 0, 0), duration=timedelta(days=1), interval=None, include_end=True)
>>> tr = TimeRange(start="2020-01-01", duration="1d", interval="1h")
>>> tr
TimeRange(start=datetime.datetime(2020, 1, 1, 0, 0), end=None, duration=timedelta(days=1), interval=timedelta(hours=1), include_end=True)
Fields:
  • duration (str | datetime.timedelta | None)

  • end (datetime.datetime | None)

  • include_end (bool)

  • interval (str | datetime.timedelta | None)

  • start (datetime.datetime | None)

Validators:
  • parse_start_end_duration » all fields

  • valid_duration_interval » duration

  • valid_duration_interval » interval

  • validate_start_end » end

  • validate_start_end » start

  • validate_start_end_duration » all fields

field duration: str | timedelta | None = None

The duration of the time range

Validated by:
  • parse_start_end_duration

  • valid_duration_interval

  • validate_start_end_duration

field end: datetime | None = None

The end date of the time range

Validated by:
  • parse_start_end_duration

  • validate_start_end

  • validate_start_end_duration

field include_end: bool = True

Determines if the end date should be included in the range

Validated by:
  • parse_start_end_duration

  • validate_start_end_duration

field interval: str | timedelta | None = '1h'

The frequency of the time range

Validated by:
  • parse_start_end_duration

  • valid_duration_interval

  • validate_start_end_duration

field start: datetime | None = None

The start date of the time range

Validated by:
  • parse_start_end_duration

  • validate_start_end

  • validate_start_end_duration

common_times(date_range: TimeRange) list[datetime][source]
contains(date: datetime) bool[source]
contains_range(date_range: TimeRange) bool[source]
validator parse_start_end_duration  »  all fields[source]
validator valid_duration_interval  »  duration, interval[source]
validator validate_start_end  »  start, end[source]
validator validate_start_end_duration  »  all fields[source]
property date_range: list[datetime]

Grid#

pydantic model rompy.core.grid.BaseGrid[source]

Representation of a grid in geographic space.

This is the base class for all Grid objects. The minimum representation of a grid are two NumPy array’s representing the vertices or nodes of some structured or unstructured grid, its bounding box and a boundary polygon. No knowledge of the grid connectivity is expected.

Fields:
field grid_type: Literal['base'] = 'base'
bbox(buffer=0.0) Bbox[source]

Returns a bounding box for the spatial grid

This function returns a list [ll_x, ll_y, ur_x, ur_y] where ll_x, ll_y (ur_x, ur_y) are the lower left (upper right) x and y coordinates bounding box of the model domain

boundary(tolerance=0.2) Polygon[source]

Returns the convex hull boundary polygon from the grid.

Parameters:

tolerance (float) – Simplify polygon shape based on maximum distance from original geometry, see https://shapely.readthedocs.io/en/stable/manual.html#object.simplify.

Returns:

polygon – See https://shapely.readthedocs.io/en/stable/manual.html#Polygon

Return type:

shapely.Polygon

boundary_points(spacing=None, tolerance=0.2) tuple[source]

Returns array of coordinates from boundary polygon.

Parameters:
  • tolerance (float) – Simplify polygon shape based on maximum distance from original geometry, see https://shapely.readthedocs.io/en/stable/manual.html#object.simplify.

  • spacing (float) – If specified, points are returned evenly spaced along the boundary at the specified spacing, otherwise all points are returned.

  • Returns

  • --------

  • points (tuple) – Tuple of x and y coordinates of the boundary points.

plot(ax=None, figsize=None, fscale=10, buffer=0.1, borders=True, land=True, coastline=True)[source]

Plot the grid

property maxx: float
property maxy: float
property minx: float
property miny: float
property x: ndarray
property y: ndarray
pydantic model rompy.core.grid.RegularGrid[source]

Regular grid in geographic space.

This object provides an abstract representation of a regular grid in some geographic space.

Fields:
Validators:
field dx: float | None = None

Spacing between grid points in the x direction

Validated by:
field dy: float | None = None

Spacing between grid points in the y direction

Validated by:
field grid_type: Literal['regular'] = 'regular'

Type of grid, must be ‘regular’

Validated by:
field nx: int | None = None

Number of grid points in the x direction

Validated by:
field ny: int | None = None

Number of grid points in the y direction

Validated by:
field rot: float | None = 0.0

Rotation angle of the grid in degrees

Validated by:
field x0: float | None = None

X coordinate of the grid origin

Validated by:
field y0: float | None = None

Y coordinate of the grid origin

Validated by:
bbox(buffer=0.0) Bbox

Returns a bounding box for the spatial grid

This function returns a list [ll_x, ll_y, ur_x, ur_y] where ll_x, ll_y (ur_x, ur_y) are the lower left (upper right) x and y coordinates bounding box of the model domain

boundary(tolerance=0.2) Polygon

Returns the convex hull boundary polygon from the grid.

Parameters:

tolerance (float) – Simplify polygon shape based on maximum distance from original geometry, see https://shapely.readthedocs.io/en/stable/manual.html#object.simplify.

Returns:

polygon – See https://shapely.readthedocs.io/en/stable/manual.html#Polygon

Return type:

shapely.Polygon

boundary_points(spacing=None, tolerance=0.2) tuple

Returns array of coordinates from boundary polygon.

Parameters:
  • tolerance (float) – Simplify polygon shape based on maximum distance from original geometry, see https://shapely.readthedocs.io/en/stable/manual.html#object.simplify.

  • spacing (float) – If specified, points are returned evenly spaced along the boundary at the specified spacing, otherwise all points are returned.

  • Returns

  • --------

  • points (tuple) – Tuple of x and y coordinates of the boundary points.

validator generate  »  all fields[source]

Generate the grid from the provided parameters.

plot(ax=None, figsize=None, fscale=10, buffer=0.1, borders=True, land=True, coastline=True)

Plot the grid

property maxx: float
property maxy: float
property minx: float
property miny: float
property x: ndarray
property xlen
property y: ndarray
property ylen

Data#

Rompy core data objects.

pydantic model rompy.core.data.DataBlob[source]

Data source for model ingestion.

Generic data source for files that either need to be copied to the model directory or linked if link is set to True.

Fields:
field id: str = 'data'

Unique identifier for this data source

field link: bool = False

Whether to create a symbolic link instead of copying the file

field model_type: Literal['data_blob', 'data_link'] = 'data_blob'

Model type discriminator

field source: AnyPath [Required]

URI of the data source, either a local file path or a remote uri

get(destdir: str | Path, name: str | None = None, *args, **kwargs) Path[source]

Copy or link the data source to a new directory.

Parameters:

destdir (str | Path) – The destination directory to copy or link the data source to.

Returns:

The path to the copied file or created symlink.

Return type:

Path

pydantic model rompy.core.data.DataGrid[source]

Data object for model ingestion.

Generic data object for xarray datasets that need to be filtered and written to netcdf.

Note

The fields filter_grid and filter_time trigger updates to the crop filter from the grid and time range objects passed to the get method. This is useful for data sources that are not defined on the same grid as the model grid or the same time range as the model run.

Fields:
field buffer: float = 0.0

Space to buffer the grid bounding box if filter_grid is True

field coords: DatasetCoords | None = DatasetCoords(t='time', x='longitude', y='latitude', z='depth')

Names of the coordinates in the dataset

field crop_data: bool = True

Update crop filters from Grid and Time objects if passed to get method

field filter: Filter | None [Optional]

Optional filter specification to apply to the dataset

field id: str = 'data'

Unique identifier for this data source

field link: bool = False

Whether to create a symbolic link instead of copying the file

field model_type: Literal['data_grid'] = 'data_grid'

Model type discriminator

field source: SourceDataset | SourceFile | SourceIntake | SourceDatamesh [Required]

Source reader, must return an xarray dataset in the open method

field time_buffer: list[int] = [0, 0]

Number of source data timesteps to buffer the time range if filter_time is True

field variables: list[str] | None = []

Subset of variables to extract from the dataset

get(destdir: str | Path, grid: BaseGrid | RegularGrid | None = None, time: TimeRange | None = None) Path[source]

Write the data source to a new location.

Parameters:
  • destdir (str | Path) – The destination directory to write the netcdf data to.

  • grid (GRID_TYPES, optional) – The grid to filter the data to, only used if self.crop_data is True.

  • time (TimeRange, optional) – The times to filter the data to, only used if self.crop_data is True.

Returns:

outfile – The path to the written file.

Return type:

Path

plot(param, isel={}, model_grid=None, cmap='turbo', figsize=None, fscale=10, borders=True, land=True, coastline=True, **kwargs)[source]

Plot the grid.

property ds

Return the xarray dataset for this data source.

property outfile: str
pydantic model rompy.core.data.SourceBase[source]

Abstract base class for a source dataset.

Fields:
field model_type: Literal['base_source'] [Required]

Model type discriminator, must be overriden by a subclass

open(variables: list = [], filters: Filter = {}, **kwargs) Dataset[source]

Return the filtered dataset object.

Parameters:
  • variables (list, optional) – List of variables to select from the dataset.

  • filters (Filter, optional) – Filters to apply to the dataset.

Notes

The kwargs are only a placeholder in case a subclass needs to pass additional arguments to the open method.

property coordinates: Dataset

Return the coordinates of the datasource.

pydantic model rompy.core.data.SourceDatamesh[source]

Source dataset from Datamesh.

Datamesh documentation: https://docs.oceanum.io/datamesh/index.html

Fields:
  • datasource (str)

  • kwargs (dict)

  • model_type (Literal['datamesh'])

  • token (str | None)

field datasource: str [Required]

The id of the datasource on Datamesh

field kwargs: dict = {}

Keyword arguments to pass to oceanum.datamesh.Connector

field model_type: Literal['datamesh'] = 'datamesh'

Model type discriminator

field token: str | None [Required]

Datamesh API token, taken from the environment if not provided

open(filters: Filter, coords: DatasetCoords, variables: list = []) Dataset[source]

Returns the filtered dataset object.

This method is overriden from the base class because the crop filters need to be converted to a geofilter and timefilter for querying Datamesh.

property connector: Connector

The Datamesh connector instance.

property coordinates: Dataset

Return the coordinates of the datasource.

pydantic model rompy.core.data.SourceDataset[source]

Source dataset from an existing xarray Dataset object.

Fields:
  • model_type (Literal['dataset'])

  • obj (xarray.core.dataset.Dataset)

field model_type: Literal['dataset'] = 'dataset'

Model type discriminator

field obj: Dataset [Required]

xarray Dataset object

open(variables: list = [], filters: Filter = {}, **kwargs) Dataset

Return the filtered dataset object.

Parameters:
  • variables (list, optional) – List of variables to select from the dataset.

  • filters (Filter, optional) – Filters to apply to the dataset.

Notes

The kwargs are only a placeholder in case a subclass needs to pass additional arguments to the open method.

property coordinates: Dataset

Return the coordinates of the datasource.

pydantic model rompy.core.data.SourceFile[source]

Source dataset from file to open with xarray.open_dataset.

Fields:
field kwargs: dict = {}

Keyword arguments to pass to xarray.open_dataset

field model_type: Literal['open_dataset'] = 'open_dataset'

Model type discriminator

field uri: str | Path [Required]

Path to the dataset

open(variables: list = [], filters: Filter = {}, **kwargs) Dataset

Return the filtered dataset object.

Parameters:
  • variables (list, optional) – List of variables to select from the dataset.

  • filters (Filter, optional) – Filters to apply to the dataset.

Notes

The kwargs are only a placeholder in case a subclass needs to pass additional arguments to the open method.

property coordinates: Dataset

Return the coordinates of the datasource.

pydantic model rompy.core.data.SourceIntake[source]

Source dataset from intake catalog.

Note

The intake catalog can be prescribed either by the URI of an existing catalog file or by a YAML string defining the catalog. The YAML string can be obtained from calling the yaml() method on an intake dataset instance.

Fields:
Validators:
field catalog_uri: str | Path | None = None

The URI of the catalog to read from

Validated by:
field catalog_yaml: str | None = None

The YAML string of the catalog to read from

Validated by:
field dataset_id: str [Required]

The id of the dataset to read in the catalog

Validated by:
field kwargs: dict = {}

Keyword arguments to define intake dataset parameters

Validated by:
field model_type: Literal['intake'] = 'intake'

Model type discriminator

Validated by:
validator check_catalog  »  all fields[source]
open(variables: list = [], filters: Filter = {}, **kwargs) Dataset

Return the filtered dataset object.

Parameters:
  • variables (list, optional) – List of variables to select from the dataset.

  • filters (Filter, optional) – Filters to apply to the dataset.

Notes

The kwargs are only a placeholder in case a subclass needs to pass additional arguments to the open method.

property catalog: Catalog

The intake catalog instance.

property coordinates: Dataset

Return the coordinates of the datasource.

Filters#

pydantic model rompy.core.filters.Filter[source]
Fields:
  • crop (dict | None)

  • derived (dict | None)

  • rename (dict | None)

  • sort (dict | None)

  • subset (dict | None)

  • timenorm (dict | None)

Validators:
  • convert_slices » crop

field crop: dict | None = {}
Validated by:
  • convert_slices

field derived: dict | None = {}
field rename: dict | None = {}
field sort: dict | None = {}
field subset: dict | None = {}
field timenorm: dict | None = {}
validator convert_slices  »  crop[source]
rompy.core.filters.crop_filter(ds, **data_slice) Dataset[source]

Crop dataset.

Parameters:
  • ds (xr.Dataset) – Input dataset to transform.

  • data_slice (Iterable) – Data slice to crop

Returns:

ds

Return type:

xr.Dataset

rompy.core.filters.derived_filter(ds, derived_variables)[source]

Add derived variable to Dataset.

Parameters:
  • ds (xarray.Dataset) – Input dataset to add derived variables to.

  • derived_variables (dict) – Mapping {derived_variable_name: derived_variable_definition} where derived_variable_definition is a string to be evaluated defining some transformation based on existing variables in the input dataset ds.

Returns:

ds – Input dataset with extra derived variables.

Return type:

xarray.Dataset

Example

>>> import xarray as xr
>>> ds = xr.DataArray([-10, -11], coords={"x": [0, 1]}).to_dataset(name="elevation")
>>> ds = derived_filter(ds, {"depth": "ds.elevation * -1"})
rompy.core.filters.get_filter_fns() dict[source]

Get dictionary of filter functions

rompy.core.filters.rename_filter(ds, **varmap) Dataset[source]

Rename variables in dataset

Parameters:
  • ds (xr.Dataset) – Input dataset to transform.

  • varmap (dict) – Dictionary of variable names to rename

Returns:

ds

Return type:

xr.Dataset

rompy.core.filters.subset_filter(ds, data_vars=None) Dataset[source]

Subset data variables from dataset.

Parameters:
  • ds (xr.Dataset) – Input dataset to transform.

  • data_vars (Iterable) – Variables to subset from ds.

Returns:

ds

Return type:

xr.Dataset

rompy.core.filters.timenorm_filter(ds, interval='hour', reftime=None) Dataset[source]

Normalize time to lead time in hours

Parameters:
  • ds (xr.Dataset) – Input dataset to transform.

  • interval (str, optional) – Time interval to normalize to, by default “hour”

  • reftime (str, optional) – Reference time variable, by default None

Returns:

ds

Return type:

xr.Dataset

Boundary#

rompy.core.render.find_template(repo_dir, env)[source]

Determine which child directory of repo_dir is the project template.

Parameters:

repo_dir – Local directory of newly cloned repo.

Returns project_template:

Relative path to project template.

rompy.core.render.repository_has_cookiecutter_json(repo_directory)[source]

Determine if repo_directory contains a cookiecutter.json file.

Parameters:

repo_directory – The candidate repository directory.

Returns:

True if the repo_directory is valid, else False.

Types#

Rompy types.

pydantic model rompy.core.types.Bbox[source]

Bounding box

Fields:
  • maxlat (rompy.core.types.Latitude)

  • maxlon (rompy.core.types.Longitude)

  • minlat (rompy.core.types.Latitude)

  • minlon (rompy.core.types.Longitude)

Validators:
  • validate_coords » all fields

field maxlat: Latitude [Required]

Maximum latitude

Validated by:
  • validate_coords

field maxlon: Longitude [Required]

Maximum longitude

Validated by:
  • validate_coords

field minlat: Latitude [Required]

Minimum latitude

Validated by:
  • validate_coords

field minlon: Longitude [Required]

Minimum longitude

Validated by:
  • validate_coords

contains(other)[source]
expand(amount)[source]
classmethod from_geojson(geojson)[source]
classmethod from_polygon(polygon)[source]
classmethod from_wkb(wkb)[source]
classmethod from_wkt(wkt)[source]
intersection(other)[source]
intersects(other)[source]
scale(amount)[source]
shrink(amount)[source]
to_geojson()[source]
to_wkb()[source]
to_wkt()[source]
translate(amount)[source]
union(other)[source]
validator validate_coords  »  all fields[source]
property area
property center
property height
property width
pydantic model rompy.core.types.Coordinate[source]

Coordinate

Fields:
  • lat (float)

  • lon (float)

Validators:
  • validate_lat » lat

  • validate_lon » lon

field lat: float [Required]

Latitude

Validated by:
  • validate_lat

field lon: float [Required]

Longitude

Validated by:
  • validate_lon

validator validate_lat  »  lat[source]
validator validate_lon  »  lon[source]
pydantic model rompy.core.types.DatasetCoords[source]

Coordinates representation.

Fields:
  • t (str | None)

  • x (str | None)

  • y (str | None)

  • z (str | None)

field t: str | None = 'time'

Name of the time coordinate

field x: str | None = 'longitude'

Name of the x coordinate

field y: str | None = 'latitude'

Name of the y coordinate

field z: str | None = 'depth'

Name of the z coordinate

pydantic model rompy.core.types.Latitude[source]

Latitude

Fields:
  • lat (float)

Validators:
  • validate_lat » lat

field lat: float [Required]

Latitude

Constraints:
  • ge = -90

  • le = 90

Validated by:
  • validate_lat

validator validate_lat  »  lat[source]
pydantic model rompy.core.types.Longitude[source]

Longitude

Fields:
  • lon (float)

Validators:
  • validate_lon » lon

field lon: float [Required]

Longitude

Constraints:
  • ge = -180

  • le = 180

Validated by:
  • validate_lon

validator validate_lon  »  lon[source]
pydantic model rompy.core.types.RompyBaseModel[source]
pydantic model rompy.core.types.Slice[source]

Basic float or datetime slice representation

Fields:
  • start (float | datetime.datetime | str | None)

  • stop (float | datetime.datetime | str | None)

field start: float | datetime | str | None = None

Slice start

field stop: float | datetime | str | None = None

Slice stop

classmethod from_dict(d: dict)[source]
classmethod from_slice(s: slice)[source]
to_slice() slice[source]
pydantic model rompy.core.types.Spectrum[source]

A class to represent a wave spectrum.

Fields:
  • fmax (float)

  • fmin (float)

  • ndirs (int)

  • nfreqs (int)

field fmax: float = 1.0

Maximum frequency in Hz

field fmin: float = 0.0464

Minimum frequency in Hz

field ndirs: int = 36

Number of directional components

field nfreqs: int = 31

Number of frequency components

Swan classes#

Config#

pydantic model rompy.swan.config.SwanConfig[source]

SWAN configuration

Fields:
  • checkout ()

  • forcing (rompy.swan.legacy.ForcingData)

  • grid (rompy.swan.grid.SwanGrid)

  • model_type (Literal['swan'])

  • outputs (rompy.swan.legacy.Outputs)

  • physics (rompy.swan.legacy.SwanPhysics)

  • spectra_file (str)

  • spectral_resolution (rompy.swan.legacy.SwanSpectrum)

  • template (str)

field checkout: str | None = 'main'

The git branch to use if the template is a git repo

field forcing: ForcingData = ForcingData(bottom=None, wind=None, current=None, boundary=None)

The forcing data for SWAN.

field grid: SwanGrid [Required]

The model grid for the SWAN run

field model_type: Literal['swan'] = 'swan'

The model type for SWAN.

field outputs: Outputs = Outputs(grid=GridOutput(period=None, variables=['DEPTH', 'UBOT', 'HSIGN', 'HSWELL', 'DIR', 'TPS', 'TM01', 'WIND']), spec=SpecOutput(period=None, locations=OutputLocs ))

The outputs for SWAN.

field physics: SwanPhysics = SwanPhysics(friction='MAD', friction_coeff=0.1)

The physics options for SWAN.

field spectra_file: str = 'boundary.spec'

The spectra file for SWAN.

field spectral_resolution: SwanSpectrum = SwanSpectrum(fmin=0.0464, fmax=1.0, nfreqs=31, ndirs=36)

The spectral resolution for SWAN.

field template: str = '/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/rompy/templates/swan'

The template for SWAN.

property domain
pydantic model rompy.swan.config.SwanConfigComponents[source]

SWAN config class.

TODO: Combine boundary and inpgrid into a single input type.

Note

The cgrid is the only required field since it is used to define the swan grid object which is passed to other components.

Fields:
  • boundary (rompy.swan.components.boundary.BOUNDSPEC | rompy.swan.components.boundary.BOUNDNEST1 | rompy.swan.components.boundary.BOUNDNEST2 | rompy.swan.components.boundary.BOUNDNEST3 | rompy.swan.interface.BoundaryInterface | None)

  • cgrid (rompy.swan.components.cgrid.REGULAR | rompy.swan.components.cgrid.CURVILINEAR | rompy.swan.components.cgrid.UNSTRUCTURED)

  • checkout ()

  • initial (rompy.swan.components.boundary.INITIAL | None)

  • inpgrid (rompy.swan.components.group.INPGRIDS | rompy.swan.interface.DataInterface | None)

  • lockup (rompy.swan.components.group.LOCKUP | None)

  • model_type (Literal['swanconfig', 'SWANCONFIG'])

  • numeric (rompy.swan.components.numerics.NUMERIC | None)

  • output (rompy.swan.components.group.OUTPUT | None)

  • physics (rompy.swan.components.group.PHYSICS | None)

  • prop (rompy.swan.components.numerics.PROP | None)

  • startup (rompy.swan.components.group.STARTUP | None)

  • template (str)

Validators:
  • alp_is_zero_if_spherical » all fields

  • cgrid_contain_inpgrids » all fields

  • group_within_cgrid » all fields

  • layer_defined_if_no_mud_inpgrid » all fields

  • locations_2d » all fields

  • no_nor_if_spherical » all fields

  • no_repeating_if_setup » all fields

  • not_curvilinear_if_ray » all fields

field boundary: BOUNDSPEC | BOUNDNEST1 | BOUNDNEST2 | BOUNDNEST3 | BoundaryInterface | None = None
Validated by:
  • alp_is_zero_if_spherical

  • cgrid_contain_inpgrids

  • group_within_cgrid

  • layer_defined_if_no_mud_inpgrid

  • locations_2d

  • no_nor_if_spherical

  • no_repeating_if_setup

  • not_curvilinear_if_ray

field cgrid: REGULAR | CURVILINEAR | UNSTRUCTURED [Required]

Cgrid component

Validated by:
  • alp_is_zero_if_spherical

  • cgrid_contain_inpgrids

  • group_within_cgrid

  • layer_defined_if_no_mud_inpgrid

  • locations_2d

  • no_nor_if_spherical

  • no_repeating_if_setup

  • not_curvilinear_if_ray

field checkout: str | None = 'main'

The git branch to use if the template is a git repo

Validated by:
  • alp_is_zero_if_spherical

  • cgrid_contain_inpgrids

  • group_within_cgrid

  • layer_defined_if_no_mud_inpgrid

  • locations_2d

  • no_nor_if_spherical

  • no_repeating_if_setup

  • not_curvilinear_if_ray

field initial: INITIAL | None = None
Validated by:
  • alp_is_zero_if_spherical

  • cgrid_contain_inpgrids

  • group_within_cgrid

  • layer_defined_if_no_mud_inpgrid

  • locations_2d

  • no_nor_if_spherical

  • no_repeating_if_setup

  • not_curvilinear_if_ray

field inpgrid: INPGRIDS | DataInterface | None = None
Validated by:
  • alp_is_zero_if_spherical

  • cgrid_contain_inpgrids

  • group_within_cgrid

  • layer_defined_if_no_mud_inpgrid

  • locations_2d

  • no_nor_if_spherical

  • no_repeating_if_setup

  • not_curvilinear_if_ray

field lockup: LOCKUP | None = None
Validated by:
  • alp_is_zero_if_spherical

  • cgrid_contain_inpgrids

  • group_within_cgrid

  • layer_defined_if_no_mud_inpgrid

  • locations_2d

  • no_nor_if_spherical

  • no_repeating_if_setup

  • not_curvilinear_if_ray

field model_type: Literal['swanconfig', 'SWANCONFIG'] = 'swanconfig'

Model type discriminator

Validated by:
  • alp_is_zero_if_spherical

  • cgrid_contain_inpgrids

  • group_within_cgrid

  • layer_defined_if_no_mud_inpgrid

  • locations_2d

  • no_nor_if_spherical

  • no_repeating_if_setup

  • not_curvilinear_if_ray

field numeric: NUMERIC | None = None
Validated by:
  • alp_is_zero_if_spherical

  • cgrid_contain_inpgrids

  • group_within_cgrid

  • layer_defined_if_no_mud_inpgrid

  • locations_2d

  • no_nor_if_spherical

  • no_repeating_if_setup

  • not_curvilinear_if_ray

field output: OUTPUT | None = None
Validated by:
  • alp_is_zero_if_spherical

  • cgrid_contain_inpgrids

  • group_within_cgrid

  • layer_defined_if_no_mud_inpgrid

  • locations_2d

  • no_nor_if_spherical

  • no_repeating_if_setup

  • not_curvilinear_if_ray

field physics: PHYSICS | None = None
Validated by:
  • alp_is_zero_if_spherical

  • cgrid_contain_inpgrids

  • group_within_cgrid

  • layer_defined_if_no_mud_inpgrid

  • locations_2d

  • no_nor_if_spherical

  • no_repeating_if_setup

  • not_curvilinear_if_ray

field prop: PROP | None = None
Validated by:
  • alp_is_zero_if_spherical

  • cgrid_contain_inpgrids

  • group_within_cgrid

  • layer_defined_if_no_mud_inpgrid

  • locations_2d

  • no_nor_if_spherical

  • no_repeating_if_setup

  • not_curvilinear_if_ray

field startup: STARTUP | None = None
Validated by:
  • alp_is_zero_if_spherical

  • cgrid_contain_inpgrids

  • group_within_cgrid

  • layer_defined_if_no_mud_inpgrid

  • locations_2d

  • no_nor_if_spherical

  • no_repeating_if_setup

  • not_curvilinear_if_ray

field template: str = '/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/rompy/templates/swancomp'

The template for SWAN.

Validated by:
  • alp_is_zero_if_spherical

  • cgrid_contain_inpgrids

  • group_within_cgrid

  • layer_defined_if_no_mud_inpgrid

  • locations_2d

  • no_nor_if_spherical

  • no_repeating_if_setup

  • not_curvilinear_if_ray

validator alp_is_zero_if_spherical  »  all fields[source]

Ensure alp is zero when using spherical coordinates.

validator cgrid_contain_inpgrids  »  all fields[source]

Ensure all inpgrids are inside the cgrid area.

validator group_within_cgrid  »  all fields[source]

Ensure group indices are contained in computational grid.

validator layer_defined_if_no_mud_inpgrid  »  all fields[source]

Ensure layer is set in MUD command if not defined with INPGRID MUD.

validator locations_2d  »  all fields[source]

Ensure Location components not used in 1D mode.

validator no_nor_if_spherical  »  all fields[source]

Ensure SET nor is not prescribed when using spherical coordinates.

validator no_repeating_if_setup  »  all fields[source]

Ensure COORD repeating not set when using set-up.

validator not_curvilinear_if_ray  »  all fields[source]

Ensure bottom and water level grids are not curvilinear for RAY.

transm_msc_mdc() SwanConfigComponents[source]

Ensure the number of transmission coefficients match msc and mdc.

property grid

Define a SwanGrid from the cgrid field.

Grid#

pydantic model rompy.swan.grid.SwanGrid[source]

Regular SWAN grid in geographic space.

Fields:
Validators:
field dx: float | None = None

Spacing between grid points in the x direction

Validated by:
field dy: float | None = None

Spacing between grid points in the y direction

Validated by:
field exc: float | None = None

Missing value

Validated by:
field grid_type: Literal['REG', 'CURV'] = 'REG'

Type of grid (REG=regular, CURV=curvilinear)

Validated by:
field gridfile: str | None = None

Name of grid file to load

Constraints:
  • max_length = 36

Validated by:
field nx: int | None = None

Number of grid points in the x direction

Validated by:
field ny: int | None = None

Number of grid points in the y direction

Validated by:
field rot: float | None = 0.0

Rotation angle of the grid in degrees

Validated by:
field x0: float | None = None

X coordinate of the grid origin

Validated by:
field y0: float | None = None

Y coordinate of the grid origin

Validated by:
bbox(buffer=0.0) Bbox

Returns a bounding box for the spatial grid

This function returns a list [ll_x, ll_y, ur_x, ur_y] where ll_x, ll_y (ur_x, ur_y) are the lower left (upper right) x and y coordinates bounding box of the model domain

boundary(*args, **kwargs) tuple[source]

Returns the grid boundary polygon.

Override the parent method to use the actual points from the regular grid boundary instead of the convex hull which is not always the boundary.

boundary_points(spacing=None, tolerance=0.2) tuple

Returns array of coordinates from boundary polygon.

Parameters:
  • tolerance (float) – Simplify polygon shape based on maximum distance from original geometry, see https://shapely.readthedocs.io/en/stable/manual.html#object.simplify.

  • spacing (float) – If specified, points are returned evenly spaced along the boundary at the specified spacing, otherwise all points are returned.

  • Returns

  • --------

  • points (tuple) – Tuple of x and y coordinates of the boundary points.

classmethod from_component(component: GRIDREGULAR) SwanGrid[source]

Swan grid from an existing component.

Parameters:

component (GRIDREGULAR) – A GRIDREGULAR SWAN component.

Returns:

A SwanGrid object.

Return type:

SwanGrid

validator generate  »  all fields

Generate the grid from the provided parameters.

nearby_spectra(ds_spec, dist_thres=0.05, plot=True)[source]

Find points nearby and project to the boundary

Parameters:
  • ds_spec (xarray.Dataset) –

    an XArray dataset of wave spectra at a number of points. Dataset variable names standardised using wavespectra.read_* functions.

    See https://wavespectra.readthedocs.io/en/latest/api.html#input-functions

  • dist_thres (float, optional [Default: 0.05]) – Maximum distance to translate the input spectra to the grid boundary

  • plot (boolean, optional [Default: True]) – Generate a plot that shows the applied projections

Returns:

A subset of ds_spec with lat and lon coordinates projected to the boundary

Return type:

xarray.Dataset

plot(ax=None, figsize=None, fscale=10, buffer=0.1, borders=True, land=True, coastline=True)

Plot the grid

validator validate_curvilinear_grid  »  all fields[source]
validator validate_grid_type  »  grid_type[source]
property cgrid
property cgrid_read
property component

Return the respective SWAN component for this grid.

property inpgrid
property maxx: float
property maxy: float
property minx: float
property miny: float
property x: ndarray
property xlen
property y: ndarray
property ylen

Data#

pydantic model rompy.swan.data.SwanDataGrid[source]

This class is used to write SWAN data from a dataset.

Fields:
Validators:
field buffer: float = 0.0

Space to buffer the grid bounding box if filter_grid is True

Validated by:
field coords: DatasetCoords | None = DatasetCoords(t='time', x='longitude', y='latitude', z='depth')

Names of the coordinates in the dataset

Validated by:
field crop_data: bool = True

Update crop filters from Grid and Time objects if passed to get method

Validated by:
field fac: float = 1.0

SWAN multiplies all values that are read from file by fac. For instance if the values are given in unit decimeter, one should make fac=0.1 to obtain values in m. To change sign use a negative fac

Validated by:
field filter: Filter | None [Optional]

Optional filter specification to apply to the dataset

Validated by:
field id: str = 'data'

Unique identifier for this data source

Validated by:
field link: bool = False

Whether to create a symbolic link instead of copying the file

Validated by:
field model_type: Literal['data_grid'] = 'data_grid'

Model type discriminator

Validated by:
field source: DATA_SOURCE_MODELS [Required]

Source reader, must return an xarray dataset in the open method

Validated by:
field time_buffer: list[int] = [0, 0]

Number of source data timesteps to buffer the time range if filter_time is True

Validated by:
field var: GridOptions [Required]

SWAN input grid name

Validated by:
field variables: list[str] | None = []

Subset of variables to extract from the dataset

Validated by:
field z1: str | None = None

Name of the data variable in dataset representing either a scaler parameter or the u-componet of a vector field

Validated by:
field z2: str | None = None

Name of the data variable in dataset representing the v-componet of a vector field

Validated by:
validator ensure_z1_in_data_vars  »  all fields[source]
get(destdir: str | Path, grid: SwanGrid | None = None, time: TimeRange | None = None) Path[source]

Write the data source to a new location.

Parameters:
  • destdir (str | Path) – The destination directory to write the netcdf data to.

  • grid (SwanGrid, optional) – The grid to filter the data to, only used if self.filter_grid is True.

  • time (TimeRange, optional) – The times to filter the data to, only used if self.filter_time is True.

Returns:

cmd – The command line string with the INPGRID/READINP commands ready to be written to the SWAN input file.

Return type:

str

Note

The data are assumed to not have been rotated. We cannot use the grid.rot attr as this is the rotation from the model grid object which is not necessarily the same as the rotation of the data.

plot(param, isel={}, model_grid=None, cmap='turbo', figsize=None, fscale=10, borders=True, land=True, coastline=True, **kwargs)

Plot the grid.

property ds

Return the xarray dataset for this data source.

property outfile: str
rompy.swan.data.dset_to_swan(dset: Dataset, output_file: str, variables: list, fmt: str = '%4.2f', fill_value: float = -99.0, time_dim='time')[source]

Convert xarray Dataset into SWAN ASCII file.

Parameters:
  • dset (xr.Dataset) – Dataset to write in SWAN ASCII format.

  • output_file (str) – Local file name for the ascii output file.

  • variables (list) – Variables to write to ascii.

  • fmt (str) – String float formatter.

  • fill_value (float) – Fill value.

  • time_dim (str) – Name of the time dimension if available in the dataset.

Boundary#

SWAN boundary classes.

pydantic model rompy.swan.boundary.Boundnest1[source]

SWAN BOUNDNEST1 NEST data class.

Fields:
Validators:
field buffer: float = 2.0

Space to buffer the grid bounding box if filter_grid is True

field coords: DatasetCoords | None = DatasetCoords(t='time', x='longitude', y='latitude', z='depth')

Names of the coordinates in the dataset

field crop_data: bool = True

Update crop filter from Time object if passed to get method

field filter: Filter | None [Optional]

Optional filter specification to apply to the dataset

field grid_type: Literal['boundary_wave_station'] = 'boundary_wave_station'

Model type discriminator

field id: str [Required]

Unique identifier for this data source

field link: bool = False

Whether to create a symbolic link instead of copying the file

field model_type: Literal['boundnest1', 'BOUNDNEST1'] = 'boundnest1'

Model type discriminator

field rectangle: Literal['closed', 'open'] = 'closed'

Defines whether boundary is defined over an closed or open rectangle

field sel_method: Literal['idw', 'nearest'] = 'idw'

Wavespectra method to use for selecting boundary points from the dataset

field sel_method_kwargs: dict = {}

Keyword arguments for sel_method

field source: SPEC_BOUNDARY_SOURCE_MODELS [Required]

Dataset source reader, must return a wavespectra-enabled xarray dataset in the open method

field spacing: float | Literal['parent'] | None = None

Spacing between points along the grid boundary to retrieve data for. If None (default), points are defined from the the actual grid object passed to the get method. If ‘parent’, the resolution of the parent dataset is used to define the spacing.

Validated by:
  • spacing_gt_zero

field time_buffer: list[int] = [0, 0]

Number of source data timesteps to buffer the time range if filter_time is True

field variables: list[str] | None = []

Subset of variables to extract from the dataset

get(destdir: str, grid: SwanGrid, time: TimeRange | None = None) str[source]

Write the data source to a new location.

Parameters:
  • destdir (str | Path) – Destination directory for the SWAN ASCII file.

  • grid (RegularGrid) – Grid instance to use for selecting the boundary points.

  • time (TimeRange, optional) – The times to filter the data to, only used if self.crop_data is True.

Returns:

  • filename (Path) – The filename of the written boundary file.

  • cmd (str) – Boundary command string to render in the SWAN INPUT file

plot(model_grid=None, cmap='turbo', fscale=10, ax=None, **kwargs)

Plot the grid.

plot_boundary(grid=None, fscale=10, ax=None, **kwargs)

Plot the boundary points on a map.

validator spacing_gt_zero  »  spacing
property ds

Return the filtered xarray dataset instance.

property outfile: str
pydantic model rompy.swan.boundary.BoundspecBase[source]

Base class for SWAN BOUNDSPEC data classes.

Fields:
  • buffer ()

  • coords ()

  • crop_data ()

  • file_type (Literal['tpar', 'spec2d'])

  • filter ()

  • grid_type ()

  • id ()

  • link ()

  • model_type (Literal['boundspecbase', 'BOUNDSPECBASE'])

  • sel_method ()

  • sel_method_kwargs ()

  • shapespec (rompy.swan.subcomponents.spectrum.SHAPESPEC)

  • source ()

  • spacing ()

  • time_buffer ()

  • variable (bool)

  • variables ()

Validators:
  • spacing_gt_zero » spacing

  • unique_not_supported » sel_method_kwargs

  • variable_not_implemented » variable

field buffer: float = 2.0

Space to buffer the grid bounding box if filter_grid is True

field coords: DatasetCoords | None = DatasetCoords(t='time', x='longitude', y='latitude', z='depth')

Names of the coordinates in the dataset

field crop_data: bool = True

Update crop filter from Time object if passed to get method

field file_type: Literal['tpar', 'spec2d'] = 'tpar'

The type of file to write

field filter: Filter | None [Optional]

Optional filter specification to apply to the dataset

field grid_type: Literal['boundary_wave_station'] = 'boundary_wave_station'

Model type discriminator

field id: str [Required]

Unique identifier for this data source

field link: bool = False

Whether to create a symbolic link instead of copying the file

field model_type: Literal['boundspecbase', 'BOUNDSPECBASE'] = 'boundspecbase'

Model type discriminator

field sel_method: Literal['idw', 'nearest'] = 'idw'

Wavespectra method to use for selecting boundary points from the dataset

field sel_method_kwargs: dict = {}

Keyword arguments for sel_method

Validated by:
  • unique_not_supported

field shapespec: SHAPESPEC = SHAPESPEC(model_type='shapespec', shape=JONSWAP(model_type='jonswap', gamma=3.3), per_type='peak', dspr_type='degrees')

Spectral shape specification

field source: SPEC_BOUNDARY_SOURCE_MODELS [Required]

Dataset source reader, must return a wavespectra-enabled xarray dataset in the open method

field spacing: float | Literal['parent'] | None = None

Spacing between points along the grid boundary to retrieve data for. If None (default), points are defined from the the actual grid object passed to the get method. If ‘parent’, the resolution of the parent dataset is used to define the spacing.

Validated by:
  • spacing_gt_zero

field time_buffer: list[int] = [0, 0]

Number of source data timesteps to buffer the time range if filter_time is True

field variable: bool = False

Whether the spectra can vary along the side

Validated by:
  • variable_not_implemented

field variables: list[str] | None = []

Subset of variables to extract from the dataset

get(destdir: str | Path, grid: RegularGrid, time: TimeRange | None = None) str

Write the selected boundary data to a netcdf file.

Parameters:
  • destdir (str | Path) – Destination directory for the netcdf file.

  • grid (RegularGrid) – Grid instance to use for selecting the boundary points.

  • time (TimeRange, optional) – The times to filter the data to, only used if self.crop_data is True.

Returns:

outfile – Path to the netcdf file.

Return type:

Path

plot(model_grid=None, cmap='turbo', fscale=10, ax=None, **kwargs)

Plot the grid.

plot_boundary(grid=None, fscale=10, ax=None, **kwargs)

Plot the boundary points on a map.

validator spacing_gt_zero  »  spacing
validator unique_not_supported  »  sel_method_kwargs[source]
validator variable_not_implemented  »  variable[source]
property ds

Return the filtered xarray dataset instance.

property dspr: str
property outfile: str
property per: str
property tpar: DataFrame

TPAR dataframe for the _ds attr.

pydantic model rompy.swan.boundary.BoundspecSegmentXY[source]

SWAN BOUNDSPEC SEGMENT data class.

TODO: Handle side definition on a rotated grid. TODO: Should SIDE VARIABE be supported? TODO: Support option to choose between mid-point or averaging? TODO: Does PAR need to be supported? Guess not as nonstationary isn’t supported TODO: If SIDES, ensure continuous

Note

Segments are defined from adjacent point locations so the order in which the points are defined is important. When using SIDES, please ensure SIDES are adjacent to each other and have correct directions (ccw or clockwise) accordint to the order in which each side is prescribed.

Note

The ‘spec1d’ file type is not supported yet.

Fields:
  • buffer ()

  • coords ()

  • crop_data ()

  • file_type ()

  • filter ()

  • grid_type ()

  • id ()

  • link ()

  • location (rompy.swan.subcomponents.boundary.SIDE | rompy.swan.subcomponents.boundary.SIDES | rompy.swan.subcomponents.base.XY)

  • model_type (Literal['boundspecside', 'BOUNDSPECSIDE'])

  • sel_method ()

  • sel_method_kwargs ()

  • shapespec ()

  • source ()

  • spacing ()

  • time_buffer ()

  • variable ()

  • variables ()

Validators:
  • spacing_gt_zero » spacing

  • unique_not_supported » sel_method_kwargs

  • variable_not_implemented » variable

field buffer: float = 2.0

Space to buffer the grid bounding box if filter_grid is True

field coords: DatasetCoords | None = DatasetCoords(t='time', x='longitude', y='latitude', z='depth')

Names of the coordinates in the dataset

field crop_data: bool = True

Update crop filter from Time object if passed to get method

field file_type: Literal['tpar', 'spec2d'] = 'tpar'

The type of file to write

field filter: Filter | None [Optional]

Optional filter specification to apply to the dataset

field grid_type: Literal['boundary_wave_station'] = 'boundary_wave_station'

Model type discriminator

field id: str [Required]

Unique identifier for this data source

field link: bool = False

Whether to create a symbolic link instead of copying the file

field location: SIDE | SIDES | XY [Required]

The side of the grid to apply the boundary to

field model_type: Literal['boundspecside', 'BOUNDSPECSIDE'] = 'boundspecside'

Model type discriminator

field sel_method: Literal['idw', 'nearest'] = 'idw'

Wavespectra method to use for selecting boundary points from the dataset

field sel_method_kwargs: dict = {}

Keyword arguments for sel_method

Validated by:
  • unique_not_supported

field shapespec: SHAPESPEC = SHAPESPEC(model_type='shapespec', shape=JONSWAP(model_type='jonswap', gamma=3.3), per_type='peak', dspr_type='degrees')

Spectral shape specification

field source: SPEC_BOUNDARY_SOURCE_MODELS [Required]

Dataset source reader, must return a wavespectra-enabled xarray dataset in the open method

field spacing: float | Literal['parent'] | None = None

Spacing between points along the grid boundary to retrieve data for. If None (default), points are defined from the the actual grid object passed to the get method. If ‘parent’, the resolution of the parent dataset is used to define the spacing.

Validated by:
  • spacing_gt_zero

field time_buffer: list[int] = [0, 0]

Number of source data timesteps to buffer the time range if filter_time is True

field variable: bool = False

Whether the spectra can vary along the side

Validated by:
  • variable_not_implemented

field variables: list[str] | None = []

Subset of variables to extract from the dataset

get(destdir: str, grid: SwanGrid, time: TimeRange | None = None) str[source]

Write the data source to a new location.

Parameters:
  • destdir (str | Path) – Destination directory for the SWAN ASCII file.

  • grid (RegularGrid) – Grid instance to use for selecting the boundary points.

  • time (TimeRange, optional) – The times to filter the data to, only used if self.crop_data is True.

Returns:

  • filenames (list) – The filenames of the written boundary files.

  • cmd (str) – Boundary command string to render in the SWAN INPUT file

plot(model_grid=None, cmap='turbo', fscale=10, ax=None, **kwargs)

Plot the grid.

plot_boundary(grid=None, fscale=10, ax=None, **kwargs)

Plot the boundary points on a map.

validator spacing_gt_zero  »  spacing
validator unique_not_supported  »  sel_method_kwargs
validator variable_not_implemented  »  variable
property ds

Return the filtered xarray dataset instance.

property dspr: str
property outfile: str
property per: str
property tpar: DataFrame

TPAR dataframe for the _ds attr.

pydantic model rompy.swan.boundary.BoundspecSide[source]

SWAN BOUNDSPEC SIDE data class.

TODO: Handle side definition on a rotated grid. TODO: Should SIDE VARIABE be supported? TODO: Support option to choose between mid-point or averaging? TODO: Does PAR need to be supported? Guess not as nonstationary isn’t supported

Note

The ‘spec1d’ file type is not supported yet.

Fields:
  • buffer ()

  • coords ()

  • crop_data ()

  • file_type ()

  • filter ()

  • grid_type ()

  • id ()

  • link ()

  • location (rompy.swan.subcomponents.boundary.SIDE)

  • model_type (Literal['boundspecside', 'BOUNDSPECSIDE'])

  • sel_method ()

  • sel_method_kwargs ()

  • shapespec ()

  • source ()

  • spacing ()

  • time_buffer ()

  • variable ()

  • variables ()

Validators:
  • spacing_gt_zero » spacing

  • unique_not_supported » sel_method_kwargs

  • variable_not_implemented » variable

field buffer: float = 2.0

Space to buffer the grid bounding box if filter_grid is True

field coords: DatasetCoords | None = DatasetCoords(t='time', x='longitude', y='latitude', z='depth')

Names of the coordinates in the dataset

field crop_data: bool = True

Update crop filter from Time object if passed to get method

field file_type: Literal['tpar', 'spec2d'] = 'tpar'

The type of file to write

field filter: Filter | None [Optional]

Optional filter specification to apply to the dataset

field grid_type: Literal['boundary_wave_station'] = 'boundary_wave_station'

Model type discriminator

field id: str [Required]

Unique identifier for this data source

field link: bool = False

Whether to create a symbolic link instead of copying the file

field location: SIDE [Required]

The side of the grid to apply the boundary to

field model_type: Literal['boundspecside', 'BOUNDSPECSIDE'] = 'boundspecside'

Model type discriminator

field sel_method: Literal['idw', 'nearest'] = 'idw'

Wavespectra method to use for selecting boundary points from the dataset

field sel_method_kwargs: dict = {}

Keyword arguments for sel_method

Validated by:
  • unique_not_supported

field shapespec: SHAPESPEC = SHAPESPEC(model_type='shapespec', shape=JONSWAP(model_type='jonswap', gamma=3.3), per_type='peak', dspr_type='degrees')

Spectral shape specification

field source: SPEC_BOUNDARY_SOURCE_MODELS [Required]

Dataset source reader, must return a wavespectra-enabled xarray dataset in the open method

field spacing: float | Literal['parent'] | None = None

Spacing between points along the grid boundary to retrieve data for. If None (default), points are defined from the the actual grid object passed to the get method. If ‘parent’, the resolution of the parent dataset is used to define the spacing.

Validated by:
  • spacing_gt_zero

field time_buffer: list[int] = [0, 0]

Number of source data timesteps to buffer the time range if filter_time is True

field variable: bool = False

Whether the spectra can vary along the side

Validated by:
  • variable_not_implemented

field variables: list[str] | None = []

Subset of variables to extract from the dataset

get(destdir: str, grid: SwanGrid, time: TimeRange | None = None) str[source]

Write the data source to a new location.

Parameters:
  • destdir (str | Path) – Destination directory for the SWAN ASCII file.

  • grid (RegularGrid) – Grid instance to use for selecting the boundary points.

  • time (TimeRange, optional) – The times to filter the data to, only used if self.crop_data is True.

Returns:

  • filename (Path) – The filename of the written boundary file.

  • cmd (str) – Boundary command string to render in the SWAN INPUT file

plot(model_grid=None, cmap='turbo', fscale=10, ax=None, **kwargs)

Plot the grid.

plot_boundary(grid=None, fscale=10, ax=None, **kwargs)

Plot the boundary points on a map.

validator spacing_gt_zero  »  spacing
validator unique_not_supported  »  sel_method_kwargs
validator variable_not_implemented  »  variable
property ds

Return the filtered xarray dataset instance.

property dspr: str
property outfile: str
property per: str
property tpar: DataFrame

TPAR dataframe for the _ds attr.

rompy.swan.boundary.write_tpar(df: DataFrame, filename: str | Path)[source]

Write TPAR file.

Parameters:
  • df (pandas.DataFrame) – TPAR dataframe.

  • filename (str | Path) – Filename to write to.

Types#

Types for the swan wrapper.

class rompy.swan.types.BlockOptions(value)[source]

Valid options for block output parameters.

HSIGN

Significant wave height (in m).

Type:

“hsign”

HSWELL

Swell wave height (in m).

Type:

“hswell”

DIR

Mean wave direction (in degrees).

Type:

“dir”

PDIR

Peak wave direction (in degrees).

Type:

“pdir”

TDIR

Direction of energy transport (in degrees).

Type:

“tdir”

TM01

Mean absolute wave period (in s).

Type:

“tm01”

RTM01

Mean relative wave period (in s).

Type:

“rtm01”

RTP

Peak period of the (relative frequency) variance density spectrum (in s).

Type:

“rtp”

TPS

Smoothed peak period (in s).

Type:

“tps”

PER

Mean absolute wave period (in s).

Type:

“per”

RPER

Mean relative wave period (in s).

Type:

“rper”

TMM10

Mean absolute wave period (in s).

Type:

“tmm10”

RTMM10

Mean relative wave period (in s).

Type:

“rtmm10”

TM02

Mean absolute zero-crossing period (in s).

Type:

“tm02”

FSPR

The normalised width of the frequency spectrum.

Type:

“fspr”

DSPR

Directional spreading of the waves (in degrees).

Type:

“dspr”

QP

Peakedness of the wave spectrum (dimensionless).

Type:

“qp”

DEPTH

Water depth (in m).

Type:

“depth”

WATLEV

Water level (in m).

Type:

“watlev”

BOTLEV

Bottom level (in m).

Type:

“botlev”

VEL

Current velocity (vector; in m/s).

Type:

“vel”

FRCOEF

Friction coefficient (equal to cfw or kn in command FRICTION).

Type:

“frcoef”

WIND

Wind velocity (vector; in m/s).

Type:

“wind”

AICE

Ice concentration (as a fraction from 0 to 1).

Type:

“aice”

PROPAGAT

Sum of PROPXY, PROPTHETA and PROPSIGMA (in W/m2 or m2/s).

Type:

“propagat”

PROPXY

Energy propagation in geographic space; sum of x- and y-direction (in W/m2 or m2/s).

Type:

“propxy”

PROPTHETA

Energy propagation in theta space (in W/m2 or m2/s).

Type:

“proptheta”

PROPSIGMA

Energy propagation in sigma space (in W/m2 or m2/s).

Type:

“propsigma”

GENERAT

Total energy generation (in W/m2 or m2/s).

Type:

“generat”

GENWIND

Energy generation due to wind (in W/m2 or m2/s).

Type:

“genwind”

REDIST

Total energy redistribution (in W/m2 or m2/s).

Type:

“redist”

REDQUAD

Energy redistribution due to quadruplets (in W/m2 or m2/s).

Type:

“redquad”

REDTRIAD

Energy redistribution due to triads (in W/m2 or m2/s).

Type:

“redtriad”

DISSIP

Total energy dissipation (in W/m2 or m2/s).

Type:

“dissip”

DISBOT

Energy dissipation due to bottom friction (in W/m2 or m2/s).

Type:

“disbot”

DISSURF

Energy dissipation due to surf breaking (in W/m2 or m2/s).

Type:

“dissurf”

DISWCAP

Energy dissipation due to whitecapping (in W/m2 or m2/s).

Type:

“diswcap”

DISSWELL

Energy dissipation due to swell dissipation (in W/m2 or m2/s).

Type:

“disswell”

DISVEG

Energy dissipation due to vegetation (in W/m2 or m2/s).

Type:

“disveg”

DISMUD

Energy dissipation due to mud (in W/m2 or m2/s).

Type:

“dismud”

DISICE

Energy dissipation due to sea ice (in W/m2 or m2/s).

Type:

“disice”

RADSTR

Energy transfer between waves and currents due to radiation stress (in W/m2 or m2/s).

Type:

“radstr”

QB

Fraction of breaking waves due to depth-induced breaking.

Type:

“qb”

TRANSP

Transport of energy (vector; in W/m2 or m2/s).

Type:

“transp”

FORCE

Wave-induced force per unit surface area (vector; in N/m2).

Type:

“force”

UBOT

The rms-value of the maxima of the orbital velocity near the bottom (in m/s).

Type:

“ubot”

URMS

The rms-value of the orbital velocity near the bottom (in m/s).

Type:

“urms”

TMBOT

The bottom wave period (in s).

Type:

“tmbot”

WLENGTH

Average wave length (in m).

Type:

“wlength”

LWAVP

Peak wave length (in m).

Type:

“lwavp”

STEEPNESS

Average wave steepness (dimensionless).

Type:

“steepness”

BFI

Benjamin-Feir index (dimensionless).

Type:

“bfi”

NPLANTS

Number of plants per square meter.

Type:

“nplants”

DHSIGN

Difference in significant wave height from the last two iterations (in m).

Type:

“dhsign”

DRTM01

Difference in average wave period (RTM01) from the last two iterations (in s).

Type:

“drtm01”

LEAK

Numerical loss of energy equal to cthetaE(omega,theta) across boundaries.

Type:

“leak”

TIME

Full date-time string as part of line used in TABLE only.

Type:

“time”

TSEC

Time in seconds with respect to a reference time (see command QUANTITY).

Type:

“tsec”

XP

The x-coordinate in the problem coordinate system of the output location.

Type:

“xp”

YP

The y-coordinate in the problem coordinate system of the output location.

Type:

“yp”

DIST

If output has been requested along a curve then the distance along the curve can be obtained with the command TABLE. DIST is the distance along the curve measured from teh first point on the curve to the output location on the curve in meters (also in the case of spherical coordinates).

Type:

“dist”

SETUP

Set-up due to waves (in m).

Type:

“setup”

PTHSIGN

Watershed partitions of the significant wave height (in m).

Type:

“pthsign”

PTRTP

Watershed partitions of the relative peak period (in s).

Type:

“ptrtp”

PTWLEN

Watershed partitions of the average wave length (in m).

Type:

“ptwlen”

PTDIR

Watershed partitions of the peak wave direction (in degrees).

Type:

“ptdir”

PTDSPR

Watershed partitions of the directional spreading (in degrees).

Type:

“ptdspr”

PTWFRAC

Watershed partitions of the wind fraction (dimensionless).

Type:

“ptwfrac”

PTSTEEPNE

Watershed partition of the wave steepness (dimensionless).

Type:

“ptsteepne”

PARTITION

The raw spectral partition for wave system tracking post-processing.

Type:

“partition”

Note

Energy given in W/m2 or m2/s depending on command SET.

Note

UBOT and URMS required command FRICTION to be used. If friction is ignored in the computation, then one should use the command FRICTION with the value of the friction set to zero (e.g., FRICTION COLLINS 0).

capitalize()

Return a capitalized version of the string.

More specifically, make the first character have upper case and the rest lower case.

casefold()

Return a version of the string suitable for caseless comparisons.

center(width, fillchar=' ', /)

Return a centered string of length width.

Padding is done using the specified fill character (default is a space).

count(sub[, start[, end]]) int

Return the number of non-overlapping occurrences of substring sub in string S[start:end]. Optional arguments start and end are interpreted as in slice notation.

encode(encoding='utf-8', errors='strict')

Encode the string using the codec registered for encoding.

encoding

The encoding in which to encode the string.

errors

The error handling scheme to use for encoding errors. The default is ‘strict’ meaning that encoding errors raise a UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and ‘xmlcharrefreplace’ as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors.

endswith(suffix[, start[, end]]) bool

Return True if S ends with the specified suffix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. suffix can also be a tuple of strings to try.

expandtabs(tabsize=8)

Return a copy where all tab characters are expanded using spaces.

If tabsize is not given, a tab size of 8 characters is assumed.

find(sub[, start[, end]]) int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

format(*args, **kwargs) str

Return a formatted version of S, using substitutions from args and kwargs. The substitutions are identified by braces (‘{’ and ‘}’).

format_map(mapping) str

Return a formatted version of S, using substitutions from mapping. The substitutions are identified by braces (‘{’ and ‘}’).

index(sub[, start[, end]]) int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

isalnum()

Return True if the string is an alpha-numeric string, False otherwise.

A string is alpha-numeric if all characters in the string are alpha-numeric and there is at least one character in the string.

isalpha()

Return True if the string is an alphabetic string, False otherwise.

A string is alphabetic if all characters in the string are alphabetic and there is at least one character in the string.

isascii()

Return True if all characters in the string are ASCII, False otherwise.

ASCII characters have code points in the range U+0000-U+007F. Empty string is ASCII too.

isdecimal()

Return True if the string is a decimal string, False otherwise.

A string is a decimal string if all characters in the string are decimal and there is at least one character in the string.

isdigit()

Return True if the string is a digit string, False otherwise.

A string is a digit string if all characters in the string are digits and there is at least one character in the string.

isidentifier()

Return True if the string is a valid Python identifier, False otherwise.

Call keyword.iskeyword(s) to test whether string s is a reserved identifier, such as “def” or “class”.

islower()

Return True if the string is a lowercase string, False otherwise.

A string is lowercase if all cased characters in the string are lowercase and there is at least one cased character in the string.

isnumeric()

Return True if the string is a numeric string, False otherwise.

A string is numeric if all characters in the string are numeric and there is at least one character in the string.

isprintable()

Return True if the string is printable, False otherwise.

A string is printable if all of its characters are considered printable in repr() or if it is empty.

isspace()

Return True if the string is a whitespace string, False otherwise.

A string is whitespace if all characters in the string are whitespace and there is at least one character in the string.

istitle()

Return True if the string is a title-cased string, False otherwise.

In a title-cased string, upper- and title-case characters may only follow uncased characters and lowercase characters only cased ones.

isupper()

Return True if the string is an uppercase string, False otherwise.

A string is uppercase if all cased characters in the string are uppercase and there is at least one cased character in the string.

join(iterable, /)

Concatenate any number of strings.

The string whose method is called is inserted in between each given string. The result is returned as a new string.

Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’

ljust(width, fillchar=' ', /)

Return a left-justified string of length width.

Padding is done using the specified fill character (default is a space).

lower()

Return a copy of the string converted to lowercase.

lstrip(chars=None, /)

Return a copy of the string with leading whitespace removed.

If chars is given and not None, remove characters in chars instead.

static maketrans()

Return a translation table usable for str.translate().

If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result.

partition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing the original string and two empty strings.

removeprefix(prefix, /)

Return a str with the given prefix string removed if present.

If the string starts with the prefix string, return string[len(prefix):]. Otherwise, return a copy of the original string.

removesuffix(suffix, /)

Return a str with the given suffix string removed if present.

If the string ends with the suffix string and that suffix is not empty, return string[:-len(suffix)]. Otherwise, return a copy of the original string.

replace(old, new, count=-1, /)

Return a copy with all occurrences of substring old replaced by new.

count

Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.

If the optional argument count is given, only the first count occurrences are replaced.

rfind(sub[, start[, end]]) int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

rindex(sub[, start[, end]]) int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

rjust(width, fillchar=' ', /)

Return a right-justified string of length width.

Padding is done using the specified fill character (default is a space).

rpartition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing two empty strings and the original string.

rsplit(sep=None, maxsplit=-1)

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including \n \r \t \f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits (starting from the left). -1 (the default value) means no limit.

Splitting starts at the end of the string and works to the front.

rstrip(chars=None, /)

Return a copy of the string with trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

split(sep=None, maxsplit=-1)

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including \n \r \t \f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits (starting from the left). -1 (the default value) means no limit.

Note, str.split() is mainly useful for data that has been intentionally delimited. With natural text that includes punctuation, consider using the regular expression module.

splitlines(keepends=False)

Return a list of the lines in the string, breaking at line boundaries.

Line breaks are not included in the resulting list unless keepends is given and true.

startswith(prefix[, start[, end]]) bool

Return True if S starts with the specified prefix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. prefix can also be a tuple of strings to try.

strip(chars=None, /)

Return a copy of the string with leading and trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

swapcase()

Convert uppercase characters to lowercase and lowercase characters to uppercase.

title()

Return a version of the string where each word is titlecased.

More specifically, words start with uppercased characters and all remaining cased characters have lower case.

translate(table, /)

Replace each character in the string using the given translation table.

table

Translation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None.

The table must implement lookup/indexing via __getitem__, for instance a dictionary or list. If this operation raises LookupError, the character is left untouched. Characters mapped to None are deleted.

upper()

Return a copy of the string converted to uppercase.

zfill(width, /)

Pad a numeric string with zeros on the left, to fill a field of the given width.

The string is never truncated.

class rompy.swan.types.BoundShapeOptions(value)[source]

Valid options for the boundary shape type.

JONSWAP

JONSWAP spectrum.

Type:

“jonswap”

PM

Pierson-Moskowitz spectrum.

Type:

“pm”

GAUSS

Gaussian spectrum.

Type:

“gauss”

BIN

Energy at a single bin spectrum.

Type:

“bin”

TMA

TMA spectrum.

Type:

“tma”

capitalize()

Return a capitalized version of the string.

More specifically, make the first character have upper case and the rest lower case.

casefold()

Return a version of the string suitable for caseless comparisons.

center(width, fillchar=' ', /)

Return a centered string of length width.

Padding is done using the specified fill character (default is a space).

count(sub[, start[, end]]) int

Return the number of non-overlapping occurrences of substring sub in string S[start:end]. Optional arguments start and end are interpreted as in slice notation.

encode(encoding='utf-8', errors='strict')

Encode the string using the codec registered for encoding.

encoding

The encoding in which to encode the string.

errors

The error handling scheme to use for encoding errors. The default is ‘strict’ meaning that encoding errors raise a UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and ‘xmlcharrefreplace’ as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors.

endswith(suffix[, start[, end]]) bool

Return True if S ends with the specified suffix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. suffix can also be a tuple of strings to try.

expandtabs(tabsize=8)

Return a copy where all tab characters are expanded using spaces.

If tabsize is not given, a tab size of 8 characters is assumed.

find(sub[, start[, end]]) int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

format(*args, **kwargs) str

Return a formatted version of S, using substitutions from args and kwargs. The substitutions are identified by braces (‘{’ and ‘}’).

format_map(mapping) str

Return a formatted version of S, using substitutions from mapping. The substitutions are identified by braces (‘{’ and ‘}’).

index(sub[, start[, end]]) int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

isalnum()

Return True if the string is an alpha-numeric string, False otherwise.

A string is alpha-numeric if all characters in the string are alpha-numeric and there is at least one character in the string.

isalpha()

Return True if the string is an alphabetic string, False otherwise.

A string is alphabetic if all characters in the string are alphabetic and there is at least one character in the string.

isascii()

Return True if all characters in the string are ASCII, False otherwise.

ASCII characters have code points in the range U+0000-U+007F. Empty string is ASCII too.

isdecimal()

Return True if the string is a decimal string, False otherwise.

A string is a decimal string if all characters in the string are decimal and there is at least one character in the string.

isdigit()

Return True if the string is a digit string, False otherwise.

A string is a digit string if all characters in the string are digits and there is at least one character in the string.

isidentifier()

Return True if the string is a valid Python identifier, False otherwise.

Call keyword.iskeyword(s) to test whether string s is a reserved identifier, such as “def” or “class”.

islower()

Return True if the string is a lowercase string, False otherwise.

A string is lowercase if all cased characters in the string are lowercase and there is at least one cased character in the string.

isnumeric()

Return True if the string is a numeric string, False otherwise.

A string is numeric if all characters in the string are numeric and there is at least one character in the string.

isprintable()

Return True if the string is printable, False otherwise.

A string is printable if all of its characters are considered printable in repr() or if it is empty.

isspace()

Return True if the string is a whitespace string, False otherwise.

A string is whitespace if all characters in the string are whitespace and there is at least one character in the string.

istitle()

Return True if the string is a title-cased string, False otherwise.

In a title-cased string, upper- and title-case characters may only follow uncased characters and lowercase characters only cased ones.

isupper()

Return True if the string is an uppercase string, False otherwise.

A string is uppercase if all cased characters in the string are uppercase and there is at least one cased character in the string.

join(iterable, /)

Concatenate any number of strings.

The string whose method is called is inserted in between each given string. The result is returned as a new string.

Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’

ljust(width, fillchar=' ', /)

Return a left-justified string of length width.

Padding is done using the specified fill character (default is a space).

lower()

Return a copy of the string converted to lowercase.

lstrip(chars=None, /)

Return a copy of the string with leading whitespace removed.

If chars is given and not None, remove characters in chars instead.

static maketrans()

Return a translation table usable for str.translate().

If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result.

partition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing the original string and two empty strings.

removeprefix(prefix, /)

Return a str with the given prefix string removed if present.

If the string starts with the prefix string, return string[len(prefix):]. Otherwise, return a copy of the original string.

removesuffix(suffix, /)

Return a str with the given suffix string removed if present.

If the string ends with the suffix string and that suffix is not empty, return string[:-len(suffix)]. Otherwise, return a copy of the original string.

replace(old, new, count=-1, /)

Return a copy with all occurrences of substring old replaced by new.

count

Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.

If the optional argument count is given, only the first count occurrences are replaced.

rfind(sub[, start[, end]]) int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

rindex(sub[, start[, end]]) int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

rjust(width, fillchar=' ', /)

Return a right-justified string of length width.

Padding is done using the specified fill character (default is a space).

rpartition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing two empty strings and the original string.

rsplit(sep=None, maxsplit=-1)

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including \n \r \t \f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits (starting from the left). -1 (the default value) means no limit.

Splitting starts at the end of the string and works to the front.

rstrip(chars=None, /)

Return a copy of the string with trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

split(sep=None, maxsplit=-1)

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including \n \r \t \f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits (starting from the left). -1 (the default value) means no limit.

Note, str.split() is mainly useful for data that has been intentionally delimited. With natural text that includes punctuation, consider using the regular expression module.

splitlines(keepends=False)

Return a list of the lines in the string, breaking at line boundaries.

Line breaks are not included in the resulting list unless keepends is given and true.

startswith(prefix[, start[, end]]) bool

Return True if S starts with the specified prefix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. prefix can also be a tuple of strings to try.

strip(chars=None, /)

Return a copy of the string with leading and trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

swapcase()

Convert uppercase characters to lowercase and lowercase characters to uppercase.

title()

Return a version of the string where each word is titlecased.

More specifically, words start with uppercased characters and all remaining cased characters have lower case.

translate(table, /)

Replace each character in the string using the given translation table.

table

Translation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None.

The table must implement lookup/indexing via __getitem__, for instance a dictionary or list. If this operation raises LookupError, the character is left untouched. Characters mapped to None are deleted.

upper()

Return a copy of the string converted to uppercase.

zfill(width, /)

Pad a numeric string with zeros on the left, to fill a field of the given width.

The string is never truncated.

class rompy.swan.types.GridOptions(value)[source]

Valid options for the input grid type.

BOTTOM

Bottom level grid.

Type:

“bottom”

WLEVEL

Water level grid.

Type:

“wlevel”

CURRENT

Current field grid.

Type:

“current”

VX

Current field x-component grid.

Type:

“vx”

VY

Current field y-component grid.

Type:

“vy”

WIND

Wind velocity grid.

Type:

“wind”

WX

Wind velocity x-component grid.

Type:

“wx”

WY

Wind velocity y-component grid.

Type:

“wy”

FRICTION

Bottom friction grid.

Type:

“friction”

NPLANTS

Horizontally varying vegetation density grid.

Type:

“nplants”

TURBVISC

Horizontally varying turbulent viscosity grid.

Type:

“turbvisc”

MUDLAYER

Horizontally varying mud layer thickness grid.

Type:

“mudlayer”

AICE

Areal ice fraction grid, a number between 0 and 1.

Type:

“aice”

HICE

Ice thickness grid.

Type:

“hice”

HSS

Sea-swell significant wave height grid.

Type:

“hss”

TSS

Sea-swell mean wave period.

Type:

“tss”

capitalize()

Return a capitalized version of the string.

More specifically, make the first character have upper case and the rest lower case.

casefold()

Return a version of the string suitable for caseless comparisons.

center(width, fillchar=' ', /)

Return a centered string of length width.

Padding is done using the specified fill character (default is a space).

count(sub[, start[, end]]) int

Return the number of non-overlapping occurrences of substring sub in string S[start:end]. Optional arguments start and end are interpreted as in slice notation.

encode(encoding='utf-8', errors='strict')

Encode the string using the codec registered for encoding.

encoding

The encoding in which to encode the string.

errors

The error handling scheme to use for encoding errors. The default is ‘strict’ meaning that encoding errors raise a UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and ‘xmlcharrefreplace’ as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors.

endswith(suffix[, start[, end]]) bool

Return True if S ends with the specified suffix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. suffix can also be a tuple of strings to try.

expandtabs(tabsize=8)

Return a copy where all tab characters are expanded using spaces.

If tabsize is not given, a tab size of 8 characters is assumed.

find(sub[, start[, end]]) int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

format(*args, **kwargs) str

Return a formatted version of S, using substitutions from args and kwargs. The substitutions are identified by braces (‘{’ and ‘}’).

format_map(mapping) str

Return a formatted version of S, using substitutions from mapping. The substitutions are identified by braces (‘{’ and ‘}’).

index(sub[, start[, end]]) int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

isalnum()

Return True if the string is an alpha-numeric string, False otherwise.

A string is alpha-numeric if all characters in the string are alpha-numeric and there is at least one character in the string.

isalpha()

Return True if the string is an alphabetic string, False otherwise.

A string is alphabetic if all characters in the string are alphabetic and there is at least one character in the string.

isascii()

Return True if all characters in the string are ASCII, False otherwise.

ASCII characters have code points in the range U+0000-U+007F. Empty string is ASCII too.

isdecimal()

Return True if the string is a decimal string, False otherwise.

A string is a decimal string if all characters in the string are decimal and there is at least one character in the string.

isdigit()

Return True if the string is a digit string, False otherwise.

A string is a digit string if all characters in the string are digits and there is at least one character in the string.

isidentifier()

Return True if the string is a valid Python identifier, False otherwise.

Call keyword.iskeyword(s) to test whether string s is a reserved identifier, such as “def” or “class”.

islower()

Return True if the string is a lowercase string, False otherwise.

A string is lowercase if all cased characters in the string are lowercase and there is at least one cased character in the string.

isnumeric()

Return True if the string is a numeric string, False otherwise.

A string is numeric if all characters in the string are numeric and there is at least one character in the string.

isprintable()

Return True if the string is printable, False otherwise.

A string is printable if all of its characters are considered printable in repr() or if it is empty.

isspace()

Return True if the string is a whitespace string, False otherwise.

A string is whitespace if all characters in the string are whitespace and there is at least one character in the string.

istitle()

Return True if the string is a title-cased string, False otherwise.

In a title-cased string, upper- and title-case characters may only follow uncased characters and lowercase characters only cased ones.

isupper()

Return True if the string is an uppercase string, False otherwise.

A string is uppercase if all cased characters in the string are uppercase and there is at least one cased character in the string.

join(iterable, /)

Concatenate any number of strings.

The string whose method is called is inserted in between each given string. The result is returned as a new string.

Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’

ljust(width, fillchar=' ', /)

Return a left-justified string of length width.

Padding is done using the specified fill character (default is a space).

lower()

Return a copy of the string converted to lowercase.

lstrip(chars=None, /)

Return a copy of the string with leading whitespace removed.

If chars is given and not None, remove characters in chars instead.

static maketrans()

Return a translation table usable for str.translate().

If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result.

partition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing the original string and two empty strings.

removeprefix(prefix, /)

Return a str with the given prefix string removed if present.

If the string starts with the prefix string, return string[len(prefix):]. Otherwise, return a copy of the original string.

removesuffix(suffix, /)

Return a str with the given suffix string removed if present.

If the string ends with the suffix string and that suffix is not empty, return string[:-len(suffix)]. Otherwise, return a copy of the original string.

replace(old, new, count=-1, /)

Return a copy with all occurrences of substring old replaced by new.

count

Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.

If the optional argument count is given, only the first count occurrences are replaced.

rfind(sub[, start[, end]]) int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

rindex(sub[, start[, end]]) int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

rjust(width, fillchar=' ', /)

Return a right-justified string of length width.

Padding is done using the specified fill character (default is a space).

rpartition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing two empty strings and the original string.

rsplit(sep=None, maxsplit=-1)

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including \n \r \t \f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits (starting from the left). -1 (the default value) means no limit.

Splitting starts at the end of the string and works to the front.

rstrip(chars=None, /)

Return a copy of the string with trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

split(sep=None, maxsplit=-1)

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including \n \r \t \f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits (starting from the left). -1 (the default value) means no limit.

Note, str.split() is mainly useful for data that has been intentionally delimited. With natural text that includes punctuation, consider using the regular expression module.

splitlines(keepends=False)

Return a list of the lines in the string, breaking at line boundaries.

Line breaks are not included in the resulting list unless keepends is given and true.

startswith(prefix[, start[, end]]) bool

Return True if S starts with the specified prefix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. prefix can also be a tuple of strings to try.

strip(chars=None, /)

Return a copy of the string with leading and trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

swapcase()

Convert uppercase characters to lowercase and lowercase characters to uppercase.

title()

Return a version of the string where each word is titlecased.

More specifically, words start with uppercased characters and all remaining cased characters have lower case.

translate(table, /)

Replace each character in the string using the given translation table.

table

Translation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None.

The table must implement lookup/indexing via __getitem__, for instance a dictionary or list. If this operation raises LookupError, the character is left untouched. Characters mapped to None are deleted.

upper()

Return a copy of the string converted to uppercase.

zfill(width, /)

Pad a numeric string with zeros on the left, to fill a field of the given width.

The string is never truncated.

class rompy.swan.types.IDLA(value)[source]

Order of values in the input files.

ONE

SWAN reads the map from left to right starting in the upper-left-hand corner of the map. A new line in the map should start on a new line in the file.

Type:

1

TWO

As 1 but a new line in the map need not start on a new line in the file.

Type:

2

THREE

SWAN reads the map from left to right starting in the lower-left-hand corner of the map. A new line in the map should start on a new line in the file.

Type:

3

FOUR

As 3 but a new line in the map need not start on a new line in the file.

Type:

4

FIVE

SWAN reads the map from top to bottom starting in the lower-left-hand corner of the map. A new column in the map should start on a new line in the file.

Type:

5

SIX

As 5 but a new column in the map need not start on a new line in the file.

Type:

6

Notes

It is assumed that the x-axis of the grid is pointing to the right and the y-axis upwards.

as_integer_ratio()

Return integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

denominator

the denominator of a rational number in lowest terms

from_bytes(byteorder, *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value.

signed

Indicates whether two’s complement is used to represent the integer.

imag

the imaginary part of a complex number

numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

to_bytes(length, byteorder, *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

class rompy.swan.types.PhysicsOff(value)[source]

Physics commands to be switched off.

WINDGROWTH

Switches off wind growth (in commands GEN1, GEN2, GEN3).

Type:

str = “windgrowth”

QUADRUPL

Switches off quadruplet wave interactions (in command GEN3).

Type:

str = “quadrupl”

WCAPPING

Switches off whitecapping (in command GEN3).

Type:

str = “wcapping”

BREAKING

Switches off wave breaking dissipation.

Type:

str = “breaking”

REFRAC

Switches off wave refraction (action transport in theta space).

Type:

str = “refrac”

FSHIFT

Switches off frequency shifting (action transport in sigma space).

Type:

str = “fshift”

BNDCHK

Switches off the checking of the delta imposed and computed Hs at the boundary.

Type:

str = “bndchk”

capitalize()

Return a capitalized version of the string.

More specifically, make the first character have upper case and the rest lower case.

casefold()

Return a version of the string suitable for caseless comparisons.

center(width, fillchar=' ', /)

Return a centered string of length width.

Padding is done using the specified fill character (default is a space).

count(sub[, start[, end]]) int

Return the number of non-overlapping occurrences of substring sub in string S[start:end]. Optional arguments start and end are interpreted as in slice notation.

encode(encoding='utf-8', errors='strict')

Encode the string using the codec registered for encoding.

encoding

The encoding in which to encode the string.

errors

The error handling scheme to use for encoding errors. The default is ‘strict’ meaning that encoding errors raise a UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and ‘xmlcharrefreplace’ as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors.

endswith(suffix[, start[, end]]) bool

Return True if S ends with the specified suffix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. suffix can also be a tuple of strings to try.

expandtabs(tabsize=8)

Return a copy where all tab characters are expanded using spaces.

If tabsize is not given, a tab size of 8 characters is assumed.

find(sub[, start[, end]]) int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

format(*args, **kwargs) str

Return a formatted version of S, using substitutions from args and kwargs. The substitutions are identified by braces (‘{’ and ‘}’).

format_map(mapping) str

Return a formatted version of S, using substitutions from mapping. The substitutions are identified by braces (‘{’ and ‘}’).

index(sub[, start[, end]]) int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

isalnum()

Return True if the string is an alpha-numeric string, False otherwise.

A string is alpha-numeric if all characters in the string are alpha-numeric and there is at least one character in the string.

isalpha()

Return True if the string is an alphabetic string, False otherwise.

A string is alphabetic if all characters in the string are alphabetic and there is at least one character in the string.

isascii()

Return True if all characters in the string are ASCII, False otherwise.

ASCII characters have code points in the range U+0000-U+007F. Empty string is ASCII too.

isdecimal()

Return True if the string is a decimal string, False otherwise.

A string is a decimal string if all characters in the string are decimal and there is at least one character in the string.

isdigit()

Return True if the string is a digit string, False otherwise.

A string is a digit string if all characters in the string are digits and there is at least one character in the string.

isidentifier()

Return True if the string is a valid Python identifier, False otherwise.

Call keyword.iskeyword(s) to test whether string s is a reserved identifier, such as “def” or “class”.

islower()

Return True if the string is a lowercase string, False otherwise.

A string is lowercase if all cased characters in the string are lowercase and there is at least one cased character in the string.

isnumeric()

Return True if the string is a numeric string, False otherwise.

A string is numeric if all characters in the string are numeric and there is at least one character in the string.

isprintable()

Return True if the string is printable, False otherwise.

A string is printable if all of its characters are considered printable in repr() or if it is empty.

isspace()

Return True if the string is a whitespace string, False otherwise.

A string is whitespace if all characters in the string are whitespace and there is at least one character in the string.

istitle()

Return True if the string is a title-cased string, False otherwise.

In a title-cased string, upper- and title-case characters may only follow uncased characters and lowercase characters only cased ones.

isupper()

Return True if the string is an uppercase string, False otherwise.

A string is uppercase if all cased characters in the string are uppercase and there is at least one cased character in the string.

join(iterable, /)

Concatenate any number of strings.

The string whose method is called is inserted in between each given string. The result is returned as a new string.

Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’

ljust(width, fillchar=' ', /)

Return a left-justified string of length width.

Padding is done using the specified fill character (default is a space).

lower()

Return a copy of the string converted to lowercase.

lstrip(chars=None, /)

Return a copy of the string with leading whitespace removed.

If chars is given and not None, remove characters in chars instead.

static maketrans()

Return a translation table usable for str.translate().

If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result.

partition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing the original string and two empty strings.

removeprefix(prefix, /)

Return a str with the given prefix string removed if present.

If the string starts with the prefix string, return string[len(prefix):]. Otherwise, return a copy of the original string.

removesuffix(suffix, /)

Return a str with the given suffix string removed if present.

If the string ends with the suffix string and that suffix is not empty, return string[:-len(suffix)]. Otherwise, return a copy of the original string.

replace(old, new, count=-1, /)

Return a copy with all occurrences of substring old replaced by new.

count

Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.

If the optional argument count is given, only the first count occurrences are replaced.

rfind(sub[, start[, end]]) int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

rindex(sub[, start[, end]]) int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

rjust(width, fillchar=' ', /)

Return a right-justified string of length width.

Padding is done using the specified fill character (default is a space).

rpartition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing two empty strings and the original string.

rsplit(sep=None, maxsplit=-1)

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including \n \r \t \f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits (starting from the left). -1 (the default value) means no limit.

Splitting starts at the end of the string and works to the front.

rstrip(chars=None, /)

Return a copy of the string with trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

split(sep=None, maxsplit=-1)

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including \n \r \t \f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits (starting from the left). -1 (the default value) means no limit.

Note, str.split() is mainly useful for data that has been intentionally delimited. With natural text that includes punctuation, consider using the regular expression module.

splitlines(keepends=False)

Return a list of the lines in the string, breaking at line boundaries.

Line breaks are not included in the resulting list unless keepends is given and true.

startswith(prefix[, start[, end]]) bool

Return True if S starts with the specified prefix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. prefix can also be a tuple of strings to try.

strip(chars=None, /)

Return a copy of the string with leading and trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

swapcase()

Convert uppercase characters to lowercase and lowercase characters to uppercase.

title()

Return a version of the string where each word is titlecased.

More specifically, words start with uppercased characters and all remaining cased characters have lower case.

translate(table, /)

Replace each character in the string using the given translation table.

table

Translation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None.

The table must implement lookup/indexing via __getitem__, for instance a dictionary or list. If this operation raises LookupError, the character is left untouched. Characters mapped to None are deleted.

upper()

Return a copy of the string converted to uppercase.

zfill(width, /)

Pad a numeric string with zeros on the left, to fill a field of the given width.

The string is never truncated.

class rompy.swan.types.SideOptions(value)[source]

Valid options for the boundary shape type.

NORTH

North side.

Type:

“north”

NW

North-west side.

Type:

“nw”

WEST

West side.

Type:

“west”

SW

South-west side.

Type:

“sw”

SOUTH

South side.

Type:

“south”

SE

South-east side.

Type:

“se”

EAST

East side.

Type:

“east”

NE

North-east side.

Type:

“ne”

capitalize()

Return a capitalized version of the string.

More specifically, make the first character have upper case and the rest lower case.

casefold()

Return a version of the string suitable for caseless comparisons.

center(width, fillchar=' ', /)

Return a centered string of length width.

Padding is done using the specified fill character (default is a space).

count(sub[, start[, end]]) int

Return the number of non-overlapping occurrences of substring sub in string S[start:end]. Optional arguments start and end are interpreted as in slice notation.

encode(encoding='utf-8', errors='strict')

Encode the string using the codec registered for encoding.

encoding

The encoding in which to encode the string.

errors

The error handling scheme to use for encoding errors. The default is ‘strict’ meaning that encoding errors raise a UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and ‘xmlcharrefreplace’ as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors.

endswith(suffix[, start[, end]]) bool

Return True if S ends with the specified suffix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. suffix can also be a tuple of strings to try.

expandtabs(tabsize=8)

Return a copy where all tab characters are expanded using spaces.

If tabsize is not given, a tab size of 8 characters is assumed.

find(sub[, start[, end]]) int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

format(*args, **kwargs) str

Return a formatted version of S, using substitutions from args and kwargs. The substitutions are identified by braces (‘{’ and ‘}’).

format_map(mapping) str

Return a formatted version of S, using substitutions from mapping. The substitutions are identified by braces (‘{’ and ‘}’).

index(sub[, start[, end]]) int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

isalnum()

Return True if the string is an alpha-numeric string, False otherwise.

A string is alpha-numeric if all characters in the string are alpha-numeric and there is at least one character in the string.

isalpha()

Return True if the string is an alphabetic string, False otherwise.

A string is alphabetic if all characters in the string are alphabetic and there is at least one character in the string.

isascii()

Return True if all characters in the string are ASCII, False otherwise.

ASCII characters have code points in the range U+0000-U+007F. Empty string is ASCII too.

isdecimal()

Return True if the string is a decimal string, False otherwise.

A string is a decimal string if all characters in the string are decimal and there is at least one character in the string.

isdigit()

Return True if the string is a digit string, False otherwise.

A string is a digit string if all characters in the string are digits and there is at least one character in the string.

isidentifier()

Return True if the string is a valid Python identifier, False otherwise.

Call keyword.iskeyword(s) to test whether string s is a reserved identifier, such as “def” or “class”.

islower()

Return True if the string is a lowercase string, False otherwise.

A string is lowercase if all cased characters in the string are lowercase and there is at least one cased character in the string.

isnumeric()

Return True if the string is a numeric string, False otherwise.

A string is numeric if all characters in the string are numeric and there is at least one character in the string.

isprintable()

Return True if the string is printable, False otherwise.

A string is printable if all of its characters are considered printable in repr() or if it is empty.

isspace()

Return True if the string is a whitespace string, False otherwise.

A string is whitespace if all characters in the string are whitespace and there is at least one character in the string.

istitle()

Return True if the string is a title-cased string, False otherwise.

In a title-cased string, upper- and title-case characters may only follow uncased characters and lowercase characters only cased ones.

isupper()

Return True if the string is an uppercase string, False otherwise.

A string is uppercase if all cased characters in the string are uppercase and there is at least one cased character in the string.

join(iterable, /)

Concatenate any number of strings.

The string whose method is called is inserted in between each given string. The result is returned as a new string.

Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’

ljust(width, fillchar=' ', /)

Return a left-justified string of length width.

Padding is done using the specified fill character (default is a space).

lower()

Return a copy of the string converted to lowercase.

lstrip(chars=None, /)

Return a copy of the string with leading whitespace removed.

If chars is given and not None, remove characters in chars instead.

static maketrans()

Return a translation table usable for str.translate().

If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result.

partition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing the original string and two empty strings.

removeprefix(prefix, /)

Return a str with the given prefix string removed if present.

If the string starts with the prefix string, return string[len(prefix):]. Otherwise, return a copy of the original string.

removesuffix(suffix, /)

Return a str with the given suffix string removed if present.

If the string ends with the suffix string and that suffix is not empty, return string[:-len(suffix)]. Otherwise, return a copy of the original string.

replace(old, new, count=-1, /)

Return a copy with all occurrences of substring old replaced by new.

count

Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.

If the optional argument count is given, only the first count occurrences are replaced.

rfind(sub[, start[, end]]) int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

rindex(sub[, start[, end]]) int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

rjust(width, fillchar=' ', /)

Return a right-justified string of length width.

Padding is done using the specified fill character (default is a space).

rpartition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing two empty strings and the original string.

rsplit(sep=None, maxsplit=-1)

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including \n \r \t \f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits (starting from the left). -1 (the default value) means no limit.

Splitting starts at the end of the string and works to the front.

rstrip(chars=None, /)

Return a copy of the string with trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

split(sep=None, maxsplit=-1)

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including \n \r \t \f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits (starting from the left). -1 (the default value) means no limit.

Note, str.split() is mainly useful for data that has been intentionally delimited. With natural text that includes punctuation, consider using the regular expression module.

splitlines(keepends=False)

Return a list of the lines in the string, breaking at line boundaries.

Line breaks are not included in the resulting list unless keepends is given and true.

startswith(prefix[, start[, end]]) bool

Return True if S starts with the specified prefix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. prefix can also be a tuple of strings to try.

strip(chars=None, /)

Return a copy of the string with leading and trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

swapcase()

Convert uppercase characters to lowercase and lowercase characters to uppercase.

title()

Return a version of the string where each word is titlecased.

More specifically, words start with uppercased characters and all remaining cased characters have lower case.

translate(table, /)

Replace each character in the string using the given translation table.

table

Translation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None.

The table must implement lookup/indexing via __getitem__, for instance a dictionary or list. If this operation raises LookupError, the character is left untouched. Characters mapped to None are deleted.

upper()

Return a copy of the string converted to uppercase.

zfill(width, /)

Pad a numeric string with zeros on the left, to fill a field of the given width.

The string is never truncated.

Swan components#

Base#

Base class for SWAN components.

How to subclass#

  • Define a new model_type Literal for the subclass

  • Overwrite the cmd method to return the SWAN input file string

pydantic model rompy.swan.components.base.BaseComponent[source]

Base class for SWAN components.

This class is not intended to be used directly, but to be subclassed by other SWAN components to implement the following common behaviour:

  • Define a render() method to render a CMD string from the component

  • Split the rendered CMD if longer than 132 characters

  • Forbid extra arguments so only implemented fields must be specified

Fields:
  • model_type (Literal['component'])

field model_type: Literal['component'] [Required]

Model type discriminator

abstract cmd() str | list[source]

Return the string or list of strings to render the component to the CMD.

render(cmd: str | list | None = None) str[source]

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

rompy.swan.components.base.split_string(cmd: str, max_length: int = 180, spaces: int = 4) list[source]

Split command cmd if longer than max_length.

Parameters:
  • cmd (str) – SWAN CMD string to split.

  • max_length (int) – Maximum length of each split string.

  • spaces (int) – Number of spaces in each identation before each new line.

Returns:

split_cmd – List of split CMD strings.

Return type:

list

Group#

SWAN group components.

pydantic model rompy.swan.components.group.BaseGroupComponent[source]

Base group component.

Base class for SWAN group components. This base class modifies the render() method to allow rendering of a list of components. It is not intended to be used directly but to be subclassed by other group components.

Fields:
field model_type: Literal['group', 'GROUP'] = 'group'

Model type discriminator

abstract cmd() str | list

Return the string or list of strings to render the component to the CMD.

render(*args, **kwargs) str[source]

Override base class to allow rendering list of components.

pydantic model rompy.swan.components.group.INPGRIDS[source]

SWAN input grids group component.

INPGRID ...
READGRID ...

INPGRID ...
READGRID ...

...

This group component is a convenience to allow defining and rendering a list of input grid components.

Examples

In [1]: from rompy.swan.components.inpgrid import REGULAR, ICE

In [2]: from rompy.swan.components.group import INPGRIDS

In [3]: inpgrid_bottom = REGULAR(
   ...:     grid_type="bottom",
   ...:     excval=-99.0,
   ...:     xpinp=172.0,
   ...:     ypinp=-41.0,
   ...:     alpinp=0.0,
   ...:     mxinp=99,
   ...:     myinp=99,
   ...:     dxinp=0.005,
   ...:     dyinp=0.005,
   ...:     readinp=dict(fname1="bottom.txt"),
   ...: )
   ...: 

In [4]: inpgrid_wind = REGULAR(
   ...:     grid_type="wind",
   ...:     excval=-99.0,
   ...:     xpinp=172.0,
   ...:     ypinp=-41.0,
   ...:     alpinp=0.0,
   ...:     mxinp=99,
   ...:     myinp=99,
   ...:     dxinp=0.005,
   ...:     dyinp=0.005,
   ...:     readinp=dict(fname1="wind.txt"),
   ...:     nonstationary=dict(
   ...:         tbeg="2019-01-01T00:00:00",
   ...:         tend="2019-01-07 00:00:00",
   ...:         delt=3600,
   ...:         dfmt="hr",
   ...:     ),
   ...: )
   ...: 

In [5]: inpgrid_ice_cte = ICE(aice=0.8, hice=2.0)

In [6]: inpgrids = INPGRIDS(inpgrids=[inpgrid_bottom, inpgrid_wind, inpgrid_ice_cte])

In [7]: print(inpgrids.render())
INPGRID BOTTOM REGULAR xpinp=172.0 ypinp=-41.0 alpinp=0.0 mxinp=99 myinp=99 dxinp=0.005 dyinp=0.005 EXCEPTION excval=-99.0
READINP BOTTOM fac=1.0 fname1='bottom.txt' idla=1 nhedf=0 nhedt=0 nhedvec=0 FREE

INPGRID WIND REGULAR xpinp=172.0 ypinp=-41.0 alpinp=0.0 mxinp=99 myinp=99 dxinp=0.005 dyinp=0.005 EXCEPTION excval=-99.0 NONSTATIONARY tbeginp=20190101.000000 deltinp=1.0 HR &
    tendinp=20190107.000000
READINP WIND fac=1.0 fname1='wind.txt' idla=1 nhedf=0 nhedt=0 nhedvec=0 FREE

ICE aice=0.8 hice=2.0
Fields:
Validators:
field inpgrids: list[REGULAR | CURVILINEAR | UNSTRUCTURED | WIND | ICE] [Required]

List of input grid components

Constraints:
  • min_length = 1

Validated by:
field model_type: Literal['inpgrids'] = 'inpgrids'

Model type discriminator

cmd() str | list[source]

Return the string or list of strings to render the component to the CMD.

validator ensure_unique_grid_type  »  inpgrids[source]

Ensure that each grid type is unique.

render(*args, **kwargs) str

Override base class to allow rendering list of components.

pydantic model rompy.swan.components.group.LOCKUP[source]

Lockup group component.

COMPUTE ...
HOTFILE ...
COMPUTE ...
HOTFILE ...
...
STOP

This is a group component to specify SWAN “Lockup” commands including multiple COMPUTE commands that may or may not be interleaved with HOTFILE commands, and a final STOP command.

Examples

In [1]: from rompy.swan.components.group import LOCKUP

In [2]: lockup = LOCKUP(
   ...:     compute=dict(
   ...:         model_type="stat",
   ...:         times=dict(
   ...:             model_type="nonstationary",
   ...:             tbeg="1990-01-01T00:00:00",
   ...:             tend="1990-01-01T03:00:00",
   ...:             delt="PT1H",
   ...:             dfmt="hr",
   ...:         ),
   ...:         hotfile=dict(fname="hotfile"),
   ...:         hottimes=[-1],
   ...:     ),
   ...: )
   ...: 

In [3]: print(lockup.render())
COMPUTE STATIONARY time=19900101.000000
COMPUTE STATIONARY time=19900101.010000
COMPUTE STATIONARY time=19900101.020000
COMPUTE STATIONARY time=19900101.030000
HOTFILE fname='hotfile_19900101T030000'
STOP
Fields:
field compute: COMPUTE_STAT | COMPUTE_NONSTAT [Required]

Compute components

field model_type: Literal['lockup', 'LOCKUP'] = 'lockup'

Model type discriminator

cmd() list[source]

Command file strings for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.group.OUTPUT[source]

Output group component.

FRAME 'sname' ...
GROUP 'sname' ...
CURVE 'sname' ...
RAY 'rname' ...
ISOLINE 'sname' 'rname' ...
POINTS 'sname ...
NGRID 'sname' ...
QUANTITY ...
OUTPUT OPTIONS ...
BLOCK 'sname' ...
TABLE 'sname' ...
SPECOUT 'sname' ...
NESTOUT 'sname ...

This group component is used to define multiple types of output locations and write components in a single model. Only fields that are explicitly prescribed are rendered by this group component.

Note

The components prescribed are validated according to some constraints as defined in the SWAN manual:

  • The name ‘sname’ of each Locations component must be unique.

  • The Locations ‘sname’ assigned to each write component must be defined.

  • The BLOCK component must be associated with either a FRAME or GROUP.

  • The ISOLINE write component must be associated with a RAY component.

  • The NGRID and NESTOUT components must be defined together.

Examples

In [1]: from rompy.swan.components.output import POINTS, BLOCK, QUANTITIES, TABLE

In [2]: from rompy.swan.components.group import OUTPUT

In [3]: points = POINTS(sname="outpts", xp=[172.3, 172.4], yp=[-39, -39])

In [4]: quantity = QUANTITIES(
   ...:     quantities=[
   ...:         dict(output=["depth", "hsign", "tps", "dir", "tm01"], excv=-9),
   ...:     ]
   ...: )
   ...: 

In [5]: times = dict(tbeg="2012-01-01T00:00:00", delt="PT30M", tfmt=1, dfmt="min")

In [6]: block = BLOCK(
   ...:     model_type="block",
   ...:     sname="COMPGRID",
   ...:     fname="./swangrid.nc",
   ...:     output=["depth", "hsign", "tps", "dir"],
   ...:     times=times,
   ...: )
   ...: 

In [7]: table = TABLE(
   ...:     sname="outpts",
   ...:     format="noheader",
   ...:     fname="./swantable.nc",
   ...:     output=["hsign", "hswell", "dir", "tps", "tm01", "watlev", "qp"],
   ...:     times=times,
   ...: )
   ...: 

In [8]: out = OUTPUT(
   ...:     points=points,
   ...:     quantity=quantity,
   ...:     block=block,
   ...:     table=table,
   ...: )
   ...: 

In [9]: print(out.render())
POINTS sname='outpts' &
    xp=172.3 yp=-39.0 &
    xp=172.4 yp=-39.0

QUANTITY DEPTH HSIGN TPS DIR TM01 excv=-9.0

BLOCK sname='COMPGRID' fname='./swangrid.nc' &
    DEPTH &
    HSIGN &
    TPS &
    DIR &
    OUTPUT tbegblk=20120101.000000 deltblk=30.0 MIN

TABLE sname='outpts' NOHEADER fname='./swantable.nc' &
    HSIGN &
    HSWELL &
    DIR &
    TPS &
    TM01 &
    WATLEV &
    QP &
    OUTPUT tbegtbl=20120101.000000 delttbl=30.0 MIN
Fields:
Validators:
field block: BLOCK | None = None
Validated by:
field curve: CURVES | None = None
Validated by:
field frame: FRAME | None = None
Validated by:
field group: GROUP | None = None
Validated by:
field isoline: ISOLINE | None = None
Validated by:
field model_type: Literal['output', 'OUTPUT'] = 'output'

Model type discriminator

Validated by:
field nestout: NESTOUT | None = None
Validated by:
field ngrid: NGRID | NGRID_UNSTRUCTURED | None = None
Validated by:
field output_options: OUTPUT_OPTIONS | None = None
Validated by:
field points: POINTS | POINTS_FILE | None = None
Validated by:
field quantity: QUANTITIES | None = None
Validated by:
field ray: RAY | None = None
Validated by:
field specout: SPECOUT | None = None
Validated by:
field table: TABLE | None = None
Validated by:
field test: TEST | None = None
Validated by:
validator block_with_frame_or_group  »  all fields[source]

Ensure Block is only defined for FRAME or GROUP locations.

cmd() list[source]

Command file string for this component.

validator isoline_ray_defined  »  all fields[source]

Ensure the isoline ray has been defined.

validator locations_sname_unique  »  all fields[source]

Ensure same sname isn’t used in more than one set of output locations.

validator ngrid_and_nestout  »  all fields[source]

Ensure NGRID and NESTOUT are specified together.

render(*args, **kwargs) str

Override base class to allow rendering list of components.

validator write_locations_exists  »  all fields[source]

Ensure the location component requested by a write component exists.

property locations_set

List of specified location fields.

property snames

List of snames from specified location components.

property write_set

List of specified write fields.

pydantic model rompy.swan.components.group.PHYSICS[source]

Physics group component.

The physics group component is a convenience to allow specifying several individual components in a single command and check for consistency between them.

Exemples#

In [1]: from rompy.swan.components.group import PHYSICS

In [2]: gen = {"model_type": "gen3", "source_terms": {"model_type": "komen"}}

In [3]: phys = PHYSICS(gen=gen)

In [4]: print(phys.render())
GEN3 KOMEN DRAG WU

In [5]: phys = PHYSICS(
   ...:     gen=dict(model_type="gen3", source_terms={"model_type": "st6c1"}),
   ...:     negatinp={"model_type": "negatinp", "rdcoef": 0.04},
   ...:     sswell={"model_type": "zieger"},
   ...:     breaking={"model_type": "constant", "alpha": 1.0, "gamma": 0.73},
   ...:     friction={"model_type": "jonswap", "cfjon": 0.038},
   ...: )
   ...: 

In [6]: print(phys.render())
GEN3 ST6 a1sds=4.7e-07 a2sds=6.6e-06 p1sds=4.0 p2sds=4.0 UP HWANG VECTAU U10PROXY windscaling=28.0 AGROW

SSWELL ZIEGER

NEGATINP rdcoef=0.04

BREAKING CONSTANT alpha=1.0 gamma=0.73

FRICTION JONSWAP CONSTANT cfjon=0.038
Fields:
Validators:
field bragg: BRAGG | BRAGG_FT | BRAGG_FILE | None = None
Validated by:
field breaking: BREAKING_CONSTANT | BREAKING_BKD | None = None
Validated by:
field deactivate: OFFS | None = None
Validated by:
field diffraction: DIFFRACTION | None = None
Validated by:
field friction: FRICTION_JONSWAP | FRICTION_COLLINS | FRICTION_MADSEN | FRICTION_RIPPLES | None = None
Validated by:
field gen: GEN1 | GEN2 | GEN3 | None = None
Validated by:
field limiter: LIMITER | None = None
Validated by:
field model_type: Literal['physics', 'PHYSICS'] = 'physics'

Model type discriminator

Validated by:
field mud: MUD | None = None
Validated by:
field negatinp: NEGATINP | None = None
Validated by:
field obstacle: OBSTACLES | None = None
Validated by:
field quadrupl: QUADRUPL | None = None
Validated by:
field scat: SCAT | None = None
Validated by:
field setup: SETUP | None = None
Validated by:
field sice: SICE | SICE_R19 | SICE_D15 | SICE_M18 | SICE_R21B | None = None
Validated by:
field sswell: SSWELL_ROGERS | SSWELL_ARDHUIN | SSWELL_ZIEGER | None = None
Validated by:
field surfbeat: SURFBEAT | None = None
Validated by:
field triad: TRIAD | TRIAD_DCTA | TRIAD_LTA | TRIAD_SPB | None = None
Validated by:
field turbulence: TURBULENCE | None = None
Validated by:
field vegetation: VEGETATION | None = None
Validated by:
field wcapping: WCAPPING_KOMEN | WCAPPING_AB | None = None
Validated by:
cmd()[source]

Return the string or list of strings to render the component to the CMD.

validator deactivate_physics  »  deactivate[source]

Convert OFF to OFFS so list is rendered.

validator negatinp_only_with_zieger  »  all fields[source]

Log a warning if NEGATINP is used with a non-ZIEGER SSWELL.

render(*args, **kwargs) str

Override base class to allow rendering list of components.

pydantic model rompy.swan.components.group.STARTUP[source]

Startup group component.

PROJECT ...
SET ...
MODE ...
COORDINATES ...

This group component is used to group individual startup components. Only fields that are explicitly prescribed are rendered by this group component.

Examples

In [1]: from rompy.swan.components.startup import PROJECT, SET, MODE, COORDINATES

In [2]: from rompy.swan.components.group import STARTUP

In [3]: proj = PROJECT(nr="01")

In [4]: set = SET(level=0.5, direction_convention="nautical")

In [5]: mode = MODE(kind="nonstationary", dim="twodimensional")

In [6]: coords = COORDINATES(kind=dict(model_type="spherical", projection="ccm"))

In [7]: startup = STARTUP(
   ...:     project=proj,
   ...:     set=set,
   ...:     mode=mode,
   ...:     coordinates=coords,
   ...: )
   ...: 

In [8]: print(startup.render())
PROJECT nr='01'

SET level=0.5 NAUTICAL

MODE NONSTATIONARY TWODIMENSIONAL

COORDINATES SPHERICAL CCM
Fields:
field coordinates: COORDINATES | None = None
field mode: MODE | None = None
field model_type: Literal['startup', 'STARTUP'] = 'startup'

Model type discriminator

field project: PROJECT | None = None
field set: SET | None = None
cmd() str[source]

Command file string for this component.

render(*args, **kwargs) str

Override base class to allow rendering list of components.

Startup#

Model start up components.

pydantic model rompy.swan.components.startup.COORDINATES[source]

SWAN Coordinates.

COORDINATES ->CARTESIAN|SPHERICAL REPEATING

Command to choose between Cartesian and spherical coordinates (see Section 2.5). A nested SWAN run must use the same coordinate system as the coarse grid SWAN run.

Examples

In [1]: from rompy.swan.components.startup import COORDINATES

In [2]: coords = COORDINATES()

In [3]: print(coords.render())
COORDINATES CARTESIAN

In [4]: coords = COORDINATES(
   ...:     kind=dict(model_type="spherical", projection="ccm"),
   ...:     reapeating=True,
   ...: )
   ...: 

In [5]: print(coords.render())
COORDINATES SPHERICAL CCM REPEATING
Fields:
field kind: CARTESIAN | SPHERICAL [Optional]

Coordinates kind

field model_type: Literal['coordinates', 'COORDINATES'] = 'coordinates'

Model type discriminator

field reapeating: bool = False

This option is only for academic cases. It means that wave energy leaving at one end of the domain (in computational x-direction) enter at the other side; it is as if the wave field repeats itself in x-direction with the length of the domain in x-direction. This option cannot be used in combination with computation of set-up (see command SETUP). This option is available only with regular grids

cmd() str[source]

Return the string or list of strings to render the component to the CMD.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.startup.MODE[source]

SWAN Mode.

MODE ->STATIONARY|NONSTATIONARY ->TWODIMENSIONAL|ONEDIMENSIONAL

With this optional command the user indicates that the run will be either stationary or nonstationary and one-dimensional (1D-mode) or two-dimensional (2D-mode). Nonstationary means either (see command COMPUTE):

    1. one nonstationary computations or

    1. a sequence of stationary computations or

    1. a mix of (a) and (b)

Examples

In [1]: from rompy.swan.components.startup import MODE

In [2]: mode = MODE()

In [3]: print(mode.render())
MODE STATIONARY TWODIMENSIONAL

In [4]: mode = MODE(kind="nonstationary", dim="twodimensional")

In [5]: print(mode.render())
MODE NONSTATIONARY TWODIMENSIONAL
Fields:
field dim: Literal['onedimensional', 'twodimensional'] = 'twodimensional'

Indicates that the run will be either one-dimensional (1D-mode) or two-dimensional (2D-mode)

field kind: Literal['stationary', 'nonstationary'] = 'stationary'

Indicates if run will be stationary or nonstationary

field model_type: Literal['mode', 'MODE'] = 'mode'

Model type discriminator.

cmd() str[source]

Return the string or list of strings to render the component to the CMD.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.startup.PROJECT[source]

SWAN Project.

PROJECT 'name' 'nr' 'title' 'title2 'title3'

With this required command the user defines a number of strings to identify the SWAN run (project name e.g., an engineering project) in the print and plot file.

Examples

In [1]: from rompy.swan.components.startup import PROJECT

In [2]: proj = PROJECT(nr="01")

In [3]: print(proj.render())
PROJECT nr='01'

In [4]: proj = PROJECT(
   ...:     name="waus",
   ...:     nr="001",
   ...:     title1="Western Australia",
   ...:     title2="Perth Nest"
   ...: )
   ...: 

In [5]: print(proj.render())
PROJECT name='waus' nr='001' title1='Western Australia' title2='Perth Nest'
Fields:
field model_type: Literal['project', 'PROJECT'] = 'project'

Model type discriminator

field name: str | None = None

Is the name of the project, at most 16 characters long

Constraints:
  • max_length = 16

field nr: str [Required]

Is the run identification (to be provided as a character string; e.g. the run number) to distinguish this run among other runs for the same project; it is at most 4 characters long. It is the only required information in this command.

Constraints:
  • max_length = 4

field title1: str | None = None

A string of at most 72 characters provided by the user to appear in the output of the program for the user’s convenience (SWAN default: blanks)

Constraints:
  • max_length = 72

field title2: str | None = None

Same as ‘title1’

Constraints:
  • max_length = 72

field title3: str | None = None

Same as ‘title1’

Constraints:
  • max_length = 72

cmd() str[source]

Return the string or list of strings to render the component to the CMD.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.startup.SET[source]

SWAN setting commands.

SET [level] [nor] [depmin] [maxmes] [maxerr] [grav] [rho] [cdcap] &
    [inrhog] [hsrerr] NAUTICAL|->CARTESIAN [pwtail] [froudmax] [icewind]

With this optional command the user assigns values to various general parameters.

Notes

The error level maxerr is coded as follows:

  • 1: warnings

  • 2: errors (possibly automatically repaired or repairable by SWAN)

  • 3: severe errors

Default values for pwtail depend on formulations of physics:

  • command GEN1: pwtail = 5

  • command GEN2: pwtail = 5

  • command GEN3 KOMEN: pwtail = 4

  • command GEN3 WESTH: pwtail = 4

  • command GEN3 JANSSEN: pwtail = 5

Examples

In [1]: from rompy.swan.components.startup import SET

In [2]: set = SET(level=0.5, direction_convention="nautical")

In [3]: print(set.render())
SET level=0.5 NAUTICAL

In [4]: set = SET(
   ...:     level=-1.0,
   ...:     nor=90,
   ...:     depmin=0.01,
   ...:     maxerr=3,
   ...:     grav=9.81,
   ...:     rho=1025,
   ...:     cdcap=2.5e-3,
   ...:     inrhog=0,
   ...:     hsrerr=0.1,
   ...:     direction_convention="nautical",
   ...: )
   ...: 

In [5]: print(set.render())
SET level=-1.0 nor=90.0 depmin=0.01 maxerr=3 grav=9.81 rho=1025.0 cdcap=0.0025 inrhog=0 hsrerr=0.1 NAUTICAL
Fields:
Validators:
field cdcap: float | None = None

The maximum value for the wind drag coefficient. A value of 99999 meansno cutting off the drag coefficient. A suggestion for this parameter is cdcap = 2.5x 10-3 (SWAN default: 99999)

Constraints:
  • ge = 0.0

field depmin: float | None = None

Threshold depth (in m). In the computation any positive depth smaller than depmin is made equal to depmin (SWAN default: 0.05)

Constraints:
  • ge = 0.0

field direction_convention: Literal['nautical', 'cartesian'] [Required]

Direction convention: nautical indicates that the Nautical convention for wind and wave direction (SWAN input and output) will be used, cartesian indicates that the Cartesian convention for wind and wave direction will be used. For definition, see Section 2.5 or Appendix A (SWAN default: cartesian)

field froudmax: float | None = None

Is the maximum Froude number (U/√gd with U the current and d the water depth). The currents taken from a circulation model may mismatch with given water depth d in the sense that the Froude number becomes larger than 1. For this, the current velocities will be maximized by Froude number times sqrt(gh) (SWAN default: 0.8)

Constraints:
  • ge = 0.0

field grav: float | None = None

The gravitational acceleration (in m/s2) (SWAN default: 9.81)

Constraints:
  • ge = 0.0

field hsrerr: float | None = None

The relative difference between the user imposed significant wave height and the significant wave height computed by SWAN (anywhere along the computational grid boundary) above which a warning will be given. This relative difference is the difference normalized with the user provided significant wave height. This warning will be given for each boundary grid point where the problem occurs (with its x- and y-index number of the computational grid). The cause of the difference is explained in Section 2.6.3. To suppress these warnings (in particular for nonstationary computations), set hsrerr at a very high value or use command OFF BNDCHK (SWAN default: 0.10) (ONLY MEANT FOR STRUCTURED GRIDS)

Constraints:
  • ge = 0.0

field icewind: Literal[0, 1] | None = None

Controls the scaling of wind input by open water fraction. Default value of zero corresponds to the case where wind input is scaled by the open water fraction. If icewind = 1 then sea ice does not affect wind input directly. (Though there is still indirect effect via the sea ice sink term; see command SICE) (SWAN default: 0)

field inrhog: Literal[0, 1] | None = None

To indicate whether the user requires output based on variance or based on true energy (see Section 2.5). inrhog = 0: output based on variance, inrhog = 1: output based on true energy (SWAN default: 0)

field level: float | None = None

Increase in water level that is constant in space and time can be given with this option, level is the value of this increase (in m). For a variable water level reference is made to the commands INPGRID and READINP (SWAN default: 0)

field maxerr: Literal[1, 2, 3] | None = None

During pre-processing SWAN checks input data. Depending on the severity of the errors encountered during this pre-processing, SWAN does not start computations. The user can influence the error level above which SWAN will not start computations (at the level indicated the computations will continue) (SWAN default: 1)

field maxmes: int | None = None

Maximum number of error messages during the computation at which the computation is terminated. During the computational process messages are written to the print file (SWAN default: 200)

Constraints:
  • ge = 0

field model_type: Literal['set', 'SET'] = 'set'

Model type discriminator

field nor: float | None = None

Direction of North with respect to the x-axis (measured counterclockwise); default nor = 90, i.e. x-axis of the problem coordinate system points East. When spherical coordinates are used (see command COORD) the value of nor may not be modified

Constraints:
  • ge = -360.0

  • le = 360.0

field pwtail: int | None = None

Power of high frequency tail; defines the shape of the spectral tail above the highest prognostic frequency fhigh (see command CGRID). The energy density is assumed to be proportional to frequency to the power pwtail. If the user wishes to use another value, then this SET command should be located in the command file after GEN1, GEN2 or GEN3 command (these will override the SET command with respect to pwtail)

Constraints:
  • ge = 0

Validated by:
field rho: float | None = None

The water density (in kg/m3) (SWAN default: 1025)

Constraints:
  • ge = 0.0

cmd() str[source]

Return the string or list of strings to render the component to the CMD.

validator pwtail_after_gen  »  pwtail[source]
render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

Cgrid#

Computational grid for SWAN.

pydantic model rompy.swan.components.cgrid.CGRID[source]

SWAN computational grid abstract component.

CGRID ->REGULAR|CURVILINEAR|UNSTRUCTURED &
    CIRCLE|SECTOR [mdc] [flow] [fhigh] [msc]

This class should not be used directly.

Fields:
  • model_type (Literal['cgrid', 'CGRID'])

  • spectrum (rompy.swan.subcomponents.spectrum.SPECTRUM)

field model_type: Literal['cgrid', 'CGRID'] = 'cgrid'

Model type discriminator

field spectrum: SPECTRUM [Required]

Spectrum subcomponent

abstract cmd()[source]

Return the string or list of strings to render the component to the CMD.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.cgrid.CURVILINEAR[source]

SWAN curvilinear computational grid.

CGRID CURVILINEAR [mxc] [myc] (EXCEPTION [xexc] [yexc])
    ->CIRCLE|SECTOR [mdc] [flow] [fhigh] [msc]
READGRID COORDINATES [fac] 'fname' [idla] [nhedf] [nhedvec] &
    FREE|FORMAT ('form'|[idfm])

This is a group component that includes a CGRID and a READGRID component.

Examples

In [1]: from rompy.swan.components.cgrid import CURVILINEAR

In [2]: cgrid = CURVILINEAR(
   ...:     mxc=199,
   ...:     myc=199,
   ...:     readcoord=dict(fname="./coords.txt"),
   ...:     spectrum=dict(mdc=36, flow=0.04, fhigh=1.0),
   ...: )
   ...: 

In [3]: print(cgrid.render())
CGRID CURVILINEAR mxc=199 myc=199 CIRCLE mdc=36 flow=0.04 fhigh=1.0
READGRID COORDINATES fac=1.0 fname='./coords.txt' idla=1 nhedf=0 nhedvec=0 FREE
Fields:
Validators:
field model_type: Literal['curvilinear', 'CURVILINEAR'] = 'curvilinear'

Model type discriminator

Validated by:
field mxc: int [Required]

Number of meshes in computational grid in ξ-direction (this number is one less than the number of grid points in this domain).

Validated by:
field myc: int [Required]

Number of meshes in computational grid in η-direction (this number is one less than the number of grid points in this domain).

Validated by:
field readcoord: READCOORD [Required]

Grid coordinates reader.

Validated by:
field spectrum: SPECTRUM [Required]

Spectrum subcomponent

Validated by:
field xexc: float | None = None

the value which the user uses to indicate that a grid point is to be ignored in the computations (this value is provided by the user at the location of the x-coordinate considered in the file of the x-coordinates, see command READGRID COOR).

Validated by:
field yexc: float | None = None

the value which the user uses to indicate that a grid point is to be ignored in the computations (this value is provided by the user at the location of the y-coordinate considered in the file of the y-coordinates, see command READGRID COOR).

Validated by:
cmd() str[source]

Return the string or list of strings to render the component to the CMD.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

validator xexc_and_yexc_or_neither  »  all fields[source]
property exception
property format_repr
pydantic model rompy.swan.components.cgrid.REGULAR[source]

SWAN regular computational grid.

CGRID REGULAR [xpc] [ypc] [alpc] [xlenc] [ylenc] [mxc] [myc] &
    ->CIRCLE|SECTOR [mdc] [flow] [fhigh] [msc]

This is a group component that includes a CGRID and a READGRID component.

Note

In 1D-mode, alpc should be equal to the direction alpinp.

Examples

In [1]: from rompy.swan.components.cgrid import REGULAR

In [2]: cgrid = REGULAR(
   ...:     grid=dict(xp=0, yp=0, alp=0, xlen=2000, ylen=1300, mx=100, my=100),
   ...:     spectrum=dict(mdc=36, flow=0.04, fhigh=1.0),
   ...: )
   ...: 

In [3]: print(cgrid.render())
CGRID REGULAR xpc=0.0 ypc=0.0 alpc=0.0 xlenc=2000.0 ylenc=1300.0 mxc=100 myc=100 CIRCLE mdc=36 flow=0.04 fhigh=1.0
Fields:
Validators:
field grid: GRIDREGULAR [Required]

Computational grid definition

Validated by:
field model_type: Literal['regular', 'REGULAR'] = 'regular'

Model type discriminator

Validated by:
field spectrum: SPECTRUM [Required]

Spectrum subcomponent

Validated by:
cmd() str[source]

Return the string or list of strings to render the component to the CMD.

validator grid_suffix  »  all fields[source]

Set expected grid suffix.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.cgrid.UNSTRUCTURED[source]

SWAN unstructured computational grid.

CGRID UNSTRUCTURED CIRCLE|SECTOR [mdc] [flow] [fhigh] [msc]
READGRID UNSTRUCTURED [grid_type] ('fname')

This is a group component that includes a CGRID and a READGRID component.

Examples

In [1]: from rompy.swan.components.cgrid import UNSTRUCTURED

In [2]: cgrid = UNSTRUCTURED(
   ...:     grid_type="adcirc",
   ...:     spectrum=dict(mdc=36, flow=0.04, fhigh=1.0),
   ...: )
   ...: 

In [3]: print(cgrid.render())
CGRID UNSTRUCTURED CIRCLE mdc=36 flow=0.04 fhigh=1.0
READGRID UNSTRUCTURED ADCIRC
Fields:
Validators:
field fname: str | None = None

Name of the file containing the unstructured grid

Constraints:
  • max_length = 36

Validated by:
field grid_type: Literal['adcirc', 'triangle', 'easymesh'] = 'adcirc'

Unstructured grid type

Validated by:
field model_type: Literal['unstructured'] = 'unstructured'

Model type discriminator

Validated by:
field spectrum: SPECTRUM [Required]

Spectrum subcomponent

Validated by:
validator check_fname_required  »  all fields[source]

Check that fname needs to be provided.

cmd() str[source]

Return the string or list of strings to render the component to the CMD.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

Inpgrid#

Input grid for SWAN.

pydantic model rompy.swan.components.inpgrid.CURVILINEAR[source]

SWAN curvilinear input grid.

INPGRID [grid_type] CURVILINEAR [stagrx] [stagry] [mxinp] [myinp] &
    (EXCEPTION [excval]) &
    (NONSTATIONARY [tbeginp] [deltinp] ->SEC|MIN|HR|DAY [tendinp])
READGRID [grid_type] [fac] 'fname1' [idla] [nhedf] ([nhedt]) ([nhedvec]) &
    ->FREE|FORMAT|UNFORMATTED ('form'|[idfm])

This is a group component that includes an INPGRID and a READGRID component.

Examples

In [1]: from rompy.swan.components.inpgrid import CURVILINEAR

In [2]: inpgrid = CURVILINEAR(
   ...:     grid_type="wind",
   ...:     stagrx=0.0,
   ...:     stagry=0.0,
   ...:     mxinp=199,
   ...:     myinp=199,
   ...:     excval=-99.0,
   ...:     readinp=dict(fname1="wind.txt"),
   ...:     nonstationary=dict(
   ...:         tbeg="2019-01-01T00:00:00",
   ...:         tend="2019-01-07 00:00:00",
   ...:         delt=3600,
   ...:         dfmt="hr",
   ...:     ),
   ...: )
   ...: 

In [3]: print(inpgrid.render())
INPGRID WIND CURVILINEAR stagrx=0.0 stagry=0.0 mxinp=199 myinp=199  EXCEPTION excval=-99.0 NONSTATIONARY tbeginp=20190101.000000 deltinp=1.0 HR tendinp=20190107.000000
READINP WIND fac=1.0 fname1='wind.txt' idla=1 nhedf=0 nhedt=0 nhedvec=0 FREE

TODO: Handle (or not) setting default values for mxinp and myinp from cgrid.

Fields:
Validators:
  • set_nonstat_suffix » all fields

field excval: float | None = None

Exception value to allow identifying and ignoring certain point inside the given grid during the computation. If fac != 1, excval must be given as fac times the exception value

Validated by:
  • set_nonstat_suffix

field grid_type: GridOptions [Required]

Type of the swan input grid, e.g, ‘bottom’, ‘wind’, etc

Validated by:
  • set_nonstat_suffix

field model_type: Literal['curvilinear', 'CURVILINEAR'] = 'curvilinear'

Model type discriminator

Validated by:
  • set_nonstat_suffix

field mxinp: int [Required]

Number of meshes in ξ-direction of the input grid (this number is one less than the number of grid points in this direction)

Validated by:
  • set_nonstat_suffix

field myinp: int [Required]

Number of meshes in η-direction of the input grid (this number is one less than the number of grid points in this direction)

Validated by:
  • set_nonstat_suffix

field nonstationary: NONSTATIONARY | None = None

Nonstationary time specification

Validated by:
  • set_nonstat_suffix

field readinp: READINP [Required]

SWAN input grid file reader specification

Validated by:
  • set_nonstat_suffix

field stagrx: float = 0.0

Staggered x’-direction with respect to computational grid, e.g., stagrx=0.5 means that the input grid points are shifted a half step in x’-direction; in many flow models x-velocities are defined in points shifted a half step in x’-direction

Validated by:
  • set_nonstat_suffix

field stagry: float = 0.0

Staggered y’-direction with respect to computational grid, e.g., stagry=0.5 means that the input grid points are shifted a half step in y’-direction; in many flow models y-velocities are defined in points shifted a half step in y’-direction

Validated by:
  • set_nonstat_suffix

cmd() str[source]

Return the string or list of strings to render the component to the CMD.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

validator set_nonstat_suffix  »  all fields

Set the nonstationary suffix.

pydantic model rompy.swan.components.inpgrid.ICE[source]

Constant wind input field.

ICE [aice] [hice]

With this optional command, the user indicates that one or more ice fields are constant.

Examples

In [1]: from rompy.swan.components.inpgrid import ICE

In [2]: ice = ICE(aice=0.1, hice=0.1)

In [3]: print(ice.render())
ICE aice=0.1 hice=0.1
Fields:
field aice: float [Required]

Areal ice fraction, a number from 0 to 1

Constraints:
  • ge = 0.0

  • le = 1.0

field hice: float [Required]

Ice thickness (m)

Constraints:
  • ge = 0.0

field model_type: Literal['ice', 'ICE'] = 'ice'

Model type discriminator

cmd()[source]

Return the string or list of strings to render the component to the CMD.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.inpgrid.INPGRID[source]

SWAN input grid.

INPGRID [grid_type] ->REGULAR|CURVILINEAR|UNSTRUCTURED (EXCEPTION [excval]) &
    (NONSTATIONARY [tbeginp] [deltinp] ->SEC|MIN|HR|DAY [tendinp])

This is the base class for all input grids. It is not meant to be used directly.

Fields:
  • excval (float | None)

  • grid_type (rompy.swan.types.GridOptions)

  • model_type (Literal['inpgrid', 'INPGRID'])

  • nonstationary (rompy.swan.subcomponents.time.NONSTATIONARY | None)

  • readinp (rompy.swan.subcomponents.readgrid.READINP)

Validators:
  • set_nonstat_suffix » all fields

field excval: float | None = None

Exception value to allow identifying and ignoring certain point inside the given grid during the computation. If fac != 1, excval must be given as fac times the exception value

Validated by:
  • set_nonstat_suffix

field grid_type: GridOptions [Required]

Type of the swan input grid, e.g, ‘bottom’, ‘wind’, etc

Validated by:
  • set_nonstat_suffix

field model_type: Literal['inpgrid', 'INPGRID'] = 'inpgrid'

Model type discriminator

Validated by:
  • set_nonstat_suffix

field nonstationary: NONSTATIONARY | None = None

Nonstationary time specification

Validated by:
  • set_nonstat_suffix

field readinp: READINP [Required]

SWAN input grid file reader specification

Validated by:
  • set_nonstat_suffix

cmd() str[source]

Return the string or list of strings to render the component to the CMD.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

validator set_nonstat_suffix  »  all fields[source]

Set the nonstationary suffix.

pydantic model rompy.swan.components.inpgrid.REGULAR[source]

SWAN regular input grid.

INPGRID [grid_type] REGULAR [xpinp] [ypinp] [alpinp] [mxinp] [myinp] &
    [dxinp] [dyinp] (EXCEPTION [excval]) &
    (NONSTATIONARY [tbeginp] [deltinp] ->SEC|MIN|HR|DAY [tendinp])
READGRID [grid_type] [fac] 'fname1' [idla] [nhedf] ([nhedt]) ([nhedvec]) &
    ->FREE|FORMAT|UNFORMATTED ('form'|[idfm])

This is a group component that includes an INPGRID and a READGRID component.

Examples

In [1]: from rompy.swan.components.inpgrid import REGULAR

In [2]: inpgrid = REGULAR(
   ...:     grid_type="bottom",
   ...:     excval=-99.0,
   ...:     xpinp=172.0,
   ...:     ypinp=-41.0,
   ...:     alpinp=0.0,
   ...:     mxinp=99,
   ...:     myinp=99,
   ...:     dxinp=0.005,
   ...:     dyinp=0.005,
   ...:     readinp=dict(fname1="bottom.txt"),
   ...: )
   ...: 

In [3]: print(inpgrid.render())
INPGRID BOTTOM REGULAR xpinp=172.0 ypinp=-41.0 alpinp=0.0 mxinp=99 myinp=99 dxinp=0.005 dyinp=0.005 EXCEPTION excval=-99.0
READINP BOTTOM fac=1.0 fname1='bottom.txt' idla=1 nhedf=0 nhedt=0 nhedvec=0 FREE

In [4]: inpgrid = REGULAR(
   ...:     grid_type="wind",
   ...:     excval=-99.0,
   ...:     xpinp=172.0,
   ...:     ypinp=-41.0,
   ...:     alpinp=0.0,
   ...:     mxinp=99,
   ...:     myinp=99,
   ...:     dxinp=0.005,
   ...:     dyinp=0.005,
   ...:     readinp=dict(fname1="wind.txt"),
   ...:     nonstationary=dict(
   ...:         tbeg="2019-01-01T00:00:00",
   ...:         tend="2019-01-07 00:00:00",
   ...:         delt=3600,
   ...:         dfmt="hr",
   ...:     ),
   ...: )
   ...: 

In [5]: print(inpgrid.render())
INPGRID WIND REGULAR xpinp=172.0 ypinp=-41.0 alpinp=0.0 mxinp=99 myinp=99 dxinp=0.005 dyinp=0.005 EXCEPTION excval=-99.0 NONSTATIONARY tbeginp=20190101.000000 deltinp=1.0 HR &
    tendinp=20190107.000000
READINP WIND fac=1.0 fname1='wind.txt' idla=1 nhedf=0 nhedt=0 nhedvec=0 FREE

TODO: Use grid object, requires different grid parameters to be allowed.

Fields:
Validators:
  • set_nonstat_suffix » all fields

field alpinp: float | None = 0.0

Direction of the positive x-axis of the input grid (in degrees, Cartesian convention)

Validated by:
  • set_nonstat_suffix

field dxinp: float [Required]

Mesh size in x-direction of the input grid, in m in case of Cartesian coordinates or in degrees if spherical coordinates are used

Validated by:
  • set_nonstat_suffix

field dyinp: float [Required]

Mesh size in y-direction of the input grid, in m in case of Cartesian coordinates or in degrees if spherical coordinates are used. In 1D-mode, dyinp may have any value

Validated by:
  • set_nonstat_suffix

field excval: float | None = None

Exception value to allow identifying and ignoring certain point inside the given grid during the computation. If fac != 1, excval must be given as fac times the exception value

Validated by:
  • set_nonstat_suffix

field grid_type: GridOptions [Required]

Type of the swan input grid, e.g, ‘bottom’, ‘wind’, etc

Validated by:
  • set_nonstat_suffix

field model_type: Literal['regular', 'REGULAR'] = 'regular'

Model type discriminator

Validated by:
  • set_nonstat_suffix

field mxinp: int [Required]

Number of meshes in x-direction of the input grid (this number is one less than the number of grid points in this direction)

Validated by:
  • set_nonstat_suffix

field myinp: int [Required]

Number of meshes in y-direction of the input grid (this number is one less than the number of grid points in this direction). In 1D-mode, myinp should be 0

Validated by:
  • set_nonstat_suffix

field nonstationary: NONSTATIONARY | None = None

Nonstationary time specification

Validated by:
  • set_nonstat_suffix

field readinp: READINP [Required]

SWAN input grid file reader specification

Validated by:
  • set_nonstat_suffix

field xpinp: float [Required]

Geographic location (x-coordinate) of the origin of the input grid in problem coordinates (in m) if Cartesian coordinates are used or in degrees if spherical coordinates are used. In case of spherical coordinates there is no default

Validated by:
  • set_nonstat_suffix

field ypinp: float [Required]

Geographic location (y-coordinate) of the origin of the input grid in problem coordinates (in m) if Cartesian coordinates are used or in degrees if spherical coordinates are used. In case of spherical coordinates there is no default

Validated by:
  • set_nonstat_suffix

cmd() list[source]

Return the string or list of strings to render the component to the CMD.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

validator set_nonstat_suffix  »  all fields

Set the nonstationary suffix.

pydantic model rompy.swan.components.inpgrid.UNSTRUCTURED[source]

SWAN unstructured input grid.

INPGRID [grid_type] UNSTRUCTURED EXCEPTION [excval]) &
    (NONSTATIONARY [tbeginp] [deltinp] ->SEC|MIN|HR|DAY [tendinp])
READGRID [grid_type] [fac] 'fname1' [idla] [nhedf] ([nhedt]) ([nhedvec]) &
    ->FREE|FORMAT|UNFORMATTED ('form'|[idfm])

This is a group component that includes an INPGRID and a READGRID component.

Examples

In [1]: from rompy.swan.components.inpgrid import UNSTRUCTURED

In [2]: inpgrid = UNSTRUCTURED(
   ...:     grid_type="bottom",
   ...:     excval=-99.0,
   ...:     readinp=dict(fname1="bottom.txt"),
   ...:     nonstationary=dict(
   ...:         tbeg="2019-01-01T00:00:00",
   ...:         tend="2019-01-07 00:00:00",
   ...:         delt=3600,
   ...:         dfmt="hr",
   ...:     ),
   ...: )
   ...: 

In [3]: print(inpgrid.render())
INPGRID BOTTOM UNSTRUCTURED EXCEPTION excval=-99.0 NONSTATIONARY tbeginp=20190101.000000 deltinp=1.0 HR tendinp=20190107.000000
READINP BOTTOM fac=1.0 fname1='bottom.txt' idla=1 nhedf=0 nhedt=0 nhedvec=0 FREE
Fields:
Validators:
  • set_nonstat_suffix » all fields

field excval: float | None = None

Exception value to allow identifying and ignoring certain point inside the given grid during the computation. If fac != 1, excval must be given as fac times the exception value

Validated by:
  • set_nonstat_suffix

field grid_type: GridOptions [Required]

Type of the swan input grid, e.g, ‘bottom’, ‘wind’, etc

Validated by:
  • set_nonstat_suffix

field model_type: Literal['unstructured', 'UNSTRUCTURED'] = 'unstructured'

Model type discriminator

Validated by:
  • set_nonstat_suffix

field nonstationary: NONSTATIONARY | None = None

Nonstationary time specification

Validated by:
  • set_nonstat_suffix

field readinp: READINP [Required]

SWAN input grid file reader specification

Validated by:
  • set_nonstat_suffix

cmd() str[source]

Return the string or list of strings to render the component to the CMD.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

validator set_nonstat_suffix  »  all fields

Set the nonstationary suffix.

pydantic model rompy.swan.components.inpgrid.WIND[source]

Constant wind input field.

WIND [vel] [dir]

With this optional command, the user indicates that the wind field is constant.

Examples

In [1]: from rompy.swan.components.inpgrid import WIND

In [2]: wind = WIND(vel=10.0, dir=270.0)

In [3]: print(wind.render())
WIND vel=10.0 dir=270.0
Fields:
field dir: float [Required]

Wind direction at 10 m elevation (in degrees, Cartesian or Nautical convention, see command SET)

Constraints:
  • ge = -180.0

  • le = 360.0

field model_type: Literal['wind', 'WIND'] = 'wind'

Model type discriminator

field vel: float [Required]

Wind velocity at 10 m elevation (m/s)

Constraints:
  • ge = 0.0

cmd()[source]

Return the string or list of strings to render the component to the CMD.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

Boundary#

Boundary for SWAN.

pydantic model rompy.swan.components.boundary.BOUNDNEST1[source]

Boundary spectra from a coarser SWAN nest.

BOUNDNEST1 NEST 'fname' ->CLOSED|OPEN

With this optional command a nested SWAN run can be carried out with the boundary conditions obtained from a coarse grid SWAN run (generated in that previous SWAN run with command NESTOUT). The spectral frequencies and directions of the coarse grid run do not have to coincide with the frequencies and directions used in the nested SWAN run; SWAN will interpolate to these frequencies and directions in the nested run (see Section 2.6.3). To generate the nest boundary in the coarse grid run, use command NGRID. For the nested run, use the command CGRID with identical geographical information except the number of meshes (which will be much higher for the nested run). This BOUNDNEST1 command is not available for 1D computations; in such cases the commands SPECOUT and BOUNDSPEC can be used for the same purpose. A nested SWAN run must use the same coordinate system as the coarse grid SWAN run. For a curvilinear grid, it is advised to use the commands POINTS or CURVE and SPECOUT instead of NGRID and NESTOUT.

Examples

In [1]: from rompy.swan.components.boundary import BOUNDNEST1

In [2]: boundary = BOUNDNEST1(fname="boundary.swn", rectangle="closed")

In [3]: print(boundary.render())
BOUNDNEST1 NEST fname='boundary.swn' CLOSED
Fields:
field fname: str [Required]

Name of the file containing the boundary conditions for the present run, created by the previous SWAN coarse grid run. This file is structured according to the rules given in Appendix D for 2D spectra

Constraints:
  • min_length = 1

  • max_length = 36

field model_type: Literal['boundnest1', 'BOUNDNEST1'] = 'boundnest1'

Model type discriminator

field rectangle: Literal['closed', 'open'] = 'closed'

Boundary is defined over a closed (default) or an open rectangle. Boundary generated from the NESTOUT command is aways closed

cmd() str[source]

Return the string or list of strings to render the component to the CMD.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.boundary.BOUNDNEST2[source]

Boundary spectra from WAM.

BOUNDNEST2 WAMNEST 'fname' FREE|UNFORMATTED ->CRAY|WKSTAT [xgc] [ygc] [lwdate]

With this optional command (not fully tested) a nested SWAN run can be carried out with the boundary conditions obtained from a coarse grid WAM run (WAM Cycle 4.5, source code as distributed by the Max Planck Institute in Hamburg). The spectral frequencies and directions of the coarse grid run do not have to coincide with the frequencies and directions used in the nested SWAN run; SWAN will interpolate to these frequencies and directions in the nested run (see Section 2.6.3). Note that SWAN will accept output of a WAM output location only if the SWAN grid point on the nest boundary lies within a rectangle between two consecutive WAM output locations with a width equal to 0.1 times the distance between these output locations on either side of the line between these WAM output locations. This BOUNDNEST2 command is not available for 1D computations. Only boundary conditions generated by WAM Cycle 4.5 can be read properly by SWAN. A nested SWAN run may use either Cartesian or spherical coordinates. A curvilinear grid may be used in the nested grid but the boundaries of this nest should conform to the rectangular course grid nest boundaries. WAM output files are unformatted (binary); this usually implies that WAM and SWAN have to run on the same computer. For those cases where WAM and SWAN run on different types of machines (binary files do not transfer properly), the option FREE is available in this command. The distributed version of WAM does not support the required free format nesting output; WAM users who modify WAM such that it can make formatted output, must modify WAM such that the files made by WAM can be read in free format, i.e. with at least a blank or comma between numbers.

Note

the contents of ‘fname’ file could look like:

CBO9212010000
CBO9212020000
CBO9212030000

Examples

In [1]: from rompy.swan.components.boundary import BOUNDNEST2

In [2]: boundary = BOUNDNEST2(fname="boundary.wam", format="cray", lwdate=12)

In [3]: print(boundary.render())
BOUNDNEST2 WAMNEST fname='boundary.wam' UNFORMATTED CRAY lwdate=12
Fields:
field fname: str [Required]

A file name that contains all the names of WAM files containing the nested boundary conditions in time-sequence (usually one file per day)

Constraints:
  • min_length = 1

  • max_length = 36

field format: Literal['cray', 'wkstat', 'free'] [Required]

Format of the WAM file. cray: CRAY version of WAM, wkstat: WORKSTATION version of WAM, free: Free format (these files are not generated standard by WAM)

field lwdate: Literal[10, 12, 14] = 12

Length of character string for date-time as used in the WAM files. Possible values are: 10 (i.e. YYMMDDHHMM), 12 (i.e. YYMMDDHHMMSS) or 14 (i.e. YYYYMMDDHHMMSS) (SWAN default: lwdate = 12)

field model_type: Literal['boundnest2', 'BOUNDNEST2'] = 'boundnest2'

Model type discriminator

field xgc: float | None = None

If SWAN is used with Cartesian coordinates: longitude of south-west corner of SWAN computational grid (in degrees); if the south-west corner of the nest in the WAM computation is on land this value is required. If SWAN is used with spherical coordinates then xgc is ignored by SWAN (SWAN default: the location of the first spectrum encountered in the nest file

field ygc: float | None = None

If SWAN is used with Cartesian coordinates: latitude of south-west corner of SWAN computational grid (in degrees); if the south-west corner of the nest in the WAM computation is on land this value is required. If SWAN is used with spherical coordinates then ygc is ignored by SWAN (SWAN default: the location of the first spectrum encountered in the nest file

cmd() str[source]

Return the string or list of strings to render the component to the CMD.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

property format_str
pydantic model rompy.swan.components.boundary.BOUNDNEST3[source]

Boundary spectra from WAVEWATCHIII.

BOUNDNEST3 WW3 'fname' FREE|UNFORMATTED ->CLOSED|OPEN [xgc] [ygc]

With this optional command a nested SWAN run can be carried out with the boundary conditions obtained from a coarse grid WAVEWATCH III run. The spectral frequencies and directions of the coarse grid run do not have to coincide with the frequencies and directions used in the nested SWAN run; SWAN will interpolate to these frequencies and directions in the nested run (see Section 2.6.3). The output files of WAVEWATCH III have to be created with the post-processor of WAVEWATCH III as output transfer files (formatted or unformatted) with WW_3 OUTP (output type 1 sub type 3) at the locations along the nest boundary (i.e. computational grid points in WAVEWATCH III). These locations are equal to the corner points of the SWAN nested grid and optionally also distributed between the corner points of the SWAN nested grid (the boundary of the WAVEWATCH III nested grid need not be closed and may cover land). The locations should be output by WAVEWATCH III in sequence (going along the nest boundary, clockwise or counterclockwise). Note that SWAN will accept output of a WAVEWATCH III output location only if the SWAN grid point on the nest boundary lies within a rectangle between two consecutive WAVEWATCH III output locations with a width equal to 0.1 times the distance between these output locations on either side of the line between these WAVEWATCH III output locations. This BOUNDNEST3 command is not available for 1D computations. A nested SWAN run may use either Cartesian or spherical coordinates. A curvilinear grid may be used in the nested grid but the boundaries of this nest should conform to the rectangular course grid nest boundaries.

Examples

In [1]: from rompy.swan.components.boundary import BOUNDNEST3

In [2]: boundary = BOUNDNEST3(
   ...:     fname="boundary.ww3",
   ...:     format="free",
   ...:     rectangle="closed",
   ...: )
   ...: 

In [3]: print(boundary.render())
BOUNDNEST3 WW3 fname='boundary.ww3' FREE CLOSED
Fields:
field fname: str [Required]

The name of the file that contains the spectra computed by WAVEWATCH III

Constraints:
  • min_length = 1

  • max_length = 36

field format: Literal['unformatted', 'free'] [Required]

Format of the WW3 file. unformatted: The input WW3 files are binary, free: The input WW3 files are formatted

field model_type: Literal['boundnest3', 'BOUNDNEST3'] = 'boundnest3'

Model type discriminator

field rectangle: Literal['closed', 'open'] = 'closed'

Boundary is defined over a closed (default) or an open rectangle. Boundary generated from the NESTOUT command is aways closed

field xgc: float | None = None

If SWAN is used with Cartesian coordinates: longitude of south-west corner of SWAN computational grid (in degrees); if the south-west corner of the nest in the WAM computation is on land this value is required. If SWAN is used with spherical coordinates then xgc is ignored by SWAN (SWAN default: the location of the first spectrum encountered in the nest file.

field ygc: float | None = None

If SWAN is used with Cartesian coordinates: latitude of south-west corner of SWAN computational grid (in degrees); if the south-west corner of the nest in the WAM computation is on land this value is required. If SWAN is used with spherical coordinates then ygc is ignored by SWAN (SWAN default: the location of the first spectrum encountered in the nest file.

cmd() str[source]

Return the string or list of strings to render the component to the CMD.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.boundary.BOUNDSPEC[source]

Boundary along sides or segment.

BOUNDSPEC ->SIDE|SEGMENT CONSTANT|VARIABLE PAR|FILE

This command BOUNDSPEC defines parametric spectra at the boundary. It consists of two parts, the first part defines the boundary side or segment where the spectra will be given, the second part defines the spectral parameters of these spectra. Note that in fact only the incoming wave components of these spectra are used by SWAN. The fact that complete spectra are calculated at the model boundaries from the spectral parameters should not be misinterpreted. Only the incoming components are effective in the computation.

TODO: Add support for unstructured grid (k).

Examples

In [1]: from rompy.swan.components.boundary import BOUNDSPEC

In [2]: boundary = BOUNDSPEC(
   ...:     shapespec=dict(model_type="shapespec", shape=dict(model_type="pm")),
   ...:     location=dict(model_type="side", side="west", direction="ccw"),
   ...:     data=dict(model_type="constantpar", hs=2, per=8, dir=270, dd=30),
   ...: )
   ...: 

In [3]: print(boundary.render())
BOUND SHAPESPEC PM PEAK DSPR POWER
BOUNDSPEC SIDE WEST CCW CONSTANT PAR hs=2.0 per=8.0 dir=270.0 dd=30.0

In [4]: boundary = BOUNDSPEC(
   ...:     shapespec=dict(model_type="shapespec", shape=dict(model_type="pm")),
   ...:     location=dict(
   ...:         model_type="segment",
   ...:         points=dict(model_type="ij", i=[0, 0], j=[0, 3])
   ...:     ),
   ...:     data=dict(model_type="constantpar", hs=2, per=8, dir=270, dd=30),
   ...: )
   ...: 

In [5]: print(boundary.render())
BOUND SHAPESPEC PM PEAK DSPR POWER
BOUNDSPEC SEGMENT IJ  &
    i=0 j=0 &
    i=0 j=3 &
    CONSTANT PAR hs=2.0 per=8.0 dir=270.0 dd=30.0
Fields:
field data: CONSTANTPAR | CONSTANTFILE | VARIABLEPAR | VARIABLEFILE [Required]

Spectral data

field location: SIDE | SEGMENT [Required]

Location to apply the boundary

field model_type: Literal['boundspec', 'BOUNDSPEC'] = 'boundspec'

Model type discriminator

field shapespec: SHAPESPEC [Optional]

Spectral shape specification

cmd() list[source]

Return the string or list of strings to render the component to the CMD.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.boundary.INITIAL[source]

Initial conditions.

INITIAL -> DEFAULT|ZERO|PAR|HOTSTART

This command can be used to specify the initial values for a stationary (INITIAL HOTSTART only) or nonstationary computation. The initial values thus specified override the default initialization (see Section 2.6.3). Note that it is possible to obtain an initial state by carrying out a previous stationary or nonstationary computation.

Examples

In [1]: from rompy.swan.components.boundary import INITIAL

In [2]: init = INITIAL()

In [3]: print(init.render())
INITIAL DEFAULT

In [4]: init = INITIAL(
   ...:     kind=dict(model_type="hotmultiple", fname="hotstart.swn", format="free")
   ...: )
   ...: 

In [5]: print(init.render())
INITIAL HOTSTART MULTIPLE fname='hotstart.swn' FREE
Fields:
field kind: DEFAULT | ZERO | PAR | HOTSINGLE | HOTMULTIPLE [Optional]

Initial condition type

field model_type: Literal['initial', 'INITIAL'] = 'initial'

Model type discriminator

cmd() str[source]

Return the string or list of strings to render the component to the CMD.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

Physics#

Model physics components.

pydantic model rompy.swan.components.physics.BRAGG[source]

Bragg scattering.

BRAGG [ibrag] [nreg] [cutoff]

Using this optional command, the user activates a source term to represent the scattering of waves due to changes in the small-scale bathymetry based on the theory of Ardhuin and Herbers (2002). If this command is not used, SWAN will not account for Bragg scattering.

The underlying process is related to the bed elevation spectrum that describes the random variability of the bathymetry at the scale of the wave length on top of a slowly varying depth. To input this spectrum in the model, two options are available. One option is to read a spectrum from a file. This single bottom spectrum will subsequently be applied in all active grid points. The assumption being made here is that the inputted bottom is gently sloping. Note that the bottom spectrum must be given as a function of the wave number k.

Another option is to compute the spectrum by a Fourier transform from x to k of the bed modulations around a computational grid point. First, one must define a square region with a fixed size around the grid point in order to perform the Fourier transform. The size should correspond to a multiple of the wave length at which refraction is resolved (i.e. consistent with the mild slope assumption). Next, the amplitude modulation of the small-scale bathymetry is obtained by substracting a slowly varying bed level from the inputted high-resolution bathymetric data within this square region. Here, the smooth bed level is achieved using a bilinear fit. During the computation, however, SWAN employs the gently sloping bed as the mean of the original bathymetry within the given square around each computational grid point. Finally, the corresponding bottom spectrum is computed with an FFT.

Notes

The Bragg scattering source term to the action balance equation gives rise to a fairly stiff equation. The best remedy is to run SWAN in the nonstationary mode with a relatively small time step or in the stationary mode with some under relaxation (see command NUM STAT [alfa]).

Examples

In [1]: from rompy.swan.components.physics import BRAGG

In [2]: bragg = BRAGG(nreg=200)

In [3]: print(bragg.render())
BRAGG nreg=200

In [4]: bragg = BRAGG(ibrag=1, nreg=200, cutoff=5.0)

In [5]: print(bragg.render())
BRAGG ibrag=1 nreg=200 cutoff=5.0
Fields:
field cutoff: float | None = None

Cutoff to the ratio between surface and bottom wave numbers. Note: seethe Scientific/Technical documentation for details (SWAN default: 5.0)

field ibrag: Literal[1, 2, 3] | None = None

Indicates the computation of Bragg scattering term:

  • 1: source term is calculated per sweep and bottom spectrum is interpolated at the difference wave number a priori (thus requiring storage)

  • 2: source term is calculated per sweep and bottom spectrum is interpolated at the difference wave number per sweep (no storage)

  • 3: source term is calculated per iteration and bottom spectrum is interpolated at the difference wave number per iteration (no storage)

(SWAN default: 1)

field model_type: Literal['bragg', 'BRAGG'] = 'bragg'

Model type discriminator

field nreg: int [Required]

Size of square region around computational grid point (centered) for computing the mean depth and, if desired, the bed elevation spectrum. It is expressed in terms of the number of grid points (per direction) of the inputted bottom grid

cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.BRAGG_FILE[source]

Bragg scattering with bottom spectrum from file.

BRAGG [ibrag] [nreg] [cutoff] FILE 'fname' [idla] [mkx] [mky] [dkx] [dky]

The bed elevation spectrum FB(kx, ky) is read from a file.

Notes

This spectrum is taken to be uniform over the entire computational domain.

Examples

In [1]: from rompy.swan.components.physics import BRAGG_FILE

In [2]: bragg = BRAGG_FILE(fname="bottom_spectrum.txt", nreg=500, mkx=99, dkx=0.1)

In [3]: print(bragg.render())
BRAGG nreg=500 FILE fname='bottom_spectrum.txt' mkx=99 dkx=0.1

In [4]: kwargs = dict(
   ...:     ibrag=3,
   ...:     nreg=500,
   ...:     cutoff=5.0,
   ...:     fname="bottom_spectrum.txt",
   ...:     mkx=99,
   ...:     mky=149,
   ...:     dkx=0.1,
   ...:     dky=0.1,
   ...: )
   ...: 

In [5]: bragg = BRAGG_FILE(**kwargs)

In [6]: print(bragg.render())
BRAGG ibrag=3 nreg=500 cutoff=5.0 FILE fname='bottom_spectrum.txt' mkx=99 mky=149 dkx=0.1 dky=0.1
Fields:
field cutoff: float | None = None

Cutoff to the ratio between surface and bottom wave numbers. Note: seethe Scientific/Technical documentation for details (SWAN default: 5.0)

field dkx: float [Required]

Mesh size in x-direction of the wave number grid related to bottom spectrum (1/m)

field dky: float | None = None

Mesh size in y-direction of the wave number grid related to bottom spectrum (1/m) (SWAN default: dky = dkx)

field fname: str [Required]

Name of file containing the bottom spectrum

Constraints:
  • max_length = 36

field ibrag: Literal[1, 2, 3] | None = None

Indicates the computation of Bragg scattering term:

  • 1: source term is calculated per sweep and bottom spectrum is interpolated at the difference wave number a priori (thus requiring storage)

  • 2: source term is calculated per sweep and bottom spectrum is interpolated at the difference wave number per sweep (no storage)

  • 3: source term is calculated per iteration and bottom spectrum is interpolated at the difference wave number per iteration (no storage)

(SWAN default: 1)

field idla: IDLA | None = None

Order in which the values should be given in the input files

field mkx: int [Required]

Number of cells in x-direction of the wave number grid related to bottom spectrum (this is one less than the number of points in this direction)

field mky: int | None = None

Number of cells in y-direction of the wave number grid related to bottom spectrum (this is one less than the number of points in this direction)(SWAN default: mky = mkx)

field model_type: Literal['file', 'FILE'] = 'file'

Model type discriminator

field nreg: int [Required]

Size of square region around computational grid point (centered) for computing the mean depth and, if desired, the bed elevation spectrum. It is expressed in terms of the number of grid points (per direction) of the inputted bottom grid

cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.BRAGG_FT[source]

Bragg scattering with bottom spectrum computed from FFT.

BRAGG [ibrag] [nreg] [cutoff] FT

If this keyword is present the bottom spectrum will be computed in each active grid point using a Fast Fourier Transform (FFT).

Notes

The depth in each computational grid point is computed as the average of the inputted (high-resolution) bed levels within the square region.

Examples

In [1]: from rompy.swan.components.physics import BRAGG_FT

In [2]: bragg = BRAGG_FT(nreg=350)

In [3]: print(bragg.render())
BRAGG nreg=350 FT

In [4]: bragg = BRAGG_FT(ibrag=2, nreg=350, cutoff=5.0)

In [5]: print(bragg.render())
BRAGG ibrag=2 nreg=350 cutoff=5.0 FT
Fields:
field cutoff: float | None = None

Cutoff to the ratio between surface and bottom wave numbers. Note: seethe Scientific/Technical documentation for details (SWAN default: 5.0)

field ibrag: Literal[1, 2, 3] | None = None

Indicates the computation of Bragg scattering term:

  • 1: source term is calculated per sweep and bottom spectrum is interpolated at the difference wave number a priori (thus requiring storage)

  • 2: source term is calculated per sweep and bottom spectrum is interpolated at the difference wave number per sweep (no storage)

  • 3: source term is calculated per iteration and bottom spectrum is interpolated at the difference wave number per iteration (no storage)

(SWAN default: 1)

field model_type: Literal['ft', 'FT'] = 'ft'

Model type discriminator

field nreg: int [Required]

Size of square region around computational grid point (centered) for computing the mean depth and, if desired, the bed elevation spectrum. It is expressed in terms of the number of grid points (per direction) of the inputted bottom grid

cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.BREAKING_BKD[source]

Variable wave breaking index.

BREAKING BKD [alpha] [gamma0] [a1] [a2] [a3]

Indicates that the breaker index scales with both the bottom slope (beta) and the dimensionless depth (kd).

Examples

In [1]: from rompy.swan.components.physics import BREAKING_BKD

In [2]: breaking = BREAKING_BKD()

In [3]: print(breaking.render())
BREAKING BKD

In [4]: breaking = BREAKING_BKD(alpha=1.0, gamma0=0.54, a1=7.59, a2=-8.06, a3=8.09)

In [5]: print(breaking.render())
BREAKING BKD alpha=1.0 gamma0=0.54 a1=7.59 a2=-8.06 a3=8.09
Fields:
field a1: float | None = None

First tunable coefficient for the breaker index (SWAN default: 7.59)

field a2: float | None = None

Second tunable coefficient for the breaker index (SWAN default: -8.06)

field a3: float | None = None

Third tunable coefficient for the breaker index (SWAN default: 8.09)

field alpha: float | None = None

Proportionality coefficient of the rate of dissipation (SWAN default: 1.0)

field gamma0: float | None = None

The reference $gamma$ for horizontal slopes (SWAN default: 0.54)

field model_type: Literal['bkd', 'BKD'] = 'bkd'

Model type discriminator

cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.BREAKING_CONSTANT[source]

Constant wave breaking index.

BREAKING CONSTANT [alpha] [gamma]

Indicates that a constant breaker index is to be used.

Examples

In [1]: from rompy.swan.components.physics import BREAKING_CONSTANT

In [2]: breaking = BREAKING_CONSTANT()

In [3]: print(breaking.render())
BREAKING CONSTANT

In [4]: breaking = BREAKING_CONSTANT(alpha=1.0, gamma=0.73)

In [5]: print(breaking.render())
BREAKING CONSTANT alpha=1.0 gamma=0.73
Fields:
field alpha: float | None = None

Proportionality coefficient of the rate of dissipation (SWAN default: 1.0)

field gamma: float | None = None

The breaker index, i.e. the ratio of maximum individual wave height over depth (SWAN default: 0.73)

field model_type: Literal['constant', 'CONSTANT'] = 'constant'

Model type discriminator

cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.DIFFRACTION[source]

Wave diffraction.

DIFFRACTION [idiffr] [smpar] [smnum] [cgmod]

If this optional command is given, the diffraction is included in the wave computation. But the diffraction approximation in SWAN does not properly handle diffraction in harbours or in front of reflecting obstacles (see Scientific/Technical documentation). Behind breakwaters with a down-wave beach, the SWAN results seem reasonable. The spatial resolution near (the tip of) the diffraction obstacle should be 1/5 to 1/10 of the dominant wave length.

Notes

Without extra measures, the diffraction computations with SWAN often converge poorly or not at all. Two measures can be taken:

1. (RECOMMENDED) The user can request under-relaxation. See command NUMERIC parameter alpha and Scientific/Technical documentation (Eq. (3.31)). Very limited experience suggests alpha = 0.01.

2. Alternatively, the user can request smoothing of the wave field for the computation of the diffraction parameter (the wave field remains intact for all other computations and output). This is done with a repeated convolution filtering.

Examples

In [1]: from rompy.swan.components.physics import DIFFRACTION

In [2]: diffraction = DIFFRACTION()

In [3]: print(diffraction.render())
DIFFRACTION

In [4]: diffraction = DIFFRACTION(idiffr=True, smpar=0.0, smnum=1.0)

In [5]: print(diffraction.render())
DIFFRACTION idiffr=1 smpar=0.0 smnum=1
Fields:
field cgmod: float | None = None

Adaption of propagation velocities in geographic space due to diffraction. If cgmod=0 then no adaption (SWAN default: 1.0)

field idiffr: bool | None = None

Indicates the use of diffraction. If idiffr=0 then no diffraction is taken into account (SWAN default: 1)

field model_type: Literal['diffraction', 'DIFFRACTION'] = 'diffraction'

Model type discriminator

field smnum: int | None = None

Number of smoothing steps relative to smpar (SWAN default: 0)

field smpar: float | None = None

Smoothing parameter for the calculation of ∇ · √Etot. During every smoothing step all grid points exchange smpar times the energy with their neighbours. Note that smpar is parameter a in the above text (SWAN default: 0.0)

cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.FRICTION_COLLINS[source]

Collins (1972) friction.

FRICTION COLLINS [cfw]

Note that cfw is allowed to vary over the computational region; in that case use the commands INPGRID FRICTION and READINP FRICTION to define and read the friction data. This command FRICTION is still required to define the type of friction expression. The value of cfw in this command is then not required (it will be ignored).

References

Collins, J.I., 1972. Prediction of shallow-water spectra. Journal of Geophysical Research, 77(15), pp.2693-2707.

Examples

In [1]: from rompy.swan.components.physics import FRICTION_COLLINS

In [2]: friction = FRICTION_COLLINS()

In [3]: print(friction.render())
FRICTION COLLINS

In [4]: friction = FRICTION_COLLINS(cfw=0.038)

In [5]: print(friction.render())
FRICTION COLLINS cfw=0.038
Fields:
field cfw: float | None = None

Collins bottom friction coefficient (SWAN default: 0.015)

field model_type: Literal['collins', 'COLLINS'] = 'collins'

Model type discriminator

cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.FRICTION_JONSWAP[source]

Hasselmann et al. (1973) Jonswap friction.

FRICTION JONSWAP CONSTANT [cfjon]

Indicates that the semi-empirical expression derived from the JONSWAP results for bottom friction dissipation (Hasselmann et al., 1973, JONSWAP) should be activated. This option is default.

References

Hasselmann, K., Barnett, T.P., Bouws, E., Carlson, H., Cartwright, D.E., Enke, K., Ewing, J.A., Gienapp, A., Hasselmann, D.E., Kruseman, P. and Meerburg, A., 1973. Measurements of wind-wave growth and swell decay during the Joint North Sea Wave Project (JONSWAP). Deutches Hydrographisches Institut, Hamburg, Germany, Rep. No. 12, 95 pp.

Examples

In [1]: from rompy.swan.components.physics import FRICTION_JONSWAP

In [2]: friction = FRICTION_JONSWAP()

In [3]: print(friction.render())
FRICTION JONSWAP CONSTANT

In [4]: friction = FRICTION_JONSWAP(cfjon=0.038)

In [5]: print(friction.render())
FRICTION JONSWAP CONSTANT cfjon=0.038

TODO: Implement VARIABLE option?

Fields:
field cfjon: float | None = None

Coefficient of the JONSWAP formulation (SWAN default: 0.038)

field model_type: Literal['jonswap', 'JONSWAP'] = 'jonswap'

Model type discriminator

cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.FRICTION_MADSEN[source]

Madsen et al (1988) friction.

FRICTION MADSEN [kn]

Note that kn is allowed to vary over the computational region; in that case use the commands INPGRID FRICTION and READINP FRICTION to define and read the friction data. This command FRICTION is still required to define the type of friction expression. The value of kn in this command is then not required (it will be ignored).

References

Madsen, O.S., Poon, Y.K. and Graber, H.C., 1988. Spectral wave attenuation by bottom friction: Theory. In Coastal engineering 1988 (pp. 492-504).

Madsen, O.S. and Rosengaus, M.M., 1988. Spectral wave attenuation by bottom friction: Experiments. In Coastal Engineering 1988 (pp. 849-857).

Examples

In [1]: from rompy.swan.components.physics import FRICTION_MADSEN

In [2]: friction = FRICTION_MADSEN()

In [3]: print(friction.render())
FRICTION MADSEN

In [4]: friction = FRICTION_MADSEN(kn=0.038)

In [5]: print(friction.render())
FRICTION MADSEN kn=0.038
Fields:
field kn: float | None = None

equivalent roughness length scale of the bottom (in m) (SWAN default: 0.05)

field model_type: Literal['madsen', 'MADSEN'] = 'madsen'

Model type discriminator

cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.FRICTION_RIPPLES[source]

Smith et al. (2011) Ripples friction.

FRICTION RIPPLES [S] [D]

Indicates that the expression of Smith et al. (2011) should be activated. Here friction depends on the formation of bottom ripples and sediment size.

References

Smith, G.A., Babanin, A.V., Riedel, P., Young, I.R., Oliver, S. and Hubbert, G., 2011. Introduction of a new friction routine into the SWAN model that evaluates roughness due to bedform and sediment size changes. Coastal Engineering, 58(4), pp.317-326.

Examples

In [1]: from rompy.swan.components.physics import FRICTION_RIPPLES

In [2]: friction = FRICTION_RIPPLES()

In [3]: print(friction.render())
FRICTION RIPPLES

In [4]: friction = FRICTION_RIPPLES(s=2.65, d=0.0001)

In [5]: print(friction.render())
FRICTION RIPPLES S=2.65 D=0.0001
Fields:
field d: float | None = None

The sediment diameter (in m) (SWAN default: 0.0001)

field model_type: Literal['ripples', 'RIPPLES'] = 'ripples'

Model type discriminator

field s: float | None = None

The specific gravity of the sediment (SWAN default: 2.65)

cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.GEN1[source]

First generation source terms GEN1.

GEN1 [cf10] [cf20] [cf30] [cf40] [edmlpm] [cdrag] [umin] [cfpm]

With this command the user indicates that SWAN should run in first-generation mode (see Scientific/Technical documentation).

Examples

In [1]: from rompy.swan.components.physics import GEN1

In [2]: gen = GEN1()

In [3]: print(gen.render())
GEN1

In [4]: kwargs = dict(
   ...:     cf10=188.0,
   ...:     cf20=0.59,
   ...:     cf30=0.12,
   ...:     cf40=250.0,
   ...:     edmlpm=0.0036,
   ...:     cdrag=0.0012,
   ...:     umin=1.0,
   ...:     cfpm=0.13
   ...: )
   ...: 

In [5]: gen = GEN1(**kwargs)

In [6]: print(gen.render())
GEN1 cf10=188.0 cf20=0.59 cf30=0.12 cf40=250.0 edmlpm=0.0036 cdrag=0.0012 umin=1.0 cfpm=0.13
Fields:
field cdrag: float | None = None

Drag coefficient (SWAN default: 0.0012)

field cf10: float | None = None

Controls the linear wave growth (SWAN default: 188.0)

field cf20: float | None = None

Controls the exponential wave growth (SWAN default: 0.59)

field cf30: float | None = None

Controls the exponential wave growth (SWAN default: 0.12)

field cf40: float | None = None

Controls the dissipation rate, i.e., the time decay scale (SWAN default: 250.0)

field cfpm: float | None = None

Coefficient which determines the Pierson Moskowitz frequency: delta_PM = 2pi g / U_10 (SWAN default: 0.13)

field edmlpm: float | None = None

Maximum non-dimensionless energy density of the wind sea part of the spectrum according to Pierson Moskowitz (SWAN default: 0.0036)

field model_type: Literal['gen1', 'GEN1'] = 'gen1'

Model type discriminator

field umin: float | None = None

Minimum wind velocity (relative to current; all wind speeds are taken at 10 m above sea level) (SWAN default: 1)

cmd()[source]

Command line string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.GEN2[source]

Second generation source terms GEN2.

GEN2 [cf10] [cf20] [cf30] [cf40] [cf50] [cf60] [edmlpm] [cdrag] [umin] [cfpm]

With this command the user indicates that SWAN should run in second-generation mode (see Scientific/Technical documentation).

Examples

In [1]: from rompy.swan.components.physics import GEN2

In [2]: gen = GEN2()

In [3]: print(gen.render())
GEN2

In [4]: kwargs = dict(
   ...:     cf10=188.0,
   ...:     cf20=0.59,
   ...:     cf30=0.12,
   ...:     cf40=250.0,
   ...:     cf50=0.0023,
   ...:     cf60=-0.223,
   ...:     edmlpm=0.0036,
   ...:     cdrag=0.0012,
   ...:     umin=1.0,
   ...:     cfpm=0.13
   ...: )
   ...: 

In [5]: gen = GEN2(**kwargs)

In [6]: print(gen.render())
GEN2 cf10=188.0 cf20=0.59 cf30=0.12 cf40=250.0 cf50=0.0023 cf60=-0.223 edmlpm=0.0036 cdrag=0.0012 umin=1.0 cfpm=0.13
Fields:
field cdrag: float | None = None

Drag coefficient (SWAN default: 0.0012)

field cf10: float | None = None

Controls the linear wave growth (SWAN default: 188.0)

field cf20: float | None = None

Controls the exponential wave growth (SWAN default: 0.59)

field cf30: float | None = None

Controls the exponential wave growth (SWAN default: 0.12)

field cf40: float | None = None

Controls the dissipation rate, i.e., the time decay scale (SWAN default: 250.0)

field cf50: float | None = None

Controls the spectral energy scale of the limit spectrum (SWAN default: 0.0023)

field cf60: float | None = None

Ccontrols the spectral energy scale of the limit spectrum (SWAN default: -0.223

field cfpm: float | None = None

Coefficient which determines the Pierson Moskowitz frequency: delta_PM = 2pi g / U_10 (SWAN default: 0.13)

field edmlpm: float | None = None

Maximum non-dimensionless energy density of the wind sea part of the spectrum according to Pierson Moskowitz (SWAN default: 0.0036)

field model_type: Literal['gen2', 'GEN2'] = 'gen2'

Model type discriminator

field umin: float | None = None

Minimum wind velocity (relative to current; all wind speeds are taken at 10 m above sea level) (SWAN default: 1)

cmd()[source]

Command line string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.GEN3[source]

Third generation source terms GEN3.

GEN3 JANSSEN|KOMEN|->WESTHUYSEN|ST6 AGROW [a]

With this command the user indicates that SWAN should run in third-generation mode for wind input, quadruplet interactions and whitecapping.

Examples

In [1]: from rompy.swan.components.physics import GEN3

In [2]: gen = GEN3(
   ...:     source_terms=dict(
   ...:         model_type="westhuysen",
   ...:         wind_drag="wu",
   ...:         agrow=True,
   ...:     ),
   ...: )
   ...: 

In [3]: print(gen.render())
GEN3 WESTHUYSEN DRAG WU AGROW

In [4]: from rompy.swan.subcomponents.physics import ST6C1

In [5]: gen = GEN3(source_terms=ST6C1())

In [6]: print(gen.render())
GEN3 ST6 a1sds=4.7e-07 a2sds=6.6e-06 p1sds=4.0 p2sds=4.0 UP HWANG VECTAU U10PROXY windscaling=28.0 AGROW
Fields:
field model_type: Literal['gen3', 'GEN3'] = 'gen3'

Model type discriminator

field source_terms: JANSSEN | KOMEN | WESTHUYSEN | ST6 | ST6C1 | ST6C2 | ST6C3 | ST6C4 | ST6C5 [Optional]

SWAN source terms to be used (SWAN default: WESTHUYSEN)

cmd()[source]

Command line string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.LIMITER[source]

Physics limiter.

LIMITER [ursell] [qb]

With this command the user can de-activate permanently the quadruplets when the actual Ursell number exceeds ursell. Moreover, as soon as the actual fraction of breaking waves exceeds qb then the action limiter will not be used in case of decreasing action density.

Examples

In [1]: from rompy.swan.components.physics import LIMITER

In [2]: limiter = LIMITER()

In [3]: print(limiter.render())
LIMITER

In [4]: limiter = LIMITER(ursell=10.0, qb=1.0)

In [5]: print(limiter.render())
LIMITER ursell=10.0 qb=1.0
Fields:
field model_type: Literal['limiter', 'LIMITER'] = 'limiter'

Model type discriminator

field qb: float | None = None

The threshold for fraction of breaking waves (SWAN default: 1.0)

field ursell: float | None = None

The upper threshold for Ursell number (SWAN default: 10.0)

cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.MUD[source]

Mud dumping.

MUD [layer] [rhom] [viscm]

With this command the user can activate wave damping due to mud based on Ng (2000). If this command or the commands INPGRID MUDLAY and READINP MUDLAY are not used, SWAN will not account for muddy bottom effects.

References

Ng, C., 2000, Water waves over a muddy bed: A two layer Stokes’ boundary layer model, Coastal Eng., 40, 221-242.

Examples

In [1]: from rompy.swan.components.physics import MUD

In [2]: mud = MUD()

In [3]: print(mud.render())
MUD

In [4]: mud = MUD(
   ...:     layer=2.0,
   ...:     rhom=1300,
   ...:     viscm=0.0076,
   ...: )
   ...: 

In [5]: print(mud.render())
MUD layer=2.0 rhom=1300.0 viscm=0.0076

TODO: Validate layer must be prescribed if INPGRID MUDLAY isn’t used.

Fields:
field layer: float | None = None

The thickness of the mud layer (in m). Note that layer is allowed to vary over the computational region to account for the zonation of muddy bottom. In that case use the commands INPGRID MUDLAY and READINP MUDLAY to define and read the layer thickness of mud. The value of layer in this command is then not required (it will be ignored)

field model_type: Literal['mud', 'MUD'] = 'mud'

Model type discriminator

field rhom: float | None = None

The density of the mud layer (in kg/m3) (SWAN default: 1300)

field viscm: float | None = None

The kinematic viscosity of the mud layer (in m2/s) (SWAN default: 0.0076)

cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.NEGATINP[source]

Negative wind input.

NEGATINP [rdcoef]

With this optional command the user activates negative wind input. This is intended only for use with non-breaking swell dissipation SSWELL ZIEGER. Parameter rdcoef is a fraction between 0 and 1, representing the strength of negative wind input. As an example, with [rdcoef]=0.04, for a spectral bin that is opposed to the wind direction, the wind input factor W(k, θ) is negative, and its magnitude is 4% of the corresponding value of the spectral bin that is in the opposite direction (i.e. in the wind direction). See Zieger et al. (2015) eq. 11, where a0 is their notation for [rdcoef]. Default [rdcoef]=0.0 and rdcoef=0.04 is recommended, though as implied by Zieger et al. (2015), this value is not well-established, so the user is encouraged to experiment with other values.

References

Zieger, S., Babanin, A.V., Rogers, W.E. and Young, I.R., 2015. Observation-based source terms in the third-generation wave model WAVEWATCH. Ocean Modelling, 96, pp.2-25.

Examples

In [1]: from rompy.swan.components.physics import NEGATINP

In [2]: negatinp = NEGATINP()

In [3]: print(negatinp.render())
NEGATINP

In [4]: negatinp = NEGATINP(rdcoef=0.04)

In [5]: print(negatinp.render())
NEGATINP rdcoef=0.04
Fields:
field model_type: Literal['negatinp', 'NEGATINP'] = 'negatinp'

Model type discriminator

field rdcoef: float | None = None

Coefficient representing the strength of negative wind input

Constraints:
  • ge = 0.0

  • le = 1.0

cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.OBSTACLE[source]

Subgrid obstacle.

OBSTACLE ->TRANSM|TRANS1D|TRANS2D|GODA|DANGREMOND REFL [reflc] ->RSPEC|RDIFF &
    (FREEBOARD [hgt] [gammat] [gammar] QUAY) LINE < [xp] [yp] >

With this optional command the user provides the characteristics of a (line of) sub-grid obstacle(s) through which waves are transmitted or against which waves are reflected (possibly both at the same time). The obstacle is sub-grid in the sense that it is narrow compared to the spatial meshes; its length should be at least one mesh length.

The location of the obstacle is defined by a sequence of corner points of a line. The obstacles interrupt the propagation of the waves from one grid point to the next wherever this obstacle line is located between two neighbouring grid points (of the computational grid; the resolution of the obstacle is therefore equal to the computational grid spacing). This implies that an obstacle to be effective must be located such that it crosses at least one grid line. This is always the case when an obstacle is larger than one mesh length.

Notes

  • The advise is to define obstacles with the least amount of points possible.

  • SWAN checks if the criterion reflc^2 + trcoef^2 LE 1 is fulfilled.

Examples

In [1]: from rompy.swan.components.physics import OBSTACLE

In [2]: obs = OBSTACLE(
   ...:     transmission=dict(model_type="transm", trcoef=0.5),
   ...:     reflection=dict(reflc=0.5),
   ...:     line=dict(xp=[174.1, 174.2, 174.3], yp=[-39.1, -39.1, -39.1]),
   ...: )
   ...: 

In [3]: print(obs.render())
OBSTACLE TRANSM trcoef=0.5 REFL reflc=0.5 LINE 174.1 -39.1 174.2 -39.1 174.3 -39.1
Fields:
Validators:
field freeboard: FREEBOARD | None = None

Freeboard

Validated by:
field line: LINE = None

Line of obstacle

Validated by:
field model_type: Literal['obstacle', 'OBSTACLE'] = 'obstacle'

Model type discriminator

Validated by:
field reflection: REFL | None = None

Wave reflection

Validated by:
field reflection_type: RSPEC | RDIFF | None = None
Validated by:
field transmission: TRANSM | TRANS1D | TRANS2D | GODA | DANGREMOND | None = None
Validated by:
cmd() str[source]

Command file string for this component.

validator hgt_consistent  »  all fields[source]

Warns if hgt has different values in DAM and FREEBOARD specifications.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.OBSTACLES[source]

List of swan obstacles.

OBSTACLE ... LINE < [xp] [yp] >
OBSTACLE ... LINE < [xp] [yp] >
.

This group component is a convenience to allow defining and rendering a list of obstacle components.

Examples

In [1]: from rompy.swan.components.physics import OBSTACLES, OBSTACLE, OBSTACLE_FIG

In [2]: obst1 = dict(
   ...:     model_type="obstacle",
   ...:     reflection=dict(reflc=1.0),
   ...:     line=dict(xp=[174.1, 174.2, 174.3], yp=[-39.1, -39.1, -39.1]),
   ...: )
   ...: 

In [3]: obst2 = OBSTACLE(
   ...:     transmission=dict(model_type="transm"),
   ...:     line=dict(xp=[174.3, 174.3], yp=[-39.1, -39.2]),
   ...: )
   ...: 

In [4]: obst3 = OBSTACLE_FIG(
   ...:     alpha1=5e-4,
   ...:     hss=2.5,
   ...:     tss=10.3,
   ...:     line=dict(xp=[174.1, 174.2, 174.3], yp=[-39.1, -39.1, -39.1]),
   ...: )
   ...: 

In [5]: obstacles = OBSTACLES(obstacles=[obst1, obst2, obst3])

In [6]: for obst in obstacles.render():
   ...:     print(obst)
   ...: 
OBSTACLE REFL reflc=1.0 LINE 174.1 -39.1 174.2 -39.1 174.3 -39.1
OBSTACLE TRANSM LINE 174.3 -39.1 174.3 -39.2
OBSTACLE FIG alpha1=0.0005 hss=2.5 tss=10.3 LINE 174.1 -39.1 174.2 -39.1 174.3 -39.1
Fields:
field model_type: Literal['obstacles', 'OBSTACLES'] = 'obstacles'

Model type discriminator

field obstacles: list[OBSTACLE | OBSTACLE_FIG] [Required]

Obstacle component

cmd() list[source]

Command file strings for this component.

render() str[source]

Override base class to allow rendering list of components.

pydantic model rompy.swan.components.physics.OBSTACLE_FIG[source]

Obstacle for free infragravity radiation.

OBSTACLE FIG [alpha1] [hss] [tss] (REFL [reflc]) LINE <[xp] [yp]>

With this optional command the user specifies the obstacles along which the free infra-gravity (FIG) energy is radiated. By placing the obstacles close to the shorelines SWAN will include the FIG source term along the coastlines according to the parametrization of Ardhuin et al. (2014).

The location of the obstacle is defined by a sequence of corner points of a line. For an obstacle line to be effective its length is at least one mesh size large. It is recommended to place the obstacles at the inner area of the computational grid, not at or through the boundaries. In particular, each obstacle line must be bordered by wet points on both sides.

In addition, the orientation of the obstacle line determines from which side of the obstacle the FIG wave energy is radiated away. If the begin point of the line is below or left of the end point, that is, pointing upwards/to the right, then FIG energy is radiated from the west/north side of the line. If the begin point is above or right of the end point (pointing downwards/to the left), then FIG energy is radiated away from the east/south side of the obstacle line.

References

Ardhuin, F., Rawat, A. and Aucan, J., 2014. A numerical model for free infragravity waves: Definition and validation at regional and global scales. Ocean Modelling, 77, pp.20-32.

Notes

Either hss or tss or both are allowed to vary over the computational domain. In that case use the commands INPGRID HSS and READINP HSS and/or the commands INPGRID TSS and READINP TSS to define and read the sea-swell wave height/period It is permissible to have constant sea-swell height and non-constant sea-swell period, or vice versa. The command OBST FIG is still required to define the obstacles. The values of hss and/or tss in this command are then not required (they will be ignored).

Examples

In [1]: from rompy.swan.components.physics import OBSTACLE_FIG

In [2]: obs = OBSTACLE_FIG(
   ...:     alpha1=5e-4,
   ...:     hss=2.5,
   ...:     tss=10.3,
   ...:     line=dict(xp=[174.1, 174.2, 174.3], yp=[-39.1, -39.1, -39.1]),
   ...: )
   ...: 

In [3]: print(obs.render())
OBSTACLE FIG alpha1=0.0005 hss=2.5 tss=10.3 LINE 174.1 -39.1 174.2 -39.1 174.3 -39.1

In [4]: obs = OBSTACLE_FIG(
   ...:     alpha1=5e-4,
   ...:     hss=2.5,
   ...:     tss=10.3,
   ...:     reflection=dict(reflc=0.5),
   ...:     line=dict(xp=[174.1, 174.2, 174.3], yp=[-39.1, -39.1, -39.1]),
   ...: )
   ...: 

In [5]: print(obs.render())
OBSTACLE FIG alpha1=0.0005 hss=2.5 tss=10.3 REFL reflc=0.5 LINE 174.1 -39.1 174.2 -39.1 174.3 -39.1
Fields:
field alpha1: float [Required]

Calibration parameter (in 1/s) for determining the rate of radiating FIG energy from the shorelines, values in Table 1 of Ardhuin et al. (2014) are between 4e-4 and 8.1e-4

field hss: float [Required]

The sea-swell significant wave height (in m)

Constraints:
  • ge = 0.0

field line: LINE [Required]

Line of obstacle

field model_type: Literal['fig', 'FIG'] = 'fig'

Model type discriminator

field reflection: REFL | None = None

Wave reflection

field tss: float [Required]

The sea-swell mean wave period (in s)

Constraints:
  • ge = 0.0

cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.OFF[source]

Deactivate physics commands.

OFF WINDGROWTH|QUADRUPL|WCAPPING|BREAKING|REFRAC|FSHIFT|BNDCHK

This command deactivates physics commands. The command can be used to switch off the computation of a certain physics component without having to remove the command from the input file. This is useful for testing purposes.

Examples:#

In [1]: from rompy.swan.components.physics import OFF

In [2]: off = OFF(physics="windgrowth")

In [3]: print(off.render())
OFF WINDGROWTH
Fields:
field model_type: Literal['off', 'OFF'] = 'off'

Model type discriminator

field physics: PhysicsOff [Required]

Physics command to be switched off

cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.OFFS[source]

Deactivate multiple physics commands.

OFF WINDGROWTH|QUADRUPL|WCAPPING|BREAKING|REFRAC|FSHIFT|BNDCHK
OFF WINDGROWTH|QUADRUPL|WCAPPING|BREAKING|REFRAC|FSHIFT|BNDCHK
.

This group component is a convenience to allow defining and rendering a list of OFF components.

Examples

In [1]: from rompy.swan.components.physics import OFFS

In [2]: off1 = dict(physics="windgrowth")

In [3]: off2 = dict(physics="wcapping")

In [4]: offs = OFFS(offs=[off1, off2])

In [5]: for off in offs.render():
   ...:     print(off)
   ...: 
O
F
F
 
W
I
N
D
G
R
O
W
T
H


O
F
F
 
W
C
A
P
P
I
N
G
Fields:
field model_type: Literal['offs', 'OFFS'] = 'offs'

Model type discriminator

field offs: list[OFF] [Required]

Physics commands to deactivate

cmd() list[source]

Command file strings for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.QUADRUPL[source]

Nonlinear quadruplet wave interactions.

QUADRUPL [iquad] [lambda] [cnl4] [Csh1] [Csh2] [Csh3]

With this option the user can influence the computation of nonlinear quadruplet wave interactions which are usually included in the computations. Can be de-activated with command OFF QUAD. Note that the DIA approximation of the quadruplet interactions is a poor approximation for long-crested waves and frequency resolutions that are deviating much more than 10% (see command CGRID). Note that DIA is usually updated per sweep, either semi-implicit (iquad = 1) or explicit (iquad = 2). However, when ambient current is included, the bounds of the directional sector within a sweep may be different for each frequency bin (particularly the higher frequencies are modified by the current). So there may be some overlap of frequency bins between the sweeps, implying non-conservation of wave energy. To prevent this the user is advised to choose the integration of DIA per iteration instead of per sweep, i.e. iquad = 3. If you want to speed up your computation a bit more, than the choice iquad = 8 is a good choice.

Examples

In [1]: from rompy.swan.components.physics import QUADRUPL

In [2]: quadrupl = QUADRUPL()

In [3]: print(quadrupl.render())
QUADRUPL

In [4]: kwargs = dict(
   ...:     iquad=3, lambd=0.25, cnl4=3.0e7, csh1=5.5, csh2=0.833333, csh3=-1.25
   ...: )
   ...: 

In [5]: quadrupl = QUADRUPL(**kwargs)

In [6]: print(quadrupl.render())
QUADRUPL iquad=3 lambda=0.25 cnl4=30000000.0 csh1=5.5 csh2=0.833333 csh3=-1.25
Fields:
field cnl4: float | None = None

Proportionality coefficient for quadruplet interactions in case of DIA (SWAN default: 3.0e7

field csh1: float | None = None

Coefficient for shallow water scaling in case of DIA (SWAN default: 5.5)

field csh2: float | None = None

Coefficient for shallow water scaling in case of DIA (SWAN default: 0.833333)

field csh3: float | None = None

Coefficient for shallow water scaling in case of DIA (SWAN default: -1.25)

field iquad: Literal[1, 2, 3, 8, 4, 51, 52, 53] | None = None

Numerical procedures for integrating the quadruplets: 1 = semi-implicit per sweep, 2 = explicit per sweep, 3 = explicit per iteration, 8 = explicit per iteration, but with a more efficient implementation, 4 = multiple DIA, 51 = XNL (deep water transfer), 52 = XNL (deep water transfer with WAM depth scaling), 53 XNL (finite depth transfer) (SWAN default: 2)

field lambd: float | None = None

Coefficient for quadruplet configuration in case of DIA (SWAN default: 0.25)

field model_type: Literal['quadrupl', 'QUADRUPL'] = 'quadrupl'

Model type discriminator

cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.SCAT[source]

Scattering.

SCAT [iqcm] (GRID [rfac]) (TRUNC [alpha] [qmax])

Using this optional command, the user activates a source term that allows for the generation and propagation of cross correlations between scattered waves due to variations in the bathymetry and mean currents. Such variations are rapid compared to the distancebetween the crossing waves (at the scale of 100-1000 m) and is particularly relevant for cases involving narrowband waves (swells) in coastal regions with shallow water and ambient currents. In turn, the immediate spatial effects of coherent scattering, interference, refraction and diffraction can cause large-scale changes in the wave parameters.

References

Smit, P.B. and Janssen, T.T., 2013. The evolution of inhomogeneous wave statistics through a variable medium. Journal of Physical Oceanography, 43(8), pp.1741-1758.

Smit, P.B., Janssen, T.T. and Herbers, T.H.C., 2015. Stochastic modeling of inhomogeneous ocean waves. Ocean Modelling, 96, pp.26-35.

Smit, P.B., Janssen, T.T. and Herbers, T.H.C., 2015. Stochastic modeling of coherent wave fields over variable depth. Journal of Physical Oceanography, 45(4), pp.1139-1154.

Akrish, G., Smit, P., Zijlema, M. and Reniers, A., 2020. Modelling statistical wave interferences over shear currents. Journal of Fluid Mechanics, 891, p.A2.

Notes

Implemented in SWAN 41.41.

If both alpha and qmax options are provided to truncate the infinite convolution sum their mimimum is considered as the final limit on the sum.

Examples:#

In [1]: from rompy.swan.components.physics import SCAT

In [2]: scat = SCAT()

In [3]: print(scat.render())
SCAT

In [4]: scat = SCAT(iqcm=2, rfac=1.0, alpha=1.0)

In [5]: print(scat.render())
SCAT iqcm=2 GRID rfac=1.0 TRUNC alpha=1.0
Fields:
Validators:
field alpha: float | None = None

The coefficient by which the mean wave number is multiplied to set thelimit on the convolution sum (SWAN default: 1.0)

Validated by:
field iqcm: Literal[0, 1, 2] | None = None

Indicates the modelling and computation of QC scattering:

  • 0: no scattering

  • 1: scattering due to non-uniform bathymetry and currents (the latter only if applicable; see command INPGRID CURRENT)

  • 2: wave-current interaction under the assumption of a slowly varying bathymetry

(SWAN default: 1)

Validated by:
field model_type: Literal['scat', 'SCAT'] = 'scat'

Model type discriminator

Validated by:
field qmax: float | None = None

The maximum scattering wave number (in 1/m)

Validated by:
field rfac: float | None = None

The resolution factor through which the incident spectral width ismultiplied (SWAN default: 1.0)

Constraints:
  • ge = 1.0

Validated by:
cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

validator warn_if_qmax_and_alpha  »  all fields[source]
pydantic model rompy.swan.components.physics.SETUP[source]

Wave setup.

SETUP [supcor]

If this command is given, the wave-induced set-up is computed and accounted for in the wave computations (during the computation it is added to the depth that is obtained from the READ BOTTOM and READ WLEVEL commands). This approximation in SWAN can only be applied to open coast (unlimited supply of water from outside the domain, e.g. nearshore coasts) in contrast to closed basin, e.g. lakes and estuaries, where this option should not be used. Note that set-up is not computed correctly with spherical coordinates.

Notes

  • The SETUP command cannot be used in case of unstructured grids.

  • Set-up is not supported in case of parallel runs using either MPI or OpenMP.

Examples

In [1]: from rompy.swan.components.physics import SETUP

In [2]: setup = SETUP()

In [3]: print(setup.render())
SETUP

In [4]: setup = SETUP(supcor=0.5)

In [5]: print(setup.render())
SETUP supcor=0.5
Fields:
field model_type: Literal['setup', 'SETUP'] = 'setup'

Model type discriminator

field supcor: float | None = None

By default the wave-induced set-up is computed with a constant added such that the set-up is zero in the deepest point in the computational grid. The user can modify this constant by the value of supcor. The user can thus impose a set-up in any one point (and only one) in the computational grid by first running SWAN, then reading the set-up in that point and adding or subtracting the required value of supcor (in m; positive if the set-up has to rise) (SWAN default: 0.0)

cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.SICE[source]

Sea ice dissipation.

SICE [aice]

Using this command, the user activates a sink term to represent the dissipation of wave energy by sea ice. The default method is R19 empirical/parametric: a polynomial based on wave frequency (Rogers, 2019). This polynomial (in 1/m) has seven dimensional coefficients; see Scientific/Technical documentation for details. If this command is not used, SWAN will not account for sea ice effects.

References

Doble, M.J., De Carolis, G., Meylan, M.H., Bidlot, J.R. and Wadhams, P., 2015. Relating wave attenuation to pancake ice thickness, using field measurements and model results. Geophysical Research Letters, 42(11), pp.4473-4481.

Meylan, M.H., Bennetts, L.G. and Kohout, A.L., 2014. In situ measurements and analysis of ocean waves in the Antarctic marginal ice zone. Geophysical Research Letters, 41(14), pp.5046-5051.

Rogers, W.E., Meylan, M.H. and Kohout, A.L., 2018. Frequency distribution of dissipation of energy of ocean waves by sea ice using data from Wave Array 3 of the ONR “Sea State” field experiment. Nav. Res. Lab. Memo. Rep, pp.18-9801.

Rogers, W.E., Meylan, M.H. and Kohout, A.L., 2021. Estimates of spectral wave attenuation in Antarctic sea ice, using model/data inversion. Cold Regions Science and Technology, 182, p.103198.

Notes

Iis also necessary to describe the ice, using the ICE command (for uniform and stationary ice) or INPGRID/READINP commands (for variable ice).

Examples

In [1]: from rompy.swan.components.physics import SICE

In [2]: sice = SICE()

In [3]: print(sice.render())
SICE

In [4]: sice = SICE(aice=0.5)

In [5]: print(sice.render())
SICE aice=0.5

TODO: Verify if the aice parameter should be used with SICE command, it is not shown in the command tree but it is described as an option in the description.

Fields:
field aice: float | None = None

Ice concentration as a fraction from 0 to 1. Note that aice is allowed to vary over the computational region to account for the zonation of ice concentration. In that case use the commands INPGRID AICE and READINP AICE to define and read the sea concentration. The value of aice in this command is then not required (it will be ignored)

Constraints:
  • ge = 0.0

  • le = 1.0

field model_type: Literal['sice', 'SICE'] = 'sice'

Model type discriminator

cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.SICE_D15[source]

Sea ice dissipation based on the method of Doble et al. (2015).

SICE [aice] D15 [chf]

References

Doble, M.J., De Carolis, G., Meylan, M.H., Bidlot, J.R. and Wadhams, P., 2015. Relating wave attenuation to pancake ice thickness, using field measurements and model results. Geophysical Research Letters, 42(11), pp.4473-4481.

Examples

In [1]: from rompy.swan.components.physics import SICE_D15

In [2]: sice = SICE_D15()

In [3]: print(sice.render())
SICE D15

In [4]: sice = SICE_D15(aice=0.2, chf=0.1)

In [5]: print(sice.render())
SICE aice=0.2 D15 chf=0.1
Fields:
field aice: float | None = None

Ice concentration as a fraction from 0 to 1. Note that aice is allowed to vary over the computational region to account for the zonation of ice concentration. In that case use the commands INPGRID AICE and READINP AICE to define and read the sea concentration. The value of aice in this command is then not required (it will be ignored)

Constraints:
  • ge = 0.0

  • le = 1.0

field chf: float | None = None

A simple coefficient of proportionality (SWAN default: 0.1)

field model_type: Literal['d15', 'D15'] = 'd15'

Model type discriminator

cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.SICE_M18[source]

Sea ice dissipation based on the method of Meylan et al. (2018).

SICE [aice] M18 [chf]

References

Meylan, M.H., Bennetts, L.G. and Kohout, A.L., 2014. In situ measurements and analysis of ocean waves in the Antarctic marginal ice zone. Geophysical Research Letters, 41(14), pp.5046-5051.

Examples

In [1]: from rompy.swan.components.physics import SICE_M18

In [2]: sice = SICE_M18()

In [3]: print(sice.render())
SICE M18

In [4]: sice = SICE_M18(aice=0.8, chf=0.059)

In [5]: print(sice.render())
SICE aice=0.8 M18 chf=0.059
Fields:
field aice: float | None = None

Ice concentration as a fraction from 0 to 1. Note that aice is allowed to vary over the computational region to account for the zonation of ice concentration. In that case use the commands INPGRID AICE and READINP AICE to define and read the sea concentration. The value of aice in this command is then not required (it will be ignored)

Constraints:
  • ge = 0.0

  • le = 1.0

field chf: float | None = None

A simple coefficient of proportionality (SWAN default: 0.059)

field model_type: Literal['m18', 'M18'] = 'm18'

Model type discriminator

cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.SICE_R19[source]

Sea ice dissipation based on the method of Rogers et al (2019).

SICE [aice] R19 [c0] [c1] [c2] [c3] [c4] [c5] [c6]

The default options recover the polynomial of Meylan et al. (2014), calibrated for a case of ice floes, mostly 10 to 25 m in diameter, in the marginal ice zone near Antarctica. Examples for other calibrations can be found in the Scientific/Technical documentation.

References

Meylan, M.H., Bennetts, L.G. and Kohout, A.L., 2014. In situ measurements and analysis of ocean waves in the Antarctic marginal ice zone. Geophysical Research Letters, 41(14), pp.5046-5051.

Rogers, W.E., Meylan, M.H. and Kohout, A.L., 2018. Frequency distribution of dissipation of energy of ocean waves by sea ice using data from Wave Array 3 of the ONR “Sea State” field experiment. Nav. Res. Lab. Memo. Rep, pp.18-9801.

Examples

In [1]: from rompy.swan.components.physics import SICE_R19

In [2]: sice = SICE_R19()

In [3]: print(sice.render())
SICE R19

In [4]: kwargs = dict(
   ...:     aice=0.5,
   ...:     c0=0.0,
   ...:     c1=0.0,
   ...:     c2=1.06e-3,
   ...:     c3=0.0,
   ...:     c4=0.0,
   ...:     c5=0.0,
   ...:     c6=0.0,
   ...: )
   ...: 

In [5]: sice = SICE_R19(**kwargs)

In [6]: print(sice.render())
SICE aice=0.5 R19 c0=0.0 c1=0.0 c2=0.00106 c3=0.0 c4=0.0 c5=0.0 c6=0.0
Fields:
field aice: float | None = None

Ice concentration as a fraction from 0 to 1. Note that aice is allowed to vary over the computational region to account for the zonation of ice concentration. In that case use the commands INPGRID AICE and READINP AICE to define and read the sea concentration. The value of aice in this command is then not required (it will be ignored)

Constraints:
  • ge = 0.0

  • le = 1.0

field c0: float | None = None

Polynomial coefficient (in 1/m) for determining the rate of sea ice dissipation (SWAN default: 0.0)

field c1: float | None = None

Polynomial coefficient (in s/m) for determining the rate of sea ice dissipation (SWAN default: 0.0)

field c2: float | None = None

Polynomial coefficient (in s2/m) for determining the rate of sea ice dissipation (SWAN default: 1.06E-3)

field c3: float | None = None

Polynomial coefficient (in s3/m) for determining the rate of sea ice dissipation (SWAN default: 0.0)

field c4: float | None = None

Polynomial coefficient (in s4/m) for determining the rate of sea ice dissipation (SWAN default: 2.3E-2)

field c5: float | None = None

Polynomial coefficient (in s5/m) for determining the rate of sea ice dissipation (SWAN default: 0.0)

field c6: float | None = None

Polynomial coefficient (in s6/m) for determining the rate of sea ice dissipation (SWAN default: 0.0)

field model_type: Literal['r19', 'R19'] = 'r19'

Model type discriminator

cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.SICE_R21B[source]

Sea ice dissipation based on the method of Rogers et al. (2021).

SICE [aice] R21B [chf] [npf]

References

Rogers, W.E., Meylan, M.H. and Kohout, A.L., 2021. Estimates of spectral wave attenuation in Antarctic sea ice, using model/data inversion. Cold Regions Science and Technology, 182, p.103198.

Examples

In [1]: from rompy.swan.components.physics import SICE_R21B

In [2]: sice = SICE_R21B()

In [3]: print(sice.render())
SICE R21B

In [4]: sice = SICE_R21B(aice=0.8, chf=2.9, npf=4.5)

In [5]: print(sice.render())
SICE aice=0.8 R21B chf=2.9 npf=4.5
Fields:
field aice: float | None = None

Ice concentration as a fraction from 0 to 1. Note that aice is allowed to vary over the computational region to account for the zonation of ice concentration. In that case use the commands INPGRID AICE and READINP AICE to define and read the sea concentration. The value of aice in this command is then not required (it will be ignored)

Constraints:
  • ge = 0.0

  • le = 1.0

field chf: float | None = None

A simple coefficient of proportionality (SWAN default: 2.9)

field model_type: Literal['r21b', 'R21B'] = 'r21b'

Model type discriminator

field npf: float | None = None

Controls the degree of dependence on frequency and ice thickness (SWAN default: 4.5)

cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.SSWELL_ARDHUIN[source]

Nonbreaking dissipation of Ardhuin et al. (2010).

SSWELL ARDHUIN [cdsv]

References

Ardhuin, F., Rogers, E., Babanin, A.V., Filipot, J.F., Magne, R., Roland, A., Van Der Westhuysen, A., Queffeulou, P., Lefevre, J.M., Aouf, L. and Collard, F., 2010. Semiempirical dissipation source functions for ocean waves. Part I: Definition, calibration, and validation. Journal of Physical Oceanography, 40(9), pp.1917-1941.

Examples

In [1]: from rompy.swan.components.physics import SSWELL_ARDHUIN

In [2]: sswell = SSWELL_ARDHUIN()

In [3]: print(sswell.render())
SSWELL ARDHUIN

In [4]: sswell = SSWELL_ARDHUIN(cdsv=1.2)

In [5]: print(sswell.render())
SSWELL ARDHUIN cdsv=1.2
Fields:
field cdsv: float | None = None

Coefficient related to laminar atmospheric boundary layer (SWAN default: 1.2)

field model_type: Literal['ardhuin', 'ARDHUIN'] = 'ardhuin'

Model type discriminator

cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.SSWELL_ROGERS[source]

Nonbreaking dissipation of Rogers et al. (2012).

SSWELL ROGERS [cdsv] [feswell]

References

Rogers, W.E., Babanin, A.V. and Wang, D.W., 2012. Observation-consistent input and whitecapping dissipation in a model for wind-generated surface waves: Description and simple calculations. Journal of Atmospheric and Oceanic Technology, 29(9), pp.1329-1346.

Examples

In [1]: from rompy.swan.components.physics import SSWELL_ROGERS

In [2]: sswell = SSWELL_ROGERS()

In [3]: print(sswell.render())
SSWELL ROGERS

In [4]: sswell = SSWELL_ROGERS(cdsv=1.2, feswell=0.5)

In [5]: print(sswell.render())
SSWELL ROGERS cdsv=1.2 feswell=0.5
Fields:
field cdsv: float | None = None

Coefficient related to laminar atmospheric boundary layer (SWAN default: 1.2)

field feswell: float | None = None

Swell dissipation factor

field model_type: Literal['rogers', 'ROGERS'] = 'rogers'

Model type discriminator

cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.SSWELL_ZIEGER[source]

Nonbreaking dissipation of Zieger et al. (2015).

SSWELL ZIEGER [b1]

Swell dissipation of Young et al. (2013) updated by Zieger et al. (2015). The Zieger option is intended for use with negative wind input via the NEGATINP command. Zieger non-breaking dissipation follows the method used in WAVEWATCH III version 4 and does not include the steepness-dependent swell coefficient introduced in WAVEWATCH III version 5.

References

Zieger, S., Babanin, A.V., Rogers, W.E. and Young, I.R., 2015. Observation-based source terms in the third-generation wave model WAVEWATCH. Ocean Modelling, 96, pp.2-25.

Young, I.R., Babanin, A.V. and Zieger, S., 2013. The decay rate of ocean swell observed by altimeter. Journal of physical oceanography, 43(11), pp.2322-2333.

Examples

In [1]: from rompy.swan.components.physics import SSWELL_ZIEGER

In [2]: sswell = SSWELL_ZIEGER()

In [3]: print(sswell.render())
SSWELL ZIEGER

In [4]: sswell = SSWELL_ZIEGER(b1=0.00025)

In [5]: print(sswell.render())
SSWELL ZIEGER b1=0.00025
Fields:
field b1: float | None = None

Non-dimensional proportionality coefficient (SWAN default: 0.00025)

field model_type: Literal['zieger', 'ZIEGER'] = 'zieger'

Model type discriminator

cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.SURFBEAT[source]

Surfbeat.

SURFBEAT [df] [nmax] [emin] UNIFORM/LOGARITHMIC

Using this optional command, the user activates the Infragravity Energy Module (IEM) of Reniers and Zijlema (2022). Besides the energy balance equation for a sea-swell wave field, another energy balance is included to account for the transfer of sea-swell energy to the bound infragravity (BIG) wave. This infragravity energy balance also involves a nonlinear transfer, expressed by the biphase, through the phase coupling between the radiation stress forcing and the BIG wave. For the prediction of the biphase for obliquely incident waves, an evolution equation is provided under the assumption that the bottom slopes are mild and alongshore uniform.

References

Reniers, A. and Zijlema, M., 2022. Swan surfbeat-1d. Coastal Engineering, 172, p.104068.

Examples:#

In [1]: from rompy.swan.components.physics import SURFBEAT

In [2]: surfbeat = SURFBEAT()

In [3]: print(surfbeat.render())
SURFBEAT

In [4]: surfbeat = SURFBEAT(df=0.01, nmax=50000, emin=0.05, spacing="logarithmic")

In [5]: print(surfbeat.render())
SURFBEAT df=0.01 nmax=50000 emin=0.05 LOGARITHMIC
Fields:
field df: float | None = None

The constant size of BIG frequency bin (in Hz) (SWAN default: 0.01)

Constraints:
  • ge = 0.0

field emin: float | None = None

The energy threshold in fraction of energy spectrum peak. With this threshold one takes into account those short wave components to create bichromatic wave groups while their energy levels are larger than emin x E_max with E_max the peak of the spectrum (SWAN default: 0.05)

field model_type: Literal['surfbeat', 'SURFBEAT'] = 'surfbeat'

Model type discriminator

field nmax: int | None = None

The maximum number of short-wave pairs for creating bichromatic wave groups (SWAN default: 50000)

Constraints:
  • ge = 0

field spacing: Literal['uniform', 'logarithmic'] | None = None

Define if frequencies for reflected ig waves are uniformly or logarithmically distributed

cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.TRIAD[source]

Wave triad interactions.

TRIAD [itriad] [trfac] [cutfr] [a] [b] [urcrit] [urslim]

With this command the user can activate the triad wave-wave interactions. If this command is not used, SWAN will not account for triads.

Note

This is the TRIAD specification in SWAN < 41.45.

Examples

In [1]: from rompy.swan.components.physics import TRIAD

In [2]: triad = TRIAD()

In [3]: print(triad.render())
TRIAD

In [4]: triad = TRIAD(
   ...:     itriad=1,
   ...:     trfac=0.8,
   ...:     cutfr=2.5,
   ...:     a=0.95,
   ...:     b=-0.75,
   ...:     ucrit=0.2,
   ...:     urslim=0.01,
   ...: )
   ...: 

In [5]: print(triad.render())
TRIAD itriad=1 trfac=0.8 cutfr=2.5 a=0.95 b=-0.75 urcrit=0.2 urslim=0.01
Fields:
field a: float | None = None

First calibration parameter for tuning K in Eq. (5.1) of Becq-Girard et al. (1999). This parameter is associated with broadening of the resonance condition (SWAN default: 0.95)

field b: float | None = None

Second calibration parameter for tuning K in Eq. (5.1) of Becq-Girard et al. (1999). This parameter is associated with broadening of the resonance condition (SWAN default: -0.75 for 1D, 0.0 for 2D

field cutfr: float | None = None

Controls the maximum frequency that is considered in the LTA computation. The value of cutfr is the ratio of this maximum frequency over the mean frequency (SWAN default: 2.5)

field itriad: Literal[1, 2] | None = None

Approximation method for the triad computation:

  • 1: the LTA method of Eldeberky (1996)

  • 2: the SPB method of Becq-Girard et al. (1999) (SWAN default: 1)

field model_type: Literal['triad', 'TRIAD'] = 'triad'

Model type discriminator

field trfac: float | None = None

Proportionality coefficient (SWAN default: 0.8 in case of LTA method, 0.9 in case of SPB method)

field ucrit: float | None = None

The critical Ursell number appearing in the expression for the biphase (SWAN default: 0.2)

field urslim: float | None = None

The lower threshold for Ursell number, if the actual Ursell number is below this value triad interactions are be computed (SWAN default: 0.01)

cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.TRIAD_DCTA[source]

Triad interactions with the DCTA method of Booij et al. (2009).

TRIAD DCTA [trfac] [p] COLL|NONC BIPHHASE ELDEBERKY|DEWIT

References

Booij, N., Holthuijsen, L.H. and Bénit, M.P., 2009. A distributed collinear triad approximation in SWAN. In Proceedings Of Coastal Dynamics 2009: Impacts of Human Activities on Dynamic Coastal Processes (With CD-ROM) (pp. 1-10).

Note

This is the default method to compute the triad interactions in SWAN >= 41.45, it is not supported in earlier versions of the model.

Examples

In [1]: from rompy.swan.components.physics import TRIAD_DCTA

In [2]: triad = TRIAD_DCTA()

In [3]: print(triad.render())
TRIAD DCTA COLL

In [4]: triad = TRIAD_DCTA(
   ...:     trfac=4.4,
   ...:     p=1.3,
   ...:     noncolinear=True,
   ...:     biphase={"model_type": "dewit", "lpar": 0.0},
   ...: )
   ...: 

In [5]: print(triad.render())
TRIAD DCTA trfac=4.4 p=1.3 NONC BIPHASE DEWIT lpar=0.0
Fields:
field biphase: ELDEBERKY | DEWIT | None = None

Defines the parameterization of biphase (self-self interaction) (SWAN default: ELDEBERKY)

field model_type: Literal['dcta', 'DCTA'] = 'dcta'

Model type discriminator

field noncolinear: bool = False

If True, the noncolinear triad interactions with the DCTA framework are accounted for

field p: float | None = None

Shape coefficient to force the high-frequency tail(SWAN default: 4/3)

field trfac: float | None = None

Scaling factor that controls the intensity of the triad interaction due to DCTA (SWAN default: 4.4)

cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.TRIAD_LTA[source]

Triad interactions with the LTA method of Eldeberky (1996).

TRIAD LTA [trfac] [cutfr] BIPHHASE ELDEBERKY|DEWIT

References

Eldeberky, Y., Polnikov, V. and Battjes, J.A., 1996. A statistical approach for modeling triad interactions in dispersive waves. In Coastal Engineering 1996 (pp. 1088-1101).

Note

This method to compute the triad interactions is only supported in SWAN >= 41.45.

Examples

In [1]: from rompy.swan.components.physics import TRIAD_LTA

In [2]: triad = TRIAD_LTA()

In [3]: print(triad.render())
TRIAD LTA

In [4]: triad = TRIAD_LTA(
   ...:     trfac=0.8,
   ...:     cutfr=2.5,
   ...:     biphase={"model_type": "eldeberky", "urcrit": 0.63},
   ...: )
   ...: 

In [5]: print(triad.render())
TRIAD LTA trfac=0.8 cutfr=2.5 BIPHASE ELDEBERKY urcrit=0.63
Fields:
field biphase: ELDEBERKY | DEWIT | None = None

Defines the parameterization of biphase (self-self interaction) (SWAN default: ELDEBERKY)

field cutfr: float | None = None

Controls the maximum frequency that is considered in the LTA computation. The value of cutfr is the ratio of this maximum frequency over the mean frequency (SWAN default: 2.5)

field model_type: Literal['lta', 'LTA'] = 'lta'

Model type discriminator

field trfac: float | None = None

Scaling factor that controls the intensity of the triad interaction due to LTA (SWAN default: 0.8)

cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.TRIAD_SPB[source]

Triad interactions with the SPB method of Becq-Girard et al. (1999).

TRIAD SPB [trfac] [a] [b] BIPHHASE ELDEBERKY|DEWIT

References

Becq-Girard, F., Forget, P. and Benoit, M., 1999. Non-linear propagation of unidirectional wave fields over varying topography. Coastal Engineering, 38(2), pp.91-113.

Note

This method to compute the triad interactions is only supported in SWAN >= 41.45.

Examples

In [1]: from rompy.swan.components.physics import TRIAD_SPB

In [2]: triad = TRIAD_SPB()

In [3]: print(triad.render())
TRIAD SPB

In [4]: triad = TRIAD_SPB(
   ...:     trfac=0.9,
   ...:     a=0.95,
   ...:     b=0.0,
   ...:     biphase={"model_type": "eldeberky", "urcrit": 0.63},
   ...: )
   ...: 

In [5]: print(triad.render())
TRIAD SPB trfac=0.9 a=0.95 b=0.0 BIPHASE ELDEBERKY urcrit=0.63
Fields:
field a: float | None = None

First calibration parameter for tuning K in Eq. (5.1) of Becq-Girard et al. (1999). This parameter is associated with broadening of the resonance condition. The default value is 0.95 and is calibrated by means of laboratory experiments (SWAN default: 0.95)

field b: float | None = None

Second calibration parameter for tuning K in Eq. (5.1) of Becq-Girard et al. (1999). This parameter is associated with broadening of the resonance condition. The default value is -0.75 and is calibrated by means of laboratory experiments. However, it may not be appropriate for true 2D field cases as it does not scale with the wave field characteristics. Hence, this parameter is set to zero (SWAN default: 0.0)

field biphase: ELDEBERKY | DEWIT | None = None

Defines the parameterization of biphase (self-self interaction) (SWAN default: ELDEBERKY)

field model_type: Literal['spb', 'SPB'] = 'spb'

Model type discriminator

field trfac: float | None = None

Scaling factor that controls the intensity of the triad interaction due to SPB (SWAN default: 0.9)

cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.TURBULENCE[source]

Turbulent viscosity.

TURBULENCE [ctb] (CURRENT [tbcur])

With this optional command the user can activate turbulent viscosity. This physical effect is also activated by reading values of the turbulent viscosity using the READGRID TURB command, but then with the default value of ctb. The command READGRID TURB is necessary if this command TURB is used since the value of the viscosity is assumed to vary over space.

Examples

In [1]: from rompy.swan.components.physics import TURBULENCE

In [2]: turbulence = TURBULENCE(current=False)

In [3]: print(turbulence.render())
TURBULENCE

In [4]: turbulence = TURBULENCE(ctb=0.01, current=True, tbcur=0.004)

In [5]: print(turbulence.render())
TURBULENCE ctb=0.01 CURRENT tbcur=0.004
Fields:
Validators:
field ctb: float | None = None

The value of the proportionality coefficient appearing in the energy dissipation term (SWAN default: 0.01)

Validated by:
field current: bool | None = True

If this keyword is present the turbulent viscosity will be derived from the product of the depth and the absolute value of the current velocity. If the command READGRID TURB is used, this option is ignored; the values read from file will prevail

Validated by:
field model_type: Literal['turbulence', 'TURBULENCE'] = 'turbulence'

Model type discriminator

Validated by:
field tbcur: float | None = None

The factor by which depth x current velocity is multiplied in order to get the turbulent viscosity (SWAN default: 0.004)

Validated by:
cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

validator tbcur_only_with_current  »  all fields[source]
pydantic model rompy.swan.components.physics.VEGETATION[source]

Vegetation dumping.

VEGETATION [iveg] < [height] [diamtr] [nstems] [drag] >

With this command the user can activate wave damping due to vegetation based on the Dalrymple’s formula (1984) as implemented by Suzuki et al. (2011). This damping is uniform over the wave frequencies. An alternative is the frequency-dependent (canopy) dissipation model of Jacobsen et al. (2019). If this command is not used, SWAN will not account for vegetation effects.

The vegetation (rigid plants) can be divided over a number of vertical segments and so, the possibility to vary the vegetation vertically is included. Each vertical layer represents some characteristics of the plants. These variables as indicated below can be repeated as many vertical layers to be chosen.

References

Dalrymple, R.A., Kirby, J.T. and Hwang, P.A., 1984. Wave diffraction due to areas of energy dissipation. Journal of waterway, port, coastal, and ocean engineering, 110(1), pp.67-79.

Jacobsen, N.G., Bakker, W., Uijttewaal, W.S. and Uittenbogaard, R., 2019. Experimental investigation of the wave-induced motion of and force distribution along a flexible stem. Journal of Fluid Mechanics, 880, pp.1036-1069.

Suzuki, T., Zijlema, M., Burger, B., Meijer, M.C. and Narayan, S., 2012. Wave dissipation by vegetation with layer schematization in SWAN. Coastal Engineering, 59(1), pp.64-71.

Notes

Vertical layering of the vegetation is not yet implemented for the Jacobsen et al. (2019) method.

Examples

In [1]: from rompy.swan.components.physics import VEGETATION

# Single layer
In [2]: vegetation = VEGETATION(
   ...:     height=1.2,
   ...:     diamtr=0.1,
   ...:     drag=0.5,
   ...:     nstems=10,
   ...: )
   ...: 

In [3]: print(vegetation.render())
VEGETATION iveg=1 height=1.2 diamtr=0.1 nstems=10 drag=0.5

# 2 vertical layers
In [4]: vegetation = VEGETATION(
   ...:     iveg=1,
   ...:     height=[1.2, 0.8],
   ...:     diamtr=[0.1, 0.1],
   ...:     drag=[0.5, 0.5],
   ...:     nstems=[10, 5],
   ...: )
   ...: 

In [5]: print(vegetation.render())
VEGETATION iveg=1 height=1.2 diamtr=0.1 nstems=10 drag=0.5 height=0.8 diamtr=0.1 nstems=5 drag=0.5
Fields:
Validators:
field diamtr: float | list[float] [Required]

The diameter of each plant stand per layer (in m)

Validated by:
field drag: float | list[float] [Required]

The drag coefficient per layer

Validated by:
field height: float | list[float] [Required]

The plant height per layer (in m)

Validated by:
field iveg: Literal[1, 2] = 1

Indicates the method for the vegetation computation (SWAN default: 1):

  • 1: Suzuki et al. (2011)

  • 2: Jacobsen et al. (2019)

Validated by:
field model_type: Literal['vegetation', 'VEGETATION'] = 'vegetation'

Model type discriminator

Validated by:
field nstems: int | list[int] = 1

The number of plant stands per square meter for each layer. Note that nstems is allowed to vary over the computational region to account for the zonation of vegetation. In that case use the commands IMPGRID NPLANTS and READINP NPLANTS to define and read the vegetation density. The (vertically varying) value of nstems in this command will be multiplied by this horizontally varying plant density (SWAN default: 1)

Validated by:
cmd() str[source]

Command file string for this component.

validator jacomsen_layering_not_implemented  »  all fields[source]
validator number_of_layers  »  nstems, height, drag, diamtr[source]
render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.WCAPPING_AB[source]

Whitecapping according to Alves and Banner (2003).

WCAPPING AB [cds2] [br] CURRENT [cds3]

References

Alves, J.H.G. and Banner, M.L., 2003. Performance of a saturation-based dissipation-rate source term in modeling the fetch-limited evolution of wind waves. Journal of Physical Oceanography, 33(6), pp.1274-1298.

Examples

In [1]: from rompy.swan.components.physics import WCAPPING_AB

In [2]: wcapping = WCAPPING_AB()

In [3]: print(wcapping.render())
WCAPPING AB

In [4]: wcapping = WCAPPING_AB(cds2=5.0e-5, br=1.75e-3, current=True, cds3=0.8)

In [5]: print(wcapping.render())
WCAPPING AB cds2=5e-05 br=0.00175 CURRENT cds3=0.8
Fields:
field br: float | None = None

Threshold saturation level (SWAN default: 1.75e-3)

field cds2: float | None = None

proportionality coefficient due to Alves and Banner (2003) (SWAN default: 5.0e-5)

field cds3: float | None = None

Proportionality coefficient (SWAN default: 0.8)

field current: bool = False

Indicates that enhanced current-induced dissipation as proposed by Van der Westhuysen (2012) is to be added

field model_type: Literal['ab', 'AB'] = 'ab'

Model type discriminator

cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.physics.WCAPPING_KOMEN[source]

Whitecapping according to Komen (1984).

WCAPPING KOMEN [cds2] [stpm] [powst] [delta] [powk]

Notes

The SWAN default for delta has been changed since version 40.91A. The setting delta = 1 will improve the prediction of the wave energy at low frequencies, and hence the mean wave period. The original default was delta = 0, which corresponds to WAM Cycle 3. See the Scientific/Technical documentation for further details.

References

Komen, G.J., Hasselmann, S. and Hasselmann, K., 1984. On the existence of a fully developed wind-sea spectrum. Journal of physical oceanography, 14(8), pp.1271-1285.

Examples

In [1]: from rompy.swan.components.physics import WCAPPING_KOMEN

In [2]: wcapping = WCAPPING_KOMEN()

In [3]: print(wcapping.render())
WCAPPING KOMEN

In [4]: wcapping = WCAPPING_KOMEN(cds2=2.36e-5, stpm=3.02e-3, powst=2, delta=1, powk=2)

In [5]: print(wcapping.render())
WCAPPING KOMEN cds2=2.36e-05 stpm=0.00302 powst=2.0 delta=1.0 powk=2.0
Fields:
field cds2: float | None = None

Coefficient for determining the rate of whitecapping dissipation ($Cds$) (SWAN default: 2.36e-5)

field delta: float | None = None

Coefficient which determines the dependency of the whitecapping on wave number (SWAN default: 1)

field model_type: Literal['komen', 'KOMEN'] = 'komen'

Model type discriminator

field powk: float | None = None

power of wave number normalized with the mean wave number (SWAN default: 1)

field powst: float | None = None

Power of steepness normalized with the wave steepness of a Pierson-Moskowitz spectrum (SWAN default: 2)

field stpm: float | None = None

Value of the wave steepness for a Pierson-Moskowitz spectrum ($s^2_{PM}$) (SWAN default: 3.02e-3)

cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

Numerics#

Model numerics components.

pydantic model rompy.swan.components.numerics.NUMERIC[source]

Numerical properties.

NUMeric ( STOPC [dabs] [drel] [curvat] [npnts] ->STAT|NONSTAT [limiter] ) &
    ( DIRimpl [cdd] ) ( SIGIMpl [css] [eps2] [outp] [niter] ) &
    ( CTheta [cfl] ) ( CSigma [cfl] ) ( SETUP [eps2] [outp] [niter] )

Examples

In [1]: from rompy.swan.components.numerics import NUMERIC

In [2]: numeric = NUMERIC()

In [3]: print(numeric.render())
NUMERIC

In [4]: numeric = NUMERIC(
   ...:     stop=dict(
   ...:         model_type="stopc",
   ...:         dabs=0.05,
   ...:         drel=0.01,
   ...:         curvat=0.05,
   ...:         npnts=99.5,
   ...:     ),
   ...:     dirimpl=dict(cdd=0.5),
   ...:     sigimpl=dict(css=0.5, eps2=1e-4, outp=0, niter=20),
   ...:     ctheta=dict(cfl=0.9),
   ...:     csigma=dict(cfl=0.9),
   ...:     setup=dict(eps2=1e-4, outp=0, niter=20),
   ...: )
   ...: 

In [5]: print(numeric.render())
NUMERIC STOPC dabs=0.05 drel=0.01 curvat=0.05 npnts=99.5 DIRIMPL cdd=0.5 SIGIMPL css=0.5 eps2=0.0001 outp=0 niter=20 CTHETA cfl=0.9
Fields:
field csigma: CSIGMA | None = None

Prevents excessive frequency shifting

field ctheta: CTHETA | None = None

Prevents excessive directional turning

field dirimpl: DIRIMPL | None = None

Numerical scheme for refraction

field model_type: Literal['numeric', 'NUMERIC'] = 'numeric'

Model type discriminator

field setup: SETUP | None = None

Stop criteria in the computation of wave setup

field sigimpl: SIGIMPL | None = None

Frequency shifting accuracy

field stop: STOPC | ACCUR | None = None

Iteration termination criteria

cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

pydantic model rompy.swan.components.numerics.PROP[source]

Propagation scheme.

PROP BSTB|GSE

Notes

  • The scheme defaults to S&L and SORDUP for nonstationary and stationary simulations if not specified.

  • All schemes (BSBT, SORDUP and S&L) can be used in combination with curvilinear grids. With the higher order schemes (S&L and SORDUP) it is important to use a gradually varying grid otherwise there may be a severe loss of accuracy. If sharp transitions in the grid cannot be avoided it is safer to use the BSBT scheme.

  • In the computation with unstructured meshes, a lowest order upwind scheme will be employed. This scheme is very robust but rather diffusive. This may only be significant for the case when swell waves propagate over relative large distances (in the order of thousands of kilometers) within the model domain. However and most fortunately, in such a case this will alleviate the garden-sprinkler effect.

  • Alleviating the garden-sprinkler effect by adding some diffusion makes the SWAN computation conditionally stable. You can either use (i) a smaller time step, (ii) a lower value of waveage, (iii) better resolution in the directional space, or (iv) worse resolution in the geographic space, in order of preference, to make the model stable when necessary.

Examples

In [1]: from rompy.swan.components.numerics import PROP

In [2]: prop = PROP()

In [3]: print(prop.render())
PROP

In [4]: prop = PROP(scheme=dict(model_type="bsbt"))

In [5]: print(prop.render())
PROP BSBT

In [6]: prop = PROP(
   ...:     scheme=dict(
   ...:         model_type="gse",
   ...:         waveage=dict(delt="PT5H", dfmt="hr"),
   ...:     ),
   ...: )
   ...: 

In [7]: print(prop.render())
PROP GSE waveage=5.0 HR
Fields:
field model_type: Literal['prop', 'PROP'] = 'prop'

Model type discriminator

field scheme: BSBT | GSE | None = None

Propagation scheme, by default S&L for nonstationary and SORDUP for stationary computation.

cmd() str[source]

Command file string for this component.

render(cmd: str | list | None = None) str

Render the component to a string.

Parameters:

cmd (Optional[str | list]) – Command string or list of command strings to render, by default self.cmd().

Returns:

cdmstr – The rendered command file component.

Return type:

str

Swan subcomponents#

Base#

Base class for SWAN sub-components.

pydantic model rompy.swan.subcomponents.base.BaseSubComponent[source]

Base class for SWAN sub-components.

This class is not intended to be used directly, but to be subclassed by other SWAN sub-components to implement the following common behaviour:

  • Define a render() method to render a CMD string from the subcomponent

  • Forbid extra arguments so only implemented fields must be specified

Fields:
  • model_type (Literal['subcomponent'])

field model_type: Literal['subcomponent'] [Required]

Model type discriminator

cmd() str[source]
render() str[source]

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.base.IJ[source]

Points in grid indices coordinates.

< [x] [y] >

Note

Coordinates should be given in m when Cartesian coordinates are used or degrees when Spherical coordinates are used (see command COORD).

Examples

In [1]: from rompy.swan.subcomponents.base import IJ

In [2]: points = IJ(i=[0, 0, 5], j=[0, 19, 19])

In [3]: print(points.render())

i=0 j=0
i=0 j=19
i=5 j=19
Fields:
Validators:
field i: list[int] [Required]

i-index values

Validated by:
field j: list[int] [Required]

j-index values

Validated by:
field model_type: Literal['ij', 'IJ'] = 'ij'

Model type discriminator

Validated by:
cmd() str[source]
render() str

Render the sub-component to a string.

validator validate_size  »  all fields[source]
property size
pydantic model rompy.swan.subcomponents.base.XY[source]

Points in problem coordinates.

< [x] [y] >

Note

Coordinates should be given in m when Cartesian coordinates are used or degrees when Spherical coordinates are used (see command COORD).

Examples

In [1]: from rompy.swan.subcomponents.base import XY

In [2]: points = XY(
   ...:     x=[172, 172, 172, 172.5, 173],
   ...:     y=[-41, -40.5, -40, -40, -40],
   ...:     fmt="0.2f",
   ...: )
   ...: 

In [3]: print(points.render())

172.00 -41.00
172.00 -40.50
172.00 -40.00
172.50 -40.00
173.00 -40.00
Fields:
Validators:
field fmt: str = '0.8f'

The format to render floats values

Validated by:
field model_type: Literal['xy', 'XY'] = 'xy'

Model type discriminator

Validated by:
field x: list[float] [Required]

Problem x-coordinate values

Validated by:
field y: list[float] [Required]

Problem y-coordinate values

Validated by:
cmd() str[source]
render() str

Render the sub-component to a string.

validator validate_size  »  all fields[source]
property size

Startup#

SWAN startup subcomponents.

pydantic model rompy.swan.subcomponents.startup.CARTESIAN[source]

Cartesian coordinates.

CARTESIAN

All locations and distances are in m. Coordinates are given with respect to x- and y-axes chosen by the user in the various commands.

Examples

In [1]: from rompy.swan.components.startup import CARTESIAN

In [2]: coords = CARTESIAN()

In [3]: print(coords.render())
CARTESIAN
Fields:
field model_type: Literal['cartesian', 'CARTESIAN'] = 'cartesian'

Model type discriminator

cmd() str
render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.startup.SPHERICAL[source]

Spherical coordinates.

SPHERICAL [->CCM|QC]

Notes

projection options:

  • CCM: central conformal Mercator. The horizontal and vertical scales are uniform in terms of cm/degree over the area shown. In the centre of the scale is identical to that of the conventional Mercator projection (but only at that centre). The area in the projection centre is therefore exactly conformal.

  • QC: the projection method is quasi-cartesian, i.e. the horizontal and vertical scales are equal to one another in terms of cm/degree.

All coordinates of locations and geographical grid sizes are given in degrees;`x` is longitude with x = 0 being the Greenwich meridian and x > 0 is East of this meridian; y is latitude with y > 0 being the Northern hemisphere. Input and output grids have to be oriented with their x-axis to the East; mesh sizes are in degrees. All other distances are in meters.

Note that spherical coordinates can also be used for relatively small areas, say 10 or 20 km horizontal dimension. This may be useful if one obtains the boundary conditions by nesting in an oceanic model which is naturally formulated in spherical coordinates. Note that in case of spherical coordinates regular grids must always be oriented E-W, N-S, i.e. alpc=0, alpinp=0, alpfr=0 (see commands CGRID, INPUT GRID and FRAME, respectively).

Examples

In [1]: from rompy.swan.components.startup import SPHERICAL

In [2]: coords = SPHERICAL()

In [3]: print(coords.render())
SPHERICAL CCM

In [4]: coords = SPHERICAL(projection="qc")

In [5]: print(coords.render())
SPHERICAL QC
Fields:
field model_type: Literal['spherical', 'SPHERICAL'] = 'spherical'

Model type discriminator

field projection: Literal['ccm', 'qc'] = 'ccm'

Defines the projection method in case of spherical coordinates, ccm Central Conformal Mercator, qc means Quasi-cartesian

cmd() str[source]

Render subcomponent cmd.

render() str

Render the sub-component to a string.

Spectrum#

Spectrum subcomponents.

pydantic model rompy.swan.subcomponents.spectrum.BIN[source]

Single frequency bin spectral shape.

BIN

Examples

In [1]: from rompy.swan.subcomponents.spectrum import BIN

In [2]: shape = BIN()

In [3]: print(shape.render())
BIN
Fields:
field model_type: Literal['bin', 'BIN'] = 'bin'

Model type discriminator

cmd() str
render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.spectrum.GAUSS[source]

Gaussian spectral shape.

GAUSS [sigfr]

Examples

In [1]: from rompy.swan.subcomponents.spectrum import GAUSS

In [2]: shape = GAUSS(sigfr=0.02)

In [3]: print(shape.render())
GAUSS sigfr=0.02
Fields:
field model_type: Literal['gauss', 'GAUSS'] = 'gauss'

Model type discriminator

field sigfr: float [Required]

Width of the Gaussian frequency spectrum expressed as a standard deviation in Hz.

Constraints:
  • gt = 0.0

cmd() str[source]
render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.spectrum.JONSWAP[source]

Jonswap spectral shape.

JONSWAP [gamma]

Examples

In [1]: from rompy.swan.subcomponents.spectrum import JONSWAP

In [2]: shape = JONSWAP(gamma=3.3)

In [3]: print(shape.render())
JONSWAP gamma=3.3
Fields:
field gamma: float = 3.3

Peak enhancement parameter of the JONSWAP spectrum.

Constraints:
  • gt = 0.0

field model_type: Literal['jonswap', 'JONSWAP'] = 'jonswap'

Model type discriminator

cmd() str[source]
render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.spectrum.PM[source]

Pearson-Moskowitz spectral shape.

PM

Examples

In [1]: from rompy.swan.subcomponents.spectrum import PM

In [2]: shape = PM()

In [3]: print(shape.render())
PM
Fields:
field model_type: Literal['pm', 'PM'] = 'pm'

Model type discriminator

cmd() str
render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.spectrum.SHAPESPEC[source]

Spectral shape specification.

BOUND SHAPESPEC JONSWAP|PM|GAUSS|BIN|TMA PEAK|MEAN DSPR [POWER|DEGREES]

This command BOUND SHAPESPEC defines the shape of the spectra (both in frequency and direction) at the boundary of the computational grid in case of parametric spectral input.

Notes

While technically a component BOUND SHAPESPEC, this is only intended to be used as a subcomponent of the BOUNDSPEC component.

Examples

In [1]: from rompy.swan.subcomponents.spectrum import SHAPESPEC

In [2]: shapespec = SHAPESPEC()

In [3]: print(shapespec.render())
BOUND SHAPESPEC JONSWAP gamma=3.3 PEAK DSPR POWER

In [4]: shapespec = SHAPESPEC(
   ...:     shape=dict(model_type="tma", gamma=3.1, d=12),
   ...:     per_type="mean",
   ...:     dspr_type="degrees",
   ...: )
   ...: 

In [5]: print(shapespec.render())
BOUND SHAPESPEC TMA gamma=3.1 d=12.0 MEAN DSPR DEGREES
Fields:
field dspr_type: Literal['power', 'degrees'] = 'power'

The type of directional spreading

field model_type: Literal['shapespec', 'SHAPESPEC'] = 'shapespec'

Model type discriminator

field per_type: Literal['peak', 'mean'] = 'peak'

The type of characteristic wave period

field shape: JONSWAP | PM | GAUSS | BIN | TMA [Optional]

The spectral shape

cmd() str[source]
render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.spectrum.SPECTRUM[source]

SWAN spectrum specification.

->CIRCLE|SECTOR ([dir1] [dir2]) [mdc] [flow] [fhigh] [msc]

Notes

Directions in the spectra are defined either as a CIRCLE or as a SECTOR. In the case of a SECTOR, both dir1 and dir2 must be specified. In the case of a CIRCLE, neither dir1 nor dir2 should be specified.

At least two of flow, fhigh and msc must be specified in which case the third parameter will be calculated by SWAN such that the frequency resolution df/f = 0.1 (10% increments).

Examples

In [1]: from rompy.swan.subcomponents.spectrum import SPECTRUM

In [2]: spec = SPECTRUM(mdc=36, flow=0.04, fhigh=1.0)

In [3]: print(spec.render())
CIRCLE mdc=36 flow=0.04 fhigh=1.0

In [4]: spec = SPECTRUM(mdc=36, dir1=0, dir2=180, flow=0.04, msc=31)

In [5]: print(spec.render())
SECTOR 0.0 180.0 mdc=36 flow=0.04 msc=31
Fields:
Validators:
field dir1: float | None = None

The direction of the right-hand boundary of the sector when looking outward from the sector (required for option SECTOR) in degrees.

Validated by:
field dir2: float | None = None

The direction of the left-hand boundary of the sector when looking outward from the sector (required for option SECTOR) in degrees.

Validated by:
field fhigh: float | None = None

Highest discrete frequency that is used in the calculation (in Hz).

Validated by:
field flow: float | None = None

Lowest discrete frequency that is used in the calculation (in Hz).

Validated by:
field mdc: int [Required]

Number of meshes in theta-space. In the case of CIRCLE, this is the number of subdivisions of the 360 degrees of a circle so dtheta = [360]/[mdc] is the spectral directional resolution. In the case of SECTOR, dtheta = ([dir2] - [dir1])/[mdc]. The minimum number of directional bins is 3 per directional quadrant.

Validated by:
field model_type: Literal['spectrum', 'SPECTRUM'] = 'spectrum'

Model type discriminator

Validated by:
field msc: int | None = None

One less than the number of frequencies. This defines the grid resolution in frequency-space between the lowest discrete frequency flow and the highest discrete frequency fhigh. This resolution is not constant, since the frequencies are distributed logarithmical: fi+1 = yfi where y is a constant. The minimum number of frequencies is 4

Constraints:
  • ge = 3

Validated by:
validator check_direction_definition  »  all fields[source]

Check that dir1 and dir2 are specified together.

validator check_frequency_definition  »  all fields[source]

Check spectral frequencies are prescribed correctly.

cmd() str[source]
render() str

Render the sub-component to a string.

property dir_sector
pydantic model rompy.swan.subcomponents.spectrum.TMA[source]

TMA spectral shape.

TMA [gamma] [d]

Examples

In [1]: from rompy.swan.subcomponents.spectrum import TMA

In [2]: shape = TMA(gamma=2.0, d=18)

In [3]: print(shape.render())
TMA gamma=2.0 d=18.0
Fields:
field d: float [Required]

The reference depth at the wave maker in meters.

Constraints:
  • gt = 0.0

field gamma: float = 3.3

Peak enhancement parameter of the JONSWAP spectrum.

Constraints:
  • gt = 0.0

field model_type: Literal['tma', 'TMA'] = 'tma'

Model type discriminator

cmd() str[source]
render() str

Render the sub-component to a string.

Time#

Time subcomponents.

pydantic model rompy.swan.subcomponents.time.Delt[source]

Time interval specification in SWAN.

[delt] SEC|MIN|HR|DAY

Note

The tdelta field can be specified as:

  • existing timedelta object

  • int or float, assumed as seconds

  • ISO 8601 duration string, following formats work:

    • [-][DD ][HH:MM]SS[.ffffff]

    • [±]P[DD]DT[HH]H[MM]M[SS]S (ISO 8601 format for timedelta)

Examples

In [1]: from rompy.swan.subcomponents.time import Delt

In [2]: from datetime import timedelta

In [3]: delt = Delt(delt=timedelta(minutes=30))

In [4]: print(delt.render())
1800.0 SEC

In [5]: delt = Delt(delt="PT1H", dfmt="hr")

In [6]: print(delt.render())
1.0 HR
Fields:
field delt: timedelta [Required]

Time interval

field dfmt: Literal['sec', 'min', 'hr', 'day'] = 'sec'

Format to render time interval specification

field model_type: Literal['delt', 'Delt', 'DELT'] = 'tdelt'

Model type discriminator

cmd() str[source]

Render subcomponent cmd.

render() str

Render the sub-component to a string.

property delt_float
pydantic model rompy.swan.subcomponents.time.NONSTATIONARY[source]

Nonstationary time specification.

NONSTATIONARY [tbeg] [delt] SEC|MIN|HR|DAY [tend]

Note

Default values for the time specification fields are provided for the case where the user wants to set times dynamically after instantiating this subcomponent.

Examples

In [1]: from rompy.swan.subcomponents.time import NONSTATIONARY

In [2]: nonstat = NONSTATIONARY(
   ...:     tbeg="2012-01-01T00:00:00",
   ...:     tend="2012-02-01T00:00:00",
   ...:     delt="PT1H",
   ...:     dfmt="hr",
   ...: )
   ...: 

In [3]: print(nonstat.render())
NONSTATIONARY tbeg=20120101.000000 delt=1.0 HR tend=20120201.000000

In [4]: from datetime import datetime, timedelta

In [5]: nonstat = NONSTATIONARY(
   ...:     tbeg=datetime(1990, 1, 1),
   ...:     tend=datetime(1990, 1, 7),
   ...:     delt=timedelta(minutes=30),
   ...:     tfmt=1,
   ...:     dfmt="min",
   ...:     suffix="tbl",
   ...: )
   ...: 

In [6]: print(nonstat.render())
NONSTATIONARY tbegtbl=19900101.000000 delttbl=30.0 MIN tendtbl=19900107.000000
Fields:
field delt: timedelta = datetime.timedelta(seconds=3600)

Time interval

field dfmt: Literal['sec', 'min', 'hr', 'day'] = 'sec'

Format to render time interval specification

field model_type: Literal['nonstationary', 'NONSTATIONARY'] = 'nonstationary'

Model type discriminator

field suffix: str = ''

Suffix to prepend to argument names when rendering

field tbeg: datetime = datetime.datetime(1970, 1, 1, 0, 0)

Start time

field tend: datetime = datetime.datetime(1970, 1, 2, 0, 0)

End time

field tfmt: Literal[1, 2, 3, 4, 5, 6] | str = 1

Format to render time specification

cmd() str[source]

Render subcomponent cmd.

render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.time.STATIONARY[source]

Stationary time specification.

STATIONARY [time]

Note

The field time is optional to allow for the case where the user wants to set the time dynamically after instantiating this component.

Examples

In [1]: from rompy.swan.subcomponents.time import STATIONARY

In [2]: stat = STATIONARY(time="2012-01-01T00:00:00")

In [3]: print(stat.render())
STATIONARY time=20120101.000000
Fields:
field model_type: Literal['stationary', 'STATIONARY'] = 'stationary'

Model type discriminator

field tfmt: Literal[1, 2, 3, 4, 5, 6] | str = 1

Format to render time specification

field time: datetime = datetime.datetime(1970, 1, 1, 0, 0)

Stationary time

cmd() str[source]

Render subcomponent cmd.

render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.time.Time[source]

Time specification in SWAN.

[time]

Time is rendered in one of the following formats:

  • 1: ISO-notation 19870530.153000

  • 2: (as in HP compiler) ‘30-May-87 15:30:00’

  • 3: (as in Lahey compiler) 05/30/87.15:30:00

  • 4: 15:30:00

  • 5: 87/05/30 15:30:00’

  • 6: as in WAM 8705301530

Note

The time field can be specified as:

  • existing datetime object

  • int or float, assumed as Unix time, i.e. seconds (if >= -2e10 or <= 2e10) or milliseconds (if < -2e10 or > 2e10) since 1 January 1970.

  • ISO 8601 time string.

Examples

In [1]: from rompy.swan.subcomponents.time import Time

In [2]: from datetime import datetime

In [3]: time = Time(time=datetime(1990, 1, 1))

In [4]: print(time.render())
19900101.000000

In [5]: time = Time(time="2012-01-01T00:00:00", tfmt=2)

In [6]: print(time.render())
'01-Jan-12 00:00:00'
Fields:
Validators:
field model_type: Literal['time', 'Time', 'TIME'] = 'time'

Model type discriminator

field tfmt: Literal[1, 2, 3, 4, 5, 6] | str = 1

Format to render time specification

Validated by:
field time: datetime [Required]

Datetime specification

cmd() str[source]

Render subcomponent cmd.

render() str

Render the sub-component to a string.

validator set_time_format  »  tfmt[source]

Set the time format to render.

pydantic model rompy.swan.subcomponents.time.TimeRangeClosed[source]

Regular times with a closed boundary.

[tbeg] [delt] SEC|MIN|HR|DAY [tend]

Note

Default values for the time specification fields are provided for the case where the user wants to set times dynamically after instantiating this subcomponent.

Examples

In [1]: from rompy.swan.subcomponents.time import TimeRangeClosed

In [2]: from datetime import datetime, timedelta

In [3]: times = TimeRangeClosed(
   ...:     tbeg=datetime(1990, 1, 1),
   ...:     tend=datetime(1990, 1, 7),
   ...:     delt=timedelta(minutes=30),
   ...:     dfmt="min",
   ...: )
   ...: 

In [4]: print(times.render())
tbeg=19900101.000000 delt=30.0 MIN tend=19900107.000000

In [5]: times = TimeRangeClosed(
   ...:     tbeg="2012-01-01T00:00:00",
   ...:     tend="2012-02-01T00:00:00",
   ...:     delt="PT1H",
   ...:     tfmt=2,
   ...:     dfmt="hr",
   ...:     suffix="blk",
   ...: )
   ...: 

In [6]: print(times.render())
tbegblk='01-Jan-12 00:00:00' deltblk=1.0 HR tendblk='01-Feb-12 00:00:00'
Fields:
field delt: timedelta = datetime.timedelta(seconds=3600)

Time interval

field dfmt: Literal['sec', 'min', 'hr', 'day'] = 'sec'

Format to render time interval specification

field model_type: Literal['closed', 'CLOSED'] = 'closed'

Model type discriminator

field suffix: str = ''

Suffix to prepend to argument names when rendering

field tbeg: datetime = datetime.datetime(1970, 1, 1, 0, 0)

Start time

field tend: datetime = datetime.datetime(1970, 1, 2, 0, 0)

End time

field tfmt: Literal[1, 2, 3, 4, 5, 6] | str = 1

Format to render time specification

cmd() str[source]

Render subcomponent cmd.

render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.time.TimeRangeOpen[source]

Regular times with an open boundary.

[tbeg] [delt] SEC|MIN|HR|DAY

Time is rendered in one of the following formats:

  • 1: ISO-notation 19870530.153000

  • 2: (as in HP compiler) ‘30-May-87 15:30:00’

  • 3: (as in Lahey compiler) 05/30/87.15:30:00

  • 4: 15:30:00

  • 5: 87/05/30 15:30:00’

  • 6: as in WAM 8705301530

Note

The tbeg field can be specified as:

  • existing datetime object

  • int or float, assumed as Unix time, i.e. seconds (if >= -2e10 or <= 2e10) or milliseconds (if < -2e10 or > 2e10) since 1 January 1970.

  • ISO 8601 time string.

Note

The tdelta field can be specified as:

  • existing timedelta object

  • int or float, assumed as seconds

  • ISO 8601 duration string, following formats work:

    • [-][DD ][HH:MM]SS[.ffffff]

    • [±]P[DD]DT[HH]H[MM]M[SS]S (ISO 8601 format for timedelta)

Note

Default values for the time specification fields are provided for the case where the user wants to set times dynamically after instantiating this subcomponent.

Examples

In [1]: from rompy.swan.subcomponents.time import TimeRangeOpen

In [2]: from datetime import datetime, timedelta

In [3]: times = TimeRangeOpen(
   ...:     tbeg=datetime(1990, 1, 1), delt=timedelta(minutes=30), dfmt="min"
   ...: )
   ...: 

In [4]: print(times.render())
tbeg=19900101.000000 delt=30.0 MIN

In [5]: times = TimeRangeOpen(
   ...:     tbeg="2012-01-01T00:00:00", delt="PT1H", tfmt=2, dfmt="hr", suffix="blk"
   ...: )
   ...: 

In [6]: print(times.render())
tbegblk='01-Jan-12 00:00:00' deltblk=1.0 HR
Fields:
field delt: timedelta = datetime.timedelta(seconds=3600)

Time interval

field dfmt: Literal['sec', 'min', 'hr', 'day'] = 'sec'

Format to render time interval specification

field model_type: Literal['open', 'OPEN'] = 'open'

Model type discriminator

field suffix: str = ''

Suffix to prepend to argument names when rendering

field tbeg: datetime = datetime.datetime(1970, 1, 1, 0, 0)

Start time

field tfmt: Literal[1, 2, 3, 4, 5, 6] | str = 1

Format to render time specification

cmd() str[source]

Render subcomponent cmd.

render() str

Render the sub-component to a string.

Readgrid#

Readgrid subcomponents.

pydantic model rompy.swan.subcomponents.readgrid.GRIDREGULAR[source]

SWAN Regular Grid subcomponent.

xp yp alp xlen ylen mx my

Note

The direction of the x-axis alp must be 0 in case of spherical coordinates

Note

All coordinates and distances should be given in m when Cartesian coordinates are used or degrees when Spherical coordinates are used (see command COORD).

Examples

In [1]: from rompy.swan.subcomponents.readgrid import GRIDREGULAR

In [2]: kwargs = dict(xp=173, yp=-40, alp=0, xlen=2, ylen=2, mx=199, my=199)

In [3]: grid = GRIDREGULAR(suffix="c", **kwargs)

In [4]: print(grid.render())
xpc=173.0 ypc=-40.0 alpc=0.0 xlenc=2.0 ylenc=2.0 mxc=199 myc=199

In [5]: grid = GRIDREGULAR(suffix="inp", **kwargs)

In [6]: print(grid.render())
xpinp=173.0 ypinp=-40.0 alpinp=0.0 xleninp=2.0 yleninp=2.0 mxinp=199 myinp=199
Fields:
field alp: float | None = 0.0

Direction of the xaxis in degrees

field model_type: Literal['gridregular', 'GRIDREGULAR'] = 'gridregular'

Model type discriminator

field mx: int [Required]

Number of meshes in computational grid in x-direction (this number is one less than the number of grid points in this domain)

field my: int [Required]

Number of meshes in computational grid in y-direction (this number is one less than the number of grid points in this domain)

field suffix: str | None = ''

Suffix for rendering with each output grid parameter.

field xlen: float [Required]

Length of the computational grid in the x-direction

field xp: float [Required]

The x-coordinate of the origin in problem coordinates

field ylen: float [Required]

Length of the computational grid in the y-direction

field yp: float [Required]

The y-coordinate of the origin in problem coordinates

cmd() str[source]

Command file string for this subcomponent.

render() str

Render the sub-component to a string.

property dx

Grid spacing in x-direction.

property dy

Grid spacing in y-direction.

pydantic model rompy.swan.subcomponents.readgrid.READCOORD[source]

SWAN coordinates reader.

READGRID COORDINATES [fac] 'fname' [idla] [nhedf] [nhedvec] &
    FREE|FORMAT ('form'|idfm)

Examples

In [1]: from rompy.swan.subcomponents.readgrid import READCOORD

In [2]: readcoord = READCOORD(
   ...:     fac=1.0,
   ...:     fname="coords.txt",
   ...:     idla=3,
   ...:     format="free",
   ...: )
   ...: 

In [3]: print(readcoord.render())
READGRID COORDINATES fac=1.0 fname='coords.txt' idla=3 nhedf=0 nhedvec=0 FREE
Fields:
Validators:
  • check_format_definition » all fields

field fac: float = 1.0

SWAN multiplies all values that are read from file by fac. For instance if the values are given in unit decimeter, one should make fac=0.1 to obtain values in m. To change sign use a negative fac

Constraints:
  • gt = 0.0

Validated by:
  • check_format_definition

field fname: str [Required]

Name of the SWAN coordinates file

Validated by:
  • check_format_definition

field form: str | None = None

A user-specified format string in Fortran convention, e.g., ‘(10X,12F5.0)’.Only used if format=’fixed’, do not use it if idfm is specified

Validated by:
  • check_format_definition

field format: Literal['free', 'fixed', 'unformatted'] = 'free'

File format, one of ‘free’, ‘fixed’ or ‘unformatted’. If ‘free’, the file is assumed to use the FREE FORTRAN format. If ‘fixed’, the file is assumed to use a fixed format that must be specified by (only) one of ‘form’ or ‘idfm’ arguments. Use ‘unformatted’ to read unformatted (binary) files (not recommended for ordinary use)

Validated by:
  • check_format_definition

field grid_type: Literal['coordinates'] = 'coordinates'

Type of the SWAN grid file

Validated by:
  • check_format_definition

field idfm: Literal[1, 5, 6, 8] | None = None

File format identifier, only used if format=’fixed’

Validated by:
  • check_format_definition

field idla: IDLA = 1

Prescribes the order in which the values of bottom levels and other fields should be given in the file

Validated by:
  • check_format_definition

field model_type: Literal['readcoord', 'READCOORD'] = 'readcoord'

Model type discriminator

Validated by:
  • check_format_definition

field nhedf: int = 0

The number of header lines at the start of the file. The text in the header lines is reproduced in the print file created by SWAN . The file may start with more header lines than nhedf because the start of the file is often also the start of a time step and possibly also of a vector variable (each having header lines, see nhedt and nhedvec)

Constraints:
  • ge = 0

Validated by:
  • check_format_definition

field nhedvec: int = 0

For each vector variable: number of header lines in the file at the start of each component (e.g., x- or y-component)

Constraints:
  • ge = 0

Validated by:
  • check_format_definition

validator check_format_definition  »  all fields

Check the arguments specifying the file format are specified correctly.

cmd() str[source]
render() str

Render the sub-component to a string.

property format_repr
pydantic model rompy.swan.subcomponents.readgrid.READGRID[source]

SWAN grid reader abstract class.

READGRID [grid_type] [fac] 'fname1' [idla] [nhedf] ([nhedt]) ([nhedvec]) &
    ->FREE|FORMAT|UNFORMATTED ('form'|[idfm])

This is the base class for all input grids. It is not meant to be used directly.

Note

File format identifier:

  • 1: Format according to BODKAR convention (a standard of the Ministry of Transport and Public Works in the Netherlands). Format string: (10X,12F5.0)

  • 5: Format (16F5.0), an input line consists of 16 fields of 5 places each

  • 6: Format (12F6.0), an input line consists of 12 fields of 6 places each

  • 8: Format (10F8.0), an input line consists of 10 fields of 8 places each

Fields:
  • fac (float)

  • form (str | None)

  • format (Literal['free', 'fixed', 'unformatted'])

  • grid_type (rompy.swan.types.GridOptions | Literal['coordinates'])

  • idfm (Literal[1, 5, 6, 8] | None)

  • idla (rompy.swan.types.IDLA)

  • model_type (Literal['readgrid', 'READGRID'])

  • nhedf (int)

  • nhedvec (int)

Validators:
  • check_format_definition » all fields

field fac: float = 1.0

SWAN multiplies all values that are read from file by fac. For instance if the values are given in unit decimeter, one should make fac=0.1 to obtain values in m. To change sign use a negative fac

Constraints:
  • gt = 0.0

Validated by:
  • check_format_definition

field form: str | None = None

A user-specified format string in Fortran convention, e.g., ‘(10X,12F5.0)’.Only used if format=’fixed’, do not use it if idfm is specified

Validated by:
  • check_format_definition

field format: Literal['free', 'fixed', 'unformatted'] = 'free'

File format, one of ‘free’, ‘fixed’ or ‘unformatted’. If ‘free’, the file is assumed to use the FREE FORTRAN format. If ‘fixed’, the file is assumed to use a fixed format that must be specified by (only) one of ‘form’ or ‘idfm’ arguments. Use ‘unformatted’ to read unformatted (binary) files (not recommended for ordinary use)

Validated by:
  • check_format_definition

field grid_type: GridOptions | Literal['coordinates'] [Required]

Type of the SWAN grid file

Validated by:
  • check_format_definition

field idfm: Literal[1, 5, 6, 8] | None = None

File format identifier, only used if format=’fixed’

Validated by:
  • check_format_definition

field idla: IDLA = 1

Prescribes the order in which the values of bottom levels and other fields should be given in the file

Validated by:
  • check_format_definition

field model_type: Literal['readgrid', 'READGRID'] = 'readgrid'

Model type discriminator

Validated by:
  • check_format_definition

field nhedf: int = 0

The number of header lines at the start of the file. The text in the header lines is reproduced in the print file created by SWAN . The file may start with more header lines than nhedf because the start of the file is often also the start of a time step and possibly also of a vector variable (each having header lines, see nhedt and nhedvec)

Constraints:
  • ge = 0

Validated by:
  • check_format_definition

field nhedvec: int = 0

For each vector variable: number of header lines in the file at the start of each component (e.g., x- or y-component)

Constraints:
  • ge = 0

Validated by:
  • check_format_definition

validator check_format_definition  »  all fields[source]

Check the arguments specifying the file format are specified correctly.

cmd() str
render() str

Render the sub-component to a string.

property format_repr
pydantic model rompy.swan.subcomponents.readgrid.READINP[source]

SWAN input grid reader.

READINP GRID_TYPE [fac] ('fname1' | SERIES 'fname2') [idla] [nhedf] &
    ([nhedt]) [nhedvec] FREE|FORMAT ('form'|idfm)|UNFORMATTED`

Examples

In [1]: from rompy.swan.subcomponents.readgrid import READINP

In [2]: readinp = READINP(
   ...:     grid_type="wind",
   ...:     fname1="wind.txt",
   ...:     fac=1.0,
   ...:     idla=3,
   ...:     format="free",
   ...: )
   ...: 

In [3]: print(readinp.render())
READINP WIND fac=1.0 fname1='wind.txt' idla=3 nhedf=0 nhedt=0 nhedvec=0 FREE
Fields:
Validators:
field fac: float = 1.0

SWAN multiplies all values that are read from file by fac. For instance if the values are given in unit decimeter, one should make fac=0.1 to obtain values in m. To change sign use a negative fac

Constraints:
  • gt = 0.0

Validated by:
  • check_format_definition

field fname1: str [Required]

Name of the file with the values of the variable.

Validated by:
  • check_format_definition

field fname2: str | None = None

Name of file that contains the names of the files where the variables are given when the SERIES option is used. These names are to be given in proper time sequence. SWAN reads the next file when the previous file end has been encountered. In these files the input should be given in the same format as in the above file ‘fname1’ (that implies that a file should start with the start of an input time step)

Validated by:
  • check_format_definition

field form: str | None = None

A user-specified format string in Fortran convention, e.g., ‘(10X,12F5.0)’.Only used if format=’fixed’, do not use it if idfm is specified

Validated by:
  • check_format_definition

field format: Literal['free', 'fixed', 'unformatted'] = 'free'

File format, one of ‘free’, ‘fixed’ or ‘unformatted’. If ‘free’, the file is assumed to use the FREE FORTRAN format. If ‘fixed’, the file is assumed to use a fixed format that must be specified by (only) one of ‘form’ or ‘idfm’ arguments. Use ‘unformatted’ to read unformatted (binary) files (not recommended for ordinary use)

Validated by:
  • check_format_definition

field grid_type: GridOptions | None = None

Type of the SWAN grid file

Validated by:
field idfm: Literal[1, 5, 6, 8] | None = None

File format identifier, only used if format=’fixed’

Validated by:
  • check_format_definition

field idla: IDLA = 1

Prescribes the order in which the values of bottom levels and other fields should be given in the file

Validated by:
  • check_format_definition

field model_type: Literal['readinp', 'READINP'] = 'readinp'

Model type discriminator

Validated by:
  • check_format_definition

field nhedf: int = 0

The number of header lines at the start of the file. The text in the header lines is reproduced in the print file created by SWAN . The file may start with more header lines than nhedf because the start of the file is often also the start of a time step and possibly also of a vector variable (each having header lines, see nhedt and nhedvec)

Constraints:
  • ge = 0

Validated by:
  • check_format_definition

field nhedt: int = 0

Only if variable is time dependent: number of header lines in the file at the start of each time level. A time step may start with more header lines than nhedt because the variable may be a vector variable which has its own header lines (see nhedvec)

Constraints:
  • ge = 0

Validated by:
  • check_format_definition

field nhedvec: int = 0

For each vector variable: number of header lines in the file at the start of each component (e.g., x- or y-component)

Constraints:
  • ge = 0

Validated by:
  • check_format_definition

validator check_format_definition  »  all fields

Check the arguments specifying the file format are specified correctly.

cmd() str[source]
render() str

Render the sub-component to a string.

validator set_undefined  »  grid_type[source]

Allow for undefined value so it can be redefined in INPGRID components.

property format_repr

Boundary#

SWAN boundary subcomponents.

pydantic model rompy.swan.subcomponents.boundary.CONSTANTFILE[source]

Constant file specification.

CONSTANT FILE 'fname' [seq]

There are three types of files:

  • TPAR files containing nonstationary wave parameters

  • files containing stationary or nonstationary 1D spectra (usually from measurements)

  • files containing stationary or nonstationary 2D spectra (from other computer programs or other SWAN runs)

A TPAR file is for only one location; it has the string TPAR on the first line of the file and a number of lines which each contain 5 numbers, i.e.: Time (ISO-notation), Hs, Period (average or peak period depending on the choice given in command BOUND SHAPE), Peak Direction (Nautical or Cartesian, depending on command SET), Directional spread (in degrees or as power of cos depending on the choice given in command BOUND SHAPE).

Note

Example of a TPAR file:

TPAR
19920516.130000 4.2 12. -110. 22.
19920516.180000 4.2 12. -110. 22.
19920517.000000 1.2 8. -110. 22.
19920517.120000 1.4 8.5 -80. 26
19920517.200000 0.9 6.5 -95. 28

Examples

In [1]: from rompy.swan.subcomponents.boundary import CONSTANTFILE

In [2]: par = CONSTANTFILE(fname="tpar.txt")

In [3]: print(par.render())
CONSTANT FILE fname='tpar.txt'
Fields:
field fname: str [Required]

Name of the file containing the boundary condition.

Constraints:
  • max_length = 36

field model_type: Literal['constantfile', 'CONSTANTFILE'] = 'constantfile'

Model type discriminator

field seq: int | None = None

sequence number of geographic location in the file (see Appendix D); useful for files which contain spectra for more than one location. Note: a TPAR file always contains only one location so in this case seq must always be 1

Constraints:
  • ge = 1

cmd() str[source]

Render subcomponent cmd.

render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.boundary.CONSTANTPAR[source]

Constant spectral parameters.

CONSTANT PAR [hs] [per] [dir] ([dd])

Examples

In [1]: from rompy.swan.subcomponents.boundary import CONSTANTPAR

In [2]: par = CONSTANTPAR(hs=1.5, per=8.1, dir=225)

In [3]: print(par.render())
CONSTANT PAR hs=1.5 per=8.1 dir=225.0
Fields:
field dd: float | None = None

Coefficient of directional spreading; a cos^m(θ) distribution is assumed. dd is interpreted as the directional standard deviation in degrees, if the option DEGREES is chosen in the command BOUND SHAPE (SWAN default: 30). dd is interpreted as the power m, if the option POWER is chosen in the command BOUND SHAPE (SWAN default: 2)

Constraints:
  • ge = 0.0

  • le = 360.0

field dir: float [Required]

The peak wave direction thetapeak (degree), constant over frequencies

Constraints:
  • ge = -360.0

  • le = 360.0

field hs: float [Required]

The significant wave height (m)

Constraints:
  • gt = 0.0

field model_type: Literal['constantpar', 'CONSTANTPAR'] = 'constantpar'

Model type discriminator

field per: float [Required]

The characteristic period (s) of the energy spectrum (relative frequency; which is equal to absolute frequency in the absence of currents); per is the value of the peak period if option PEAK is chosen in command BOUND SHAPE or per is the value of the mean period, if option MEAN was chosen in command BOUND SHAPE.

Constraints:
  • gt = 0.0

cmd() str[source]

Render subcomponent cmd.

render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.boundary.DEFAULT[source]

Default initial conditions.

DEFAULT

The initial spectra are computed from the local wind velocities, using the deep-water growth curve of Kahma and Calkoen (1992), cut off at values of significant wave height and peak frequency from Pierson and Moskowitz (1964). The average (over the model area) spatial step size is used as fetch with local wind. The shape of the spectrum is default JONSWAP with a cos2-directional distribution (options are available: see command BOUND SHAPE).

Examples

In [1]: from rompy.swan.subcomponents.boundary import DEFAULT

In [2]: init = DEFAULT()

In [3]: print(init.render())
DEFAULT
Fields:
field model_type: Literal['default', 'DEFAULT'] = 'default'

Model type discriminator

cmd() str
render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.boundary.HOTMULTIPLE[source]

Hotstart multiple initial conditions.

HOTSTART MULTIPLE fname='fname' FREE|UNFORMATTED

Initial wave field is read from file; this file was generated in a previous SWAN run by means of the HOTFILE command. If the previous run was nonstationary, the time found on the file will be assumed to be the initial time of computation. It can also be used for stationary computation as first guess. The computational grid (both in geographical space and in spectral space) must be identical to the one in the run in which the initial wave field was computed

Input will be read from multiple hotfiles obtained from a previous parallel MPI run. The number of files equals the number of processors. Hence, for the present run the same number of processors must be chosen.

Examples

In [1]: from rompy.swan.subcomponents.boundary import HOTMULTIPLE

In [2]: init = HOTMULTIPLE(fname="hotstart.swn", format="free")

In [3]: print(init.render())
HOTSTART MULTIPLE fname='hotstart.swn' FREE
Fields:
field fname: str [Required]

Name of the file containing the initial wave field

Constraints:
  • max_length = 36

field format: Literal['free', 'unformatted'] = 'free'

Format of the file containing the initial wave field. FREE: free format, UNFORMATTED: binary format

field model_type: Literal['hotmultiple', 'HOTMULTIPLE'] = 'hotmultiple'

Model type discriminator

cmd() str[source]

Render subcomponent cmd.

render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.boundary.HOTSINGLE[source]

Hotstart single initial conditions.

HOTSTART SINGLE fname='fname' FREE|UNFORMATTED

Initial wave field is read from file; this file was generated in a previous SWAN run by means of the HOTFILE command. If the previous run was nonstationary, the time found on the file will be assumed to be the initial time of computation. It can also be used for stationary computation as first guess. The computational grid (both in geographical space and in spectral space) must be identical to the one in the run in which the initial wave field was computed

Input will be read from a single (concatenated) hotfile. In the case of a previous parallel MPI run, the concatenated hotfile can be created from a set of multiple hotfiles using the program hcat.exe, see Implementation Manual.

Examples

In [1]: from rompy.swan.subcomponents.boundary import HOTSINGLE

In [2]: init = HOTSINGLE(fname="hotstart.swn", format="free")

In [3]: print(init.render())
HOTSTART SINGLE fname='hotstart.swn' FREE
Fields:
field fname: str [Required]

Name of the file containing the initial wave field

Constraints:
  • max_length = 36

field format: Literal['free', 'unformatted'] = 'free'

Format of the file containing the initial wave field. FREE: free format, UNFORMATTED: binary format

field model_type: Literal['hotsingle', 'HOTSINGLE'] = 'hotsingle'

Model type discriminator

cmd() str[source]

Render subcomponent cmd.

render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.boundary.PAR[source]

Spectral parameters.

PAR [hs] [per] [dir] [dd]

Examples

In [1]: from rompy.swan.subcomponents.boundary import PAR

In [2]: par = PAR(hs=1.5, per=8.1, dir=225)

In [3]: print(par.render())
PAR hs=1.5 per=8.1 dir=225.0
Fields:
field dd: float | None = None

Coefficient of directional spreading; a cos^m(θ) distribution is assumed. dd is interpreted as the directional standard deviation in degrees, if the option DEGREES is chosen in the command BOUND SHAPE (SWAN default: 30). dd is interpreted as the power m, if the option POWER is chosen in the command BOUND SHAPE (SWAN default: 2)

Constraints:
  • ge = 0.0

  • le = 360.0

field dir: float [Required]

The peak wave direction thetapeak (degree), constant over frequencies

Constraints:
  • ge = -360.0

  • le = 360.0

field hs: float [Required]

The significant wave height (m)

Constraints:
  • gt = 0.0

field model_type: Literal['par'] = 'par'

Model type discriminator

field per: float [Required]

The characteristic period (s) of the energy spectrum (relative frequency; which is equal to absolute frequency in the absence of currents); per is the value of the peak period if option PEAK is chosen in command BOUND SHAPE or per is the value of the mean period, if option MEAN was chosen in command BOUND SHAPE.

Constraints:
  • gt = 0.0

cmd() str[source]

Render subcomponent cmd.

render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.boundary.SEGMENT[source]

Boundary over a segment defined from points.

SEGMENT XY < [x] [y] >
SEGMENT IJ < [i] [j] >

The segment is defined either by means of a series of points in terms of problem coordinates (XY) or by means of a series of points in terms of grid indices (IJ). The points do not have to include all or coincide with actual grid points.

Examples

In [1]: from rompy.swan.subcomponents.boundary import SEGMENT

In [2]: seg = SEGMENT(
   ...:     points=dict(
   ...:         model_type="xy",
   ...:         x=[172, 172, 172, 172.5, 173],
   ...:         y=[-41, -40.5, -40, -40, -40],
   ...:         fmt="0.2f",
   ...:     ),
   ...: )
   ...: 

In [3]: print(seg.render())
SEGMENT XY 
172.00 -41.00
172.00 -40.50
172.00 -40.00
172.50 -40.00
173.00 -40.00


In [4]: seg = SEGMENT(
   ...:     points=dict(
   ...:         model_type="ij",
   ...:         i=[0, 0, 5],
   ...:         j=[0, 19, 19],
   ...:     ),
   ...: )
   ...: 

In [5]: print(seg.render())
SEGMENT IJ 
i=0 j=0
i=0 j=19
i=5 j=19
Fields:
field model_type: Literal['segment', 'SEGMENT'] = 'segment'

Model type discriminator

field points: XY | IJ [Required]

Points to define the segment

cmd() str[source]
render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.boundary.SIDE[source]

Boundary over one side of computational domain.

SIDE NORTH|NW|WEST|SW|SOUTH|SE|E|NE CCW|CLOCKWISE

The boundary is one full side of the computational grid (in 1D cases either of the two ends of the 1D-grid).

Note

Should not be used in case of CURVILINEAR grids.

Examples

In [1]: from rompy.swan.subcomponents.boundary import SIDE

In [2]: side = SIDE(side="west", direction="ccw")

In [3]: print(side.render())
SIDE WEST CCW 
Fields:
field direction: Literal['ccw', 'clockwise'] = 'ccw'

The direction to apply the boundary in

field model_type: Literal['side', 'SIDE'] = 'side'

Model type discriminator

field side: Literal['north', 'nw', 'west', 'sw', 'south', 'se', 'east', 'ne'] [Required]

The side of the grid to apply the boundary to

cmd() str[source]
render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.boundary.SIDES[source]

Boundary over multiple side of computational domain.

SIDE NORTH|NW|WEST|SW|SOUTH|SE|E|NE CCW|CLOCKWISE
SIDE NORTH|NW|WEST|SW|SOUTH|SE|E|NE CCW|CLOCKWISE
...

Note

Should not be used in case of CURVILINEAR grids.

Examples

In [1]: from rompy.swan.subcomponents.boundary import SIDE, SIDES

In [2]: side1 = SIDE(side="west", direction="ccw")

In [3]: side2 = SIDE(side="north", direction="ccw")

In [4]: sides = SIDES(sides=[side1, side2])

In [5]: print(sides.render())
['S', 'I', 'D', 'E', ' ', 'W', 'E', 'S', 'T', ' ', 'C', 'C', 'W', ' ', 'S', 'I', 'D', 'E', ' ', 'N', 'O', 'R', 'T', 'H', ' ', 'C', 'C', 'W', ' ']
Fields:
  • model_type (Literal['sides', 'SIDES'])

  • sides (list[rompy.swan.subcomponents.boundary.SIDE])

field model_type: Literal['sides', 'SIDES'] = 'sides'

Model type discriminator

field sides: list[SIDE] [Required]

The sides of the grid to apply the boundary to

cmd() str[source]
render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.boundary.VARIABLEFILE[source]

Variable file specification.

VARIABLE FILE < [len] 'fname' [seq] >

There are three types of files:

  • TPAR files containing nonstationary wave parameters

  • files containing stationary or nonstationary 1D spectra (usually from measurements)

  • files containing stationary or nonstationary 2D spectra (from other computer programs or other SWAN runs)

A TPAR file is for only one location; it has the string TPAR on the first line of the file and a number of lines which each contain 5 numbers, i.e.: Time (ISO-notation), Hs, Period (average or peak period depending on the choice given in command BOUND SHAPE), Peak Direction (Nautical or Cartesian, depending on command SET), Directional spread (in degrees or as power of cos depending on the choice given in command BOUND SHAPE).

Note

Example of a TPAR file:

TPAR
19920516.130000 4.2 12. -110. 22.
19920516.180000 4.2 12. -110. 22.
19920517.000000 1.2 8. -110. 22.
19920517.120000 1.4 8.5 -80. 26
19920517.200000 0.9 6.5 -95. 28

Examples

In [1]: from rompy.swan.subcomponents.boundary import VARIABLEFILE

In [2]: par = VARIABLEFILE(
   ...:     fname=["tpar1.txt", "tpar2.txt", "tpar3.txt"],
   ...:     len=[0.0, 0.5, 1.0],
   ...: )
   ...: 

In [3]: print(par.render())
VARIABLE FILE &
	len=0.0 fname='tpar1.txt' seq=1 &
	len=0.5 fname='tpar2.txt' seq=1 &
	len=1.0 fname='tpar3.txt' seq=1
Fields:
Validators:
field dist: list[float] [Required] (alias 'len')

Is the distance from the first point of the side or segment to the point along the side or segment for which the incident wave spectrum is prescribed. Note: these points do no have to coincide with grid points of the computational grid. [len] is the distance in m or degrees in the case of spherical coordinates, not in grid steps. The values of len should be given in ascending order. The length along a SIDE is measured in clockwise or counterclockwise direction, depending on the options CCW or CLOCKWISE (see above). The option CCW is default. In case of a SEGMENT the length is measured from the indicated begin point of the segment.

Validated by:
field fname: list[str] [Required]

Names of the files containing the boundary condition

Validated by:
field model_type: Literal['variablefile', 'VARIABLEFILE'] = 'variablefile'

Model type discriminator

Validated by:
field seq: list[int] | None = None

sequence number of geographic location in the file (see Appendix D); useful for files which contain spectra for more than one location. Note: a TPAR file always contains only one location so in this case [seq] must always be 1.

Validated by:
cmd() str[source]

Render subcomponent cmd.

validator ensure_equal_size  »  all fields[source]
render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.boundary.VARIABLEPAR[source]

Variable spectral parameter.

VARIABLE PAR < [len] [hs] [per] [dir] [dd] >

Examples

In [1]: from rompy.swan.subcomponents.boundary import VARIABLEPAR

In [2]: par = VARIABLEPAR(
   ...:     hs=[1.5, 1.4, 1.1],
   ...:     per=[8.1, 8.0, 8.1],
   ...:     dir=[225, 226, 228],
   ...:     dd=[25, 22, 23],
   ...:     len=[0, 0.5, 1.0],
   ...: )
   ...: 

In [3]: print(par.render())
VARIABLE PAR &
	len=0.0 hs=1.5 per=8.1 dir=225.0 dd=25.0 &
	len=0.5 hs=1.4 per=8.0 dir=226.0 dd=22.0 &
	len=1.0 hs=1.1 per=8.1 dir=228.0 dd=23.0
Fields:
Validators:
field dd: list[float] [Required]

Coefficient of directional spreading; a $cos^m(θ)$ distribution is assumed. dd is interpreted as the directional standard deviation in degrees, if the option DEGREES is chosen in the command BOUND SHAPE (SWAN default: 30). dd is interpreted as the power m, if the option POWER is chosen in the command BOUND SHAPE (SWAN default: 2)

Validated by:
field dir: list[float] [Required]

The peak wave direction thetapeak (degrees), constant over frequencies

Validated by:
field dist: list[float] [Required] (alias 'len')

Is the distance from the first point of the side or segment to the point along the side or segment for which the incident wave spectrum is prescribed. Note: these points do no have to coincide with grid points of the computational grid. len is the distance in m or degrees in the case of spherical coordinates, not in grid steps. The values of len should be given in ascending order. The length along a SIDE is measured in clockwise or counterclockwise direction, depending on the options CCW or CLOCKWISE (see above). The option CCW is default. In case of a SEGMENT the length is measured from the indicated begin point of the segment

Validated by:
field hs: list[float] [Required]

The significant wave height (m)

Validated by:
field model_type: Literal['variablepar', 'VARIABLEPAR'] = 'variablepar'

Model type discriminator

Validated by:
field per: list[float] [Required]

The characteristic period (s) of the energy spectrum (relative frequency; which is equal to absolute frequency in the absence of currents); per is the value of the peak period if option PEAK is chosen in command BOUND SHAPE or per is the value of the mean period, if option MEAN was chosen in command BOUND SHAPE

Validated by:
cmd() str[source]

Render subcomponent cmd.

validator ensure_equal_size  »  all fields[source]
render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.boundary.ZERO[source]

Zero initial conditions.

ZERO

The initial spectral densities are all 0; note that if waves are generated in the model only by wind, waves can become non-zero only by the presence of the ”A” term in the growth model; see the keyword AGROW in command GEN3.

Examples

In [1]: from rompy.swan.subcomponents.boundary import ZERO

In [2]: init = ZERO()

In [3]: print(init.render())
ZERO
Fields:
field model_type: Literal['zero', 'ZERO'] = 'zero'

Model type discriminator

cmd() str
render() str

Render the sub-component to a string.

Physics#

SWAN physics subcomponents.

pydantic model rompy.swan.subcomponents.physics.DANGREMOND[source]

DAM transmission of d’Angremond et al. (1996).

DAM DANGREMOND [hgt] [slope] [Bk]

This option specifies transmission coefficients dependent on the incident wave conditions at the obstacle and on the obstacle height (which may be submerged).

References

d’Angremond, K., Van Der Meer, J.W. and De Jong, R.J., 1996. Wave transmission at low-crested structures. In Coastal Engineering 1996 (pp. 2418-2427).

Examples

In [1]: from rompy.swan.subcomponents.physics import DANGREMOND

In [2]: transm = DANGREMOND(hgt=3.0, slope=60, Bk=10.0)

In [3]: print(transm.render())
DAM DANGREMOND hgt=3.0 slope=60.0 Bk=10.0
Fields:
field Bk: float [Required]

The crest width of the obstacle

field hgt: float [Required]

The elevation of the top of the obstacle above reference level (same reference level as for bottom etc.); use a negative value if the top is below that reference level

field model_type: Literal['dangremond', 'DANGREMOND'] = 'dangremond'

Model type discriminator

field slope: float [Required]

The slope of the obstacle (in degrees)

Constraints:
  • ge = 0.0

  • le = 90.0

cmd() str[source]

Command file string for this subcomponent.

render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.physics.DEWIT[source]

Biphase of De Wit (2022).

BIPHASE DEWIT [lpar]

Biphase parameterization based on bed slope and peak period of De Wit (2022).

References

De Wit, F.P., 2022. Wave shape prediction in complex coastal systems (Doctoral dissertation, PhD. thesis. Delft University of Technology. https://repository. tudelft. nl/islandora/object/uuid% 3A0fb850a4-4294-4181-9d74-857de21265c2).

Examples

In [1]: from rompy.swan.subcomponents.physics import DEWIT

In [2]: biphase = DEWIT()

In [3]: print(biphase.render())
BIPHASE DEWIT

In [4]: biphase = DEWIT(lpar=0.0)

In [5]: print(biphase.render())
BIPHASE DEWIT lpar=0.0
Fields:
field lpar: float | None = None

Scales spatial averaging of the De Wit’s biphase in terms of a multiple of peak wave length of the incident wave field. Note: lpar = 0` means no averaging (SWAN default: 0)

field model_type: Literal['dewit'] = 'dewit'

Model type discriminator

cmd() str[source]
render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.physics.ELDEBERKY[source]

Biphase of Eldeberky (1999).

BIPHASE ELDEBERKY [urcrit]

Biphase parameterisation as a funtion of the Ursell number of Eldeberky (1999).

References

Eldeberky, Y., Polnikov, V. and Battjes, J.A., 1996. A statistical approach for modeling triad interactions in dispersive waves. In Coastal Engineering 1996 (pp. 1088-1101).

Eldeberky, Y. and Madsen, P.A., 1999. Deterministic and stochastic evolution equations for fully dispersive and weakly nonlinear waves. Coastal Engineering, 38(1), pp.1-24.

Doering, J.C. and Bowen, A.J., 1995. Parametrization of orbital velocity asymmetries of shoaling and breaking waves using bispectral analysis. Coastal engineering, 26(1-2), pp.15-33.

Examples

In [1]: from rompy.swan.subcomponents.physics import ELDEBERKY

In [2]: biphase = ELDEBERKY()

In [3]: print(biphase.render())
BIPHASE ELDEBERKY

In [4]: biphase = ELDEBERKY(urcrit=0.63)

In [5]: print(biphase.render())
BIPHASE ELDEBERKY urcrit=0.63
Fields:
field model_type: Literal['eldeberky'] = 'eldeberky'

Model type discriminator

field urcrit: float | None = None

The critical Ursell number appearing in the parametrization. Note: the value of urcrit is setted by Eldeberky (1996) at 0.2 based on a laboratory experiment, whereas Doering and Bowen (1995) employed the value of 0.63 based on the field experiment data (SWAN default: 0.63)

cmd() str[source]
render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.physics.FREEBOARD[source]

Freeboard dependent transmission and reflection.

FREEBOARD [hgt] [gammat] [gammar] [QUAY]

With this option the user indicates that the fixed transmission trcoef and reflection reflc coefficients are freeboard dependent. The freeboard dependency has no effect on the transmission coefficient as computed using the DAM option.

Notes

See the Scientific/Technical documentation for background information on the gammat and gammar shape parameters.

Examples

In [1]: from rompy.swan.subcomponents.physics import FREEBOARD

In [2]: freeboard = FREEBOARD(hgt=2.0)

In [3]: print(freeboard.render())
FREEBOARD hgt=2.0

In [4]: freeboard = FREEBOARD(hgt=2.0, gammat=1.0, gammar=1.0, quay=True)

In [5]: print(freeboard.render())
FREEBOARD hgt=2.0 gammat=1.0 gammar=1.0 QUAY
Fields:
field gammar: float | None = None

Shape parameter of relative freeboard dependency of reflection coefficient. This parameter should be higher than zero (SWAN default 1.0)

Constraints:
  • gt = 0.0

field gammat: float | None = None

Shape parameter of relative freeboard dependency of transmission coefficient. This parameter should be higher than zero (SWAN default 1.0)

Constraints:
  • gt = 0.0

field hgt: float [Required]

The elevation of the top of the obstacle or height of the quay above the reference level (same reference level as for the bottom). Use a negative value if the top is below that reference level. In case hgt is also specified in the DAM option, both values of hgt should be equal for consistency

field model_type: Literal['freeboard', 'FREEBOARD'] = 'freeboard'

Model type discriminator

field quay: bool = False

With this option the user indicates that the freeboard dependency of the transmission and reflection coefficients also depends on the relative position of an obstacle-linked grid point with respect to the position of the obstacle line representing the edge of a quay. In case the active grid point is on the deeper side of the obstacle, then the correction factors are applied using the parameters hgt, gammat and gammar.In case the active grid point is on the shallower side of the obstacle, the reflection coefficient is set to 0 and the transmission coefficient to 1.

cmd() str[source]

Command file string for this subcomponent.

render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.physics.GODA[source]

DAM transmission of Goda/Seelig (1979).

DAM GODA [hgt] [alpha] [beta]

This option specified transmission coefficients dependent on the incident wave conditions at the obstacle and on the obstacle height (which may be submerged).

References

Goda, Y. and Suzuki, Y., 1976. Estimation of incident and reflected waves in random wave experiments. In Coastal Engineering 1976 (pp. 828-845).

Seelig, W.N., 1979. Effects of breakwaters on waves: Laboratory test of wave transmission by overtopping. In Proc. Conf. Coastal Structures, 1979 (Vol. 79, No. 2, pp. 941-961).

Examples

In [1]: from rompy.swan.subcomponents.physics import GODA

In [2]: transm = GODA(hgt=3.0)

In [3]: print(transm.render())
DAM GODA hgt=3.0

In [4]: transm = GODA(hgt=3.0, alpha=2.6, beta=0.15)

In [5]: print(transm.render())
DAM GODA hgt=3.0 alpha=2.6 beta=0.15
Fields:
field alpha: float | None = None

coefficient determining the transmission coefficient for Goda’s transmission formula (SWAN default: 2.6)

field beta: float | None = None

Another coefficient determining the transmission coefficient for Goda’s transmission formula (SWAN default: 0.15)

field hgt: float [Required]

The elevation of the top of the obstacle above reference level (same reference level as for bottom etc.); use a negative value if the top is below that reference level

field model_type: Literal['goda', 'GODA'] = 'goda'

Model type discriminator

cmd() str[source]

Command file string for this subcomponent.

render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.physics.JANSSEN[source]

Janssen source terms subcomponent.

JANSSEN [cds1] [delta] (AGROW [a])

References

Janssen, P.A., 1989. Wave-induced stress and the drag of air flow over sea waves. Journal of Physical Oceanography, 19(6), pp.745-754.

Janssen, P.A.E.M., Lionello, P. and Zambresky, L., 1989. On the interaction of wind and waves. Philosophical transactions of the royal society of London. Series A, Mathematical and Physical Sciences, 329(1604), pp.289-301.

Janssen, P.A., 1991. Quasi-linear theory of wind-wave generation applied to wave forecasting. Journal of physical oceanography, 21(11), pp.1631-1642.

Examples

In [1]: from rompy.swan.subcomponents.physics import JANSSEN

In [2]: janssen = JANSSEN()

In [3]: print(janssen.render())
JANSSEN DRAG WU

In [4]: janssen = JANSSEN(cds1=4.5, delta=0.5, agrow=True)

In [5]: print(janssen.render())
JANSSEN cds1=4.5 delta=0.5 DRAG WU AGROW
Fields:
field a: float | None = None

Proportionality coefficient when activating the Cavaleri and Malanotte (1981) wave growth term (SWAN default: 0.0015)

field agrow: bool = False

Activate the Cavaleri and Malanotte (1981) wave growth term

field cds1: float | None = None

Coefficient for determining the rate of whitecapping dissipation ($Cds / s^4_{PM}$) (SWAN default: 4.5)

field delta: float | None = None

Coefficient which determines the dependency of the whitecapping on wave number (mix with Komen et al. formulation) (SWAN default: 0.5)

field model_type: Literal['janssen', 'JANSSEN'] = 'janssen'

Model type discriminator

field wind_drag: Literal['wu', 'fit'] = 'wu'

Indicates the wind drag formulation

cmd() str[source]
render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.physics.KOMEN[source]

Komen source terms subcomponent.

KOMEN [cds2] [stpm] (AGROW [a])

References

Komen, G.J., Hasselmann, S. and Hasselmann, K., 1984. On the existence of a fully developed wind-sea spectrum. Journal of physical oceanography, 14(8), pp.1271-1285.

Examples

In [1]: from rompy.swan.subcomponents.physics import KOMEN

In [2]: komen = KOMEN()

In [3]: print(komen.render())
KOMEN DRAG WU

In [4]: komen = KOMEN(cds2=2.36e-5, stpm=3.02e-3, agrow=True, a=0.0015)

In [5]: print(komen.render())
KOMEN cds2=2.36e-05 stpm=0.00302 DRAG WU AGROW a=0.0015
Fields:
field a: float | None = None

Proportionality coefficient when activating the Cavaleri and Malanotte (1981) wave growth term (SWAN default: 0.0015)

field agrow: bool = False

Activate the Cavaleri and Malanotte (1981) wave growth term

field cds2: float | None = None

Coefficient for determining the rate of whitecapping dissipation (Cds) (SWAN default: 2.36e-5)

field model_type: Literal['komen', 'KOMEN'] = 'komen'

Model type discriminator

field stpm: float | None = None

Value of the wave steepness for a Pierson-Moskowitz spectrum (s^2_PM) (SWAN default: 3.02e-3)

field wind_drag: Literal['wu', 'fit'] = 'wu'

Indicates the wind drag formulation

cmd() str[source]
render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.physics.LINE[source]

Line of points to define obstacle location.

LINE < [xp] [yp] >

With this option the user indicates that the fixed transmission trcoef and reflection reflc coefficients are freeboard dependent. The freeboard dependency has no effect on the transmission coefficient as computed using the DAM option.

Notes

Points coordinates should be provided in m If Cartesian coordinates are used or in degrees if spherical coordinates are used (see command COORD). At least two corner points must be provided.

Examples

In [1]: from rompy.swan.subcomponents.physics import LINE

In [2]: line = LINE(xp=[174.1, 174.2, 174.3], yp=[-39.1, -39.1, -39.1])

In [3]: print(line.render())
LINE 174.1 -39.1 174.2 -39.1 174.3 -39.1
Fields:
Validators:
field model_type: Literal['line', 'LINE'] = 'line'

Model type discriminator

Validated by:
field xp: list[float] [Required]

The x-coordinates of the points defining the line

Constraints:
  • min_length = 2

Validated by:
field yp: list[float] [Required]

The y-coordinates of the points defining the line

Constraints:
  • min_length = 2

Validated by:
validator check_length  »  all fields[source]

Check that the length of xp and yp are the same.

cmd() str[source]

Command file string for this subcomponent.

render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.physics.RDIFF[source]

Diffuse reflection.

RDIFF [pown]

Specular reflection where incident waves are scattered over reflected direction.

Examples

In [1]: from rompy.swan.subcomponents.physics import RDIFF

In [2]: refl = RDIFF()

In [3]: print(refl.render())
RDIFF

In [4]: refl = RDIFF(pown=1.0)

In [5]: print(refl.render())
RDIFF pown=1.0
Fields:
field model_type: Literal['rdiff', 'RDIFF'] = 'rdiff'

Model type discriminator

field pown: float | None = None

Each incoming direction θ is scattered over reflected direction θ_refl according to cos^pown(θ-θ_refl). The parameter pown indicates the widthof the redistribution function (SWAN default: 1.0)

cmd() str[source]

Command file string for this subcomponent.

render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.physics.REFL[source]

Obstacle reflections.

REFL [reflc]

Examples

In [1]: from rompy.swan.subcomponents.physics import REFL

In [2]: refl = REFL()

In [3]: print(refl.render())
REFL

In [4]: refl = REFL(reflc=0.5)

In [5]: print(refl.render())
REFL reflc=0.5
Fields:
field model_type: Literal['refl', 'REFL'] = 'refl'

Model type discriminator

field reflc: float | None = None

Constant reflection coefficient (ratio of reflected over incoming significant wave height) (SWAN default: 1.0)

cmd() str[source]

Command file string for this subcomponent.

render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.physics.RSPEC[source]

Specular reflection.

RSPEC

Examples

In [1]: from rompy.swan.subcomponents.physics import RSPEC

In [2]: refl = RSPEC()

In [3]: print(refl.render())
RSPEC
Fields:
field model_type: Literal['rspec', 'RSPEC'] = 'rspec'

Model type discriminator

cmd() str[source]

Command file string for this subcomponent.

render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.physics.ST6[source]

St6 source terms subcomponent.

ST6 [a1sds] [a2sds] [p1sds] [p2sds] UP|DOWN HWANG|FAN|ECMWF VECTAU|SCATAU &
    TRUE10|U10PROXY [windscaling] DEBIAS [cdfac] (AGROW [a])

wind input and whitecapping from Rogers et al. (2012) (RBW12).

Notes

The two arguments are specified in the Appendix C of the User manual but not in the command description for WESTH in Section 4.5.4. They are also options in the WCAPPING command. It is not entirely clear if they should/could be specified here.

References

Fan, Y., Lin, S.J., Held, I.M., Yu, Z. and Tolman, H.L., 2012. Global ocean surface wave simulation using a coupled atmosphere–wave model. Journal of Climate, 25(18), pp.6233-6252.

Rogers, W.E., Babanin, A.V. and Wang, D.W., 2012. Observation-consistent input and whitecapping dissipation in a model for wind-generated surface waves: Description and simple calculations. Journal of Atmospheric and Oceanic Technology, 29(9), pp.1329-1346.

Examples

In [1]: from rompy.swan.subcomponents.physics import ST6

In [2]: st6 = ST6(a1sds=4.7e-7, a2sds=6.6e-6)

In [3]: print(st6.render())
ST6 a1sds=4.7e-07 a2sds=6.6e-06 UP HWANG VECTAU U10PROXY windscaling=32.0

In [4]: kwargs = dict(
   ...:     a1sds=2.8e-6,
   ...:     a2sds=3.5e-5,
   ...:     normalization="up",
   ...:     wind_drag="hwang",
   ...:     tau="vectau",
   ...:     u10="u10proxy",
   ...:     windscaling=32.0,
   ...:     cdfac=0.89,
   ...:     agrow=True,
   ...:     a=0.0015,
   ...: )
   ...: 

In [5]: st6 = ST6(**kwargs)

In [6]: print(st6.render())
ST6 a1sds=2.8e-06 a2sds=3.5e-05 UP HWANG VECTAU U10PROXY windscaling=32.0 DEBIAS cdfac=0.89 AGROW a=0.0015
Fields:
Validators:
field a: float | None = None

Proportionality coefficient when activating the Cavaleri and Malanotte (1981) wave growth term (SWAN default: 0.0015)

Validated by:
field a1sds: float [Required]

Coefficient related to local dissipation term T1 (a1 in RBW12)

Validated by:
field a2sds: float [Required]

Coefficient related to local dissipation term T2 (a2 in RBW12)

Validated by:
field agrow: bool = False

Activate the Cavaleri and Malanotte (1981) wave growth term

Validated by:
field cdfac: float | None = None

Counter bias in the input wind fields by providing a multiplier on the drag coefficient

Constraints:
  • gt = 0.0

Validated by:
field model_type: Literal['st6'] = 'st6'

Model type discriminator

Validated by:
field normalization: Literal['up', 'down'] = 'up'

Selection of normalization of exceedance level by ET(f) (up) or E(f) (down) as in RBW12 (right column, page 1333), up is default and strongly recommended

Validated by:
field p1sds: float | None = None

Power coefficient controlling strength of dissipation term T1 (L in RBW12, SWAN default: 4)

Validated by:
field p2sds: float | None = None

Power coefficient controlling strength of dissipation term T2 (M in RBW12, SWAN default: 4)

Validated by:
field tau: Literal['vectau', 'scatau'] = 'vectau'

Use vector (vectau) or scalar (scatau) calculation for the wind strerss (Eq. 12 in RBW12), vectau is the default and strongly recommended

Validated by:
field u10: Literal['u10proxy', 'true10'] = 'u10proxy'

Wind velocity definition

Validated by:
field wind_drag: Literal['hwang', 'fan', 'ecmwf'] = 'hwang'

Wind drag formula, hwang is the default and is unchanged from RBW12, fan is from Fan et al. (2012), ecmwf follows WAM Cycle 4 methodology

Validated by:
field windscaling: float | None = 32.0

Factor to scale U10 with U* when using U10PROXY

Validated by:
cmd() str[source]
validator debias_only_with_hwang  »  all fields[source]
render() str

Render the sub-component to a string.

property u10_cmd: str
pydantic model rompy.swan.subcomponents.physics.ST6C1[source]

First ST6 calibration in the SWAN user manual.

ST6 4.7e-7 6.6e-6 4.0 4.0 UP HWANG VECTAU U10PROXY 28.0 AGROW

Examples

In [1]: from rompy.swan.subcomponents.physics import ST6C1

In [2]: st6 = ST6C1()

In [3]: print(st6.render())
ST6 a1sds=4.7e-07 a2sds=6.6e-06 p1sds=4.0 p2sds=4.0 UP HWANG VECTAU U10PROXY windscaling=28.0 AGROW
Fields:
Validators:
  • debias_only_with_hwang » all fields

field a: float | None = None

Proportionality coefficient when activating the Cavaleri and Malanotte (1981) wave growth term (SWAN default: 0.0015)

Validated by:
  • debias_only_with_hwang

field a1sds: Literal[4.7e-07] = 4.7e-07
Validated by:
  • debias_only_with_hwang

field a2sds: Literal[6.6e-06] = 6.6e-06
Validated by:
  • debias_only_with_hwang

field agrow: Literal[True] = True
Validated by:
  • debias_only_with_hwang

field cdfac: float | None = None

Counter bias in the input wind fields by providing a multiplier on the drag coefficient

Constraints:
  • gt = 0.0

Validated by:
  • debias_only_with_hwang

field model_type: Literal['st6c1'] = 'st6c1'
Validated by:
  • debias_only_with_hwang

field normalization: Literal['up', 'down'] = 'up'

Selection of normalization of exceedance level by ET(f) (up) or E(f) (down) as in RBW12 (right column, page 1333), up is default and strongly recommended

Validated by:
  • debias_only_with_hwang

field p1sds: Literal[4.0] = 4.0
Validated by:
  • debias_only_with_hwang

field p2sds: Literal[4.0] = 4.0
Validated by:
  • debias_only_with_hwang

field tau: Literal['vectau', 'scatau'] = 'vectau'

Use vector (vectau) or scalar (scatau) calculation for the wind strerss (Eq. 12 in RBW12), vectau is the default and strongly recommended

Validated by:
  • debias_only_with_hwang

field u10: Literal['u10proxy', 'true10'] = 'u10proxy'

Wind velocity definition

Validated by:
  • debias_only_with_hwang

field wind_drag: Literal['hwang', 'fan', 'ecmwf'] = 'hwang'

Wind drag formula, hwang is the default and is unchanged from RBW12, fan is from Fan et al. (2012), ecmwf follows WAM Cycle 4 methodology

Validated by:
  • debias_only_with_hwang

field windscaling: Literal[28.0] = 28.0
Validated by:
  • debias_only_with_hwang

cmd() str
validator debias_only_with_hwang  »  all fields
render() str

Render the sub-component to a string.

property u10_cmd: str
pydantic model rompy.swan.subcomponents.physics.ST6C2[source]

Second ST6 calibration in the SWAN user manual.

ST6 4.7e-7 6.6e-6 4.0 4.0 UP FAN VECTAU U10PROXY 28.0 AGROW

Examples

In [1]: from rompy.swan.subcomponents.physics import ST6C2

In [2]: st6 = ST6C2()

In [3]: print(st6.render())
ST6 a1sds=4.7e-07 a2sds=6.6e-06 p1sds=4.0 p2sds=4.0 UP FAN VECTAU U10PROXY windscaling=28.0 AGROW

TODO: Ensure validator is reused here so fan and debias are not used together.

Fields:
Validators:
  • debias_only_with_hwang » all fields

field a: float | None = None

Proportionality coefficient when activating the Cavaleri and Malanotte (1981) wave growth term (SWAN default: 0.0015)

Validated by:
  • debias_only_with_hwang

field a1sds: Literal[4.7e-07] = 4.7e-07
Validated by:
  • debias_only_with_hwang

field a2sds: Literal[6.6e-06] = 6.6e-06
Validated by:
  • debias_only_with_hwang

field agrow: Literal[True] = True
Validated by:
  • debias_only_with_hwang

field cdfac: float | None = None

Counter bias in the input wind fields by providing a multiplier on the drag coefficient

Constraints:
  • gt = 0.0

Validated by:
  • debias_only_with_hwang

field model_type: Literal['st6c2'] = 'st6c2'
Validated by:
  • debias_only_with_hwang

field normalization: Literal['up', 'down'] = 'up'

Selection of normalization of exceedance level by ET(f) (up) or E(f) (down) as in RBW12 (right column, page 1333), up is default and strongly recommended

Validated by:
  • debias_only_with_hwang

field p1sds: Literal[4.0] = 4.0
Validated by:
  • debias_only_with_hwang

field p2sds: Literal[4.0] = 4.0
Validated by:
  • debias_only_with_hwang

field tau: Literal['vectau', 'scatau'] = 'vectau'

Use vector (vectau) or scalar (scatau) calculation for the wind strerss (Eq. 12 in RBW12), vectau is the default and strongly recommended

Validated by:
  • debias_only_with_hwang

field u10: Literal['u10proxy', 'true10'] = 'u10proxy'

Wind velocity definition

Validated by:
  • debias_only_with_hwang

field wind_drag: Literal['fan'] = 'fan'
Validated by:
  • debias_only_with_hwang

field windscaling: Literal[28.0] = 28.0
Validated by:
  • debias_only_with_hwang

cmd() str
validator debias_only_with_hwang  »  all fields
render() str

Render the sub-component to a string.

property u10_cmd: str
pydantic model rompy.swan.subcomponents.physics.ST6C3[source]

Third ST6 calibration in the SWAN user manual.

ST6 2.8e-6 3.5e-5 4.0 4.0 UP HWANG VECTAU U10PROXY 32.0 AGROW

Examples

In [1]: from rompy.swan.subcomponents.physics import ST6C3

In [2]: st6 = ST6C3()

In [3]: print(st6.render())
ST6 a1sds=2.8e-06 a2sds=3.5e-05 p1sds=4.0 p2sds=4.0 UP HWANG VECTAU U10PROXY windscaling=32.0 AGROW
Fields:
Validators:
  • debias_only_with_hwang » all fields

field a: float | None = None

Proportionality coefficient when activating the Cavaleri and Malanotte (1981) wave growth term (SWAN default: 0.0015)

Validated by:
  • debias_only_with_hwang

field a1sds: Literal[2.8e-06] = 2.8e-06
Validated by:
  • debias_only_with_hwang

field a2sds: Literal[3.5e-05] = 3.5e-05
Validated by:
  • debias_only_with_hwang

field agrow: Literal[True] = True
Validated by:
  • debias_only_with_hwang

field cdfac: float | None = None

Counter bias in the input wind fields by providing a multiplier on the drag coefficient

Constraints:
  • gt = 0.0

Validated by:
  • debias_only_with_hwang

field model_type: Literal['st6c3'] = 'st6c3'
Validated by:
  • debias_only_with_hwang

field normalization: Literal['up', 'down'] = 'up'

Selection of normalization of exceedance level by ET(f) (up) or E(f) (down) as in RBW12 (right column, page 1333), up is default and strongly recommended

Validated by:
  • debias_only_with_hwang

field p1sds: Literal[4.0] = 4.0
Validated by:
  • debias_only_with_hwang

field p2sds: Literal[4.0] = 4.0
Validated by:
  • debias_only_with_hwang

field tau: Literal['vectau', 'scatau'] = 'vectau'

Use vector (vectau) or scalar (scatau) calculation for the wind strerss (Eq. 12 in RBW12), vectau is the default and strongly recommended

Validated by:
  • debias_only_with_hwang

field u10: Literal['u10proxy', 'true10'] = 'u10proxy'

Wind velocity definition

Validated by:
  • debias_only_with_hwang

field wind_drag: Literal['hwang', 'fan', 'ecmwf'] = 'hwang'

Wind drag formula, hwang is the default and is unchanged from RBW12, fan is from Fan et al. (2012), ecmwf follows WAM Cycle 4 methodology

Validated by:
  • debias_only_with_hwang

field windscaling: Literal[32.0] = 32.0
Validated by:
  • debias_only_with_hwang

cmd() str
validator debias_only_with_hwang  »  all fields
render() str

Render the sub-component to a string.

property u10_cmd: str
pydantic model rompy.swan.subcomponents.physics.ST6C4[source]

Fourth ST6 calibration in the SWAN user manual.

ST6 2.8e-6 3.5e-5 4.0 4.0 UP HWANG VECTAU U10PROXY 32.0 DEBIAS 0.89 AGROW

Examples

In [1]: from rompy.swan.subcomponents.physics import ST6C4

In [2]: st6 = ST6C4()

In [3]: print(st6.render())
ST6 a1sds=2.8e-06 a2sds=3.5e-05 p1sds=4.0 p2sds=4.0 UP HWANG VECTAU U10PROXY windscaling=32.0 DEBIAS cdfac=0.89 AGROW
Fields:
Validators:
  • debias_only_with_hwang » all fields

field a: float | None = None

Proportionality coefficient when activating the Cavaleri and Malanotte (1981) wave growth term (SWAN default: 0.0015)

Validated by:
  • debias_only_with_hwang

field a1sds: Literal[2.8e-06] = 2.8e-06
Validated by:
  • debias_only_with_hwang

field a2sds: Literal[3.5e-05] = 3.5e-05
Validated by:
  • debias_only_with_hwang

field agrow: Literal[True] = True
Validated by:
  • debias_only_with_hwang

field cdfac: Literal[0.89] = 0.89
Validated by:
  • debias_only_with_hwang

field model_type: Literal['st6c4'] = 'st6c4'
Validated by:
  • debias_only_with_hwang

field normalization: Literal['up', 'down'] = 'up'

Selection of normalization of exceedance level by ET(f) (up) or E(f) (down) as in RBW12 (right column, page 1333), up is default and strongly recommended

Validated by:
  • debias_only_with_hwang

field p1sds: Literal[4.0] = 4.0
Validated by:
  • debias_only_with_hwang

field p2sds: Literal[4.0] = 4.0
Validated by:
  • debias_only_with_hwang

field tau: Literal['vectau', 'scatau'] = 'vectau'

Use vector (vectau) or scalar (scatau) calculation for the wind strerss (Eq. 12 in RBW12), vectau is the default and strongly recommended

Validated by:
  • debias_only_with_hwang

field u10: Literal['u10proxy', 'true10'] = 'u10proxy'

Wind velocity definition

Validated by:
  • debias_only_with_hwang

field wind_drag: Literal['hwang', 'fan', 'ecmwf'] = 'hwang'

Wind drag formula, hwang is the default and is unchanged from RBW12, fan is from Fan et al. (2012), ecmwf follows WAM Cycle 4 methodology

Validated by:
  • debias_only_with_hwang

field windscaling: Literal[32.0] = 32.0
Validated by:
  • debias_only_with_hwang

cmd() str
validator debias_only_with_hwang  »  all fields
render() str

Render the sub-component to a string.

property u10_cmd: str
pydantic model rompy.swan.subcomponents.physics.ST6C5[source]

Fifth ST6 calibration in the SWAN user manual.

ST6 4.7e-7 6.6e-6 4.0 4.0 UP HWANG VECTAU U10PROXY 28.0 AGROW

Examples

In [1]: from rompy.swan.subcomponents.physics import ST6C5

In [2]: st6 = ST6C5()

In [3]: print(st6.render())
ST6 a1sds=6.5e-06 a2sds=8.5e-05 p1sds=4.0 p2sds=4.0 UP HWANG VECTAU U10PROXY windscaling=35.0 DEBIAS cdfac=0.89 AGROW
Fields:
Validators:
  • debias_only_with_hwang » all fields

field a: float | None = None

Proportionality coefficient when activating the Cavaleri and Malanotte (1981) wave growth term (SWAN default: 0.0015)

Validated by:
  • debias_only_with_hwang

field a1sds: Literal[6.5e-06] = 6.5e-06
Validated by:
  • debias_only_with_hwang

field a2sds: Literal[8.5e-05] = 8.5e-05
Validated by:
  • debias_only_with_hwang

field agrow: Literal[True] = True
Validated by:
  • debias_only_with_hwang

field cdfac: Literal[0.89] = 0.89
Validated by:
  • debias_only_with_hwang

field model_type: Literal['st6c5'] = 'st6c5'
Validated by:
  • debias_only_with_hwang

field normalization: Literal['up', 'down'] = 'up'

Selection of normalization of exceedance level by ET(f) (up) or E(f) (down) as in RBW12 (right column, page 1333), up is default and strongly recommended

Validated by:
  • debias_only_with_hwang

field p1sds: Literal[4.0] = 4.0
Validated by:
  • debias_only_with_hwang

field p2sds: Literal[4.0] = 4.0
Validated by:
  • debias_only_with_hwang

field tau: Literal['vectau', 'scatau'] = 'vectau'

Use vector (vectau) or scalar (scatau) calculation for the wind strerss (Eq. 12 in RBW12), vectau is the default and strongly recommended

Validated by:
  • debias_only_with_hwang

field u10: Literal['u10proxy', 'true10'] = 'u10proxy'

Wind velocity definition

Validated by:
  • debias_only_with_hwang

field wind_drag: Literal['hwang', 'fan', 'ecmwf'] = 'hwang'

Wind drag formula, hwang is the default and is unchanged from RBW12, fan is from Fan et al. (2012), ecmwf follows WAM Cycle 4 methodology

Validated by:
  • debias_only_with_hwang

field windscaling: Literal[35.0] = 35.0
Validated by:
  • debias_only_with_hwang

cmd() str
validator debias_only_with_hwang  »  all fields
render() str

Render the sub-component to a string.

property u10_cmd: str
pydantic model rompy.swan.subcomponents.physics.SourceTerms[source]

Source term subcomponent base class.

Fields:
  • a (float | None)

  • agrow (bool)

  • model_type ()

  • wind_drag (Literal['wu', 'fit'])

field a: float | None = None

Proportionality coefficient when activating the Cavaleri and Malanotte (1981) wave growth term (SWAN default: 0.0015)

field agrow: bool = False

Activate the Cavaleri and Malanotte (1981) wave growth term

field model_type: Literal['subcomponent'] [Required]

Model type discriminator

field wind_drag: Literal['wu', 'fit'] = 'wu'

Indicates the wind drag formulation

cmd() str
render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.physics.TRANS1D[source]

Frequency dependent transmission.

TRANS1D < [trcoef] >

Examples

In [1]: from rompy.swan.subcomponents.physics import TRANS1D

In [2]: transm = TRANS1D(trcoef=[0.0, 0.0, 0.2, 0.5, 0.2, 0.0, 0.0])

In [3]: print(transm.render())
TRANS1D 0.0 0.0 0.2 0.5 0.2 0.0 0.0
Fields:
field model_type: Literal['trans1d', 'TRANS1D'] = 'trans1d'

Model type discriminator

field trcoef: list[float] [Required]

Transmission coefficient (ratio of transmitted over incoming significant wave height) per frequency. The number of these transmission values must be equal to the number of frequencies, i.e. msc + 1

cmd() str[source]

Command file string for this subcomponent.

render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.physics.TRANS2D[source]

Frequency-direction dependent transmission.

TRANS2D < [trcoef] >

Examples

In [1]: from rompy.swan.subcomponents.physics import TRANS2D

In [2]: trcoef = np.array([[0.0, 0.0], [0.1, 0.1], [0.2, 0.2]])

In [3]: transm = TRANS2D(trcoef=trcoef)

In [4]: print(transm.render())
TRANS2D &
	0.0 0.0 &
	0.1 0.1 &
	0.2 0.2 &
Fields:
Validators:
field model_type: Literal['trans2d', 'TRANS2D'] = 'trans2d'

Model type discriminator

field trcoef: ndarray[tuple[int, int], dtype[Any]] | Path | MultiArrayNumpyFile [Required]

Transmission coefficient (ratio of transmitted over incoming significant wave height) per frequency and direction, rows represent directions and columns represent frequencies

Constraints:
  • dimensions = 2

  • strict_data_typing = False

  • serialize_numpy_array_to_json = <function pd_np_native_numpy_array_to_data_dict_serializer at 0x7f958b57e440>

  • json_schema_from_type_data = <function pd_np_native_numpy_array_json_schema_from_type_data at 0x7f958b12fb50>

  • __module__ = pydantic_numpy.helper.annotation

Validated by:
cmd() str[source]

Command file string for this subcomponent.

validator constrained_0_1  »  trcoef[source]

Ensure all directions have the same number of frequencies.

render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.physics.TRANSM[source]

Constant transmission coefficient.

TRANSM [trcoef]

Examples

In [1]: from rompy.swan.subcomponents.physics import TRANSM

In [2]: transm = TRANSM()

In [3]: print(transm.render())
TRANSM

In [4]: transm = TRANSM(trcoef=0.5)

In [5]: print(transm.render())
TRANSM trcoef=0.5
Fields:
field model_type: Literal['transm', 'TRANSM'] = 'transm'

Model type discriminator

field trcoef: float | None = None

Constant transmission coefficient (ratio of transmitted over incoming significant wave height) (SWAN default: 0.0) (no transmission = complete blockage)

Constraints:
  • ge = 0.0

  • le = 1.0

cmd() str[source]

Command file string for this subcomponent.

render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.physics.WESTHUYSEN[source]

Westhuysen source terms subcomponent.

WESTHUYSEN [cds2] [br] (AGROW [a])

Nonlinear saturation-based whitecapping combined with wind input of Yan (1987).

Notes

The two arguments are specified in the Appendix C of the User manual but not in the command description for WESTH in Section 4.5.4. They are also options in the WCAPPING command. It is not entirely clear if they should/could be specified here.

References

van der Westhuysen, A.J., Zijlema, M. and Battjes, J.A., 2007. Nonlinear saturation-based whitecapping dissipation in SWAN for deep and shallow water. Coastal Engineering, 54(2), pp.151-170.

Examples

In [1]: from rompy.swan.subcomponents.physics import WESTHUYSEN

In [2]: westhuysen = WESTHUYSEN()

In [3]: print(westhuysen.render())
WESTHUYSEN DRAG WU

In [4]: westhuysen = WESTHUYSEN(cds2=5.0e-5, br=1.75e-3)

In [5]: print(westhuysen.render())
WESTHUYSEN cds2=5e-05 br=0.00175 DRAG WU
Fields:
field a: float | None = None

Proportionality coefficient when activating the Cavaleri and Malanotte (1981) wave growth term (SWAN default: 0.0015)

field agrow: bool = False

Activate the Cavaleri and Malanotte (1981) wave growth term

field br: float | None = None

Threshold saturation level (SWAN default: 1.75e-3)

field cds2: float | None = None

proportionality coefficient due to Alves and Banner (2003) (SWAN default: 5.0e-5).

field model_type: Literal['westhuysen', 'WESTHUYSEN'] = 'westhuysen'

Model type discriminator

field wind_drag: Literal['wu', 'fit'] = 'wu'

Indicates the wind drag formulation

cmd() str[source]
render() str

Render the sub-component to a string.

Numerics#

SWAN numerics subcomponents.

pydantic model rompy.swan.subcomponents.numerics.ACCUR[source]

Stop the iterative procedure.

ACCUR [drel] [dhoval] [dtoval] [npnts] ->STAT|NONSTAT [limiter]

With this option the user can influence the criterion for terminating the iterative procedure in the SWAN computations (both stationary and non-stationary modes). SWAN stops the iterations if (a), (b) and (c) are all satisfied:

  1. The change in the local significant wave height Hs from one iteration to the next is less than (1) fraction drel of that height or (2) fraction dhoval of the average Hs over all grid points.

  2. The change in the local mean wave period Tm01 from one iteration to the next is less than (1) fraction drel of that period or (2) fraction dtoval of the average mean wave period over all wet grid points.

  3. Conditions (a) and (b) are fulfilled in more than fraction npnts% of all wet grid points.

Note

This command has become obsolete in SWAN 41.01. The command STOPC should be used.

Examples

In [1]: from rompy.swan.subcomponents.numerics import ACCUR

In [2]: accur = ACCUR()

In [3]: print(accur.render())
ACCUR

In [4]: accur = ACCUR(
   ...:     drel=0.01,
   ...:     dhoval=0.02,
   ...:     dtoval=0.02,
   ...:     npnts=98.0,
   ...:     mode=dict(model_type="nonstat", mxitns=1),
   ...:     limiter=0.1,
   ...: )
   ...: 

In [5]: print(accur.render())
ACCUR drel=0.01 dhoval=0.02 dtoval=0.02 npnts=98.0 NONSTATIONARY mxitns=1 limiter=0.1
Fields:
field dhoval: float | None = None

Fraction of the average Hs over all wet grid points below which the the stopping criteria needs to be satisfied (SWAN default: 0.02)

field drel: float | None = None

Maximum relative change in Hs or Tm01 from one iteration to the next (SWAN default: 0.02)

field dtoval: float | None = None

Fraction of the average Tm01 over all wet grid points below which the the stopping criteria needs to be satisfied (SWAN default: 0.02)

field limiter: float | None = None

Determines the maximum change per iteration of the energy density per spectral-bin given in terms of a fraction of the omni-directional Phillips level (SWAN default: 0.1)

field mode: STAT | NONSTAT | None = None

Termination criteria for stationary or nonstationary runs

field model_type: Literal['accur', 'ACCUR'] = 'accur'

Model type discriminator

field npnts: float | None = None

Percentage of points in the computational grid above which the stopping criteria needs to be satisfied (SWAN default: 98)

cmd() str[source]

Command file string for this component.

render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.numerics.BSBT[source]

BSBT first order propagation scheme.

BSTB

Examples

In [1]: from rompy.swan.subcomponents.numerics import BSBT

In [2]: scheme = BSBT()

In [3]: print(scheme.render())
BSBT
Fields:
field model_type: Literal['bsbt', 'BSBT'] = 'bsbt'

Model type discriminator

cmd() str[source]

Command file string for this component.

render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.numerics.CSIGMA[source]

Prevents excessive directional turning.

CSigma [cfl]

This option prevents an excessive frequency shifting at a single grid point or vertex due to a very coarse bathymetry or current locally. This option limits the frequency shifting rate csigma based on the CFL restriction. See also the final remark in Section 2.6.3. Note that if this command is not specified, then the limiter is not activated.

Examples

In [1]: from rompy.swan.subcomponents.numerics import CSIGMA

In [2]: csigma = CSIGMA()

In [3]: print(csigma.render())
CSIGMA

In [4]: csigma = CSIGMA(cfl=0.9)

In [5]: print(csigma.render())
CSIGMA cfl=0.9
Fields:
field cfl: float | None = None

Upper limit for the CFL restriction for csigma. A suggestion for this parameter is cfl = 0.9 (SWAN default: 0.9 when CSIGMA is activated)

field model_type: Literal['ctheta', 'CTHETA'] = 'ctheta'

Model type discriminator

cmd() str[source]

Command file string for this component.

render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.numerics.CTHETA[source]

Prevents excessive directional turning.

CTheta [cfl]

This option prevents an excessive directional turning at a single grid point or vertex due to a very coarse bathymetry or current locally. This option limits the directional turning rate cθ based on the CFL restriction. (See Eq. 3.41 of Scientific/Technical documentation). See also the final remark in Section 2.6.3. Note that if this command is not specified, then the limiter is not activated.

Examples

In [1]: from rompy.swan.subcomponents.numerics import CTHETA

In [2]: ctheta = CTHETA()

In [3]: print(ctheta.render())
CTHETA

In [4]: ctheta = CTHETA(cfl=0.9)

In [5]: print(ctheta.render())
CTHETA cfl=0.9
Fields:
field cfl: float | None = None

Upper limit for the CFL restriction for ctheta. A suggestion for this parameter is cfl = 0.9 (SWAN default: 0.9 when CTHETA is activated)

field model_type: Literal['ctheta', 'CTHETA'] = 'ctheta'

Model type discriminator

cmd() str[source]

Command file string for this component.

render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.numerics.DIRIMPL[source]

Numerical scheme for refraction.

DIRIMPL [cdd]

Examples

In [1]: from rompy.swan.subcomponents.numerics import DIRIMPL

In [2]: dirimpl = DIRIMPL()

In [3]: print(dirimpl.render())
DIRIMPL

In [4]: dirimpl = DIRIMPL(cdd=0.5)

In [5]: print(dirimpl.render())
DIRIMPL cdd=0.5
Fields:
field cdd: float | None = None

A value of cdd=0 corresponds to a central scheme and has the largest accuracy (diffusion ≈ 0) but the computation may more easily generatespurious fluctuations. A value of cdd=1 corresponds to a first orderupwind scheme and it is more diffusive and therefore preferable if (strong) gradients in depth or current are present (SWAN default: 0.5)

field model_type: Literal['dirimpl', 'DIRIMPL'] = 'dirimpl'

Model type discriminator

cmd() str[source]

Command file string for this component.

render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.numerics.GSE[source]

Garden-sprinkler effect.

GSE [waveage] Sec|MIn|HR|DAy

Garden-sprinkler effect is to be counteracted in the S&L propagation scheme (default for nonstationary regular grid computations) or in the propagation scheme for unstructured grids by adding a diffusion term to the basic equation. This may affect the numerical stability of SWAN.

Examples

In [1]: from rompy.swan.subcomponents.numerics import GSE

In [2]: scheme = GSE(waveage=dict(delt=86400, dfmt="day"))

In [3]: print(scheme.render())
GSE waveage=1.0 DAY
Fields:
field model_type: Literal['gse', 'GSE'] = 'gse'

Model type discriminator

field waveage: Delt | None = None

The time interval used to determine the diffusion which counteracts the so-called garden-sprinkler effect. The default value of waveage is zero, i.e. no added diffusion. The value of waveage should correspond to the travel time of the waves over the computational region.

cmd() str[source]

Command file string for this component.

render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.numerics.NONSTAT[source]

Computation parameters in nonstationary computation.

Fields:
field model_type: Literal['nonstat', 'NONSTAT'] = 'nonstat'

Model type discriminator

field mxitns: int | None = None

The maximum number of iterations per time step for nonstationary computations. The computation moves to the next time step when this number is exceeded (SWAN default: mxitns = 1

cmd() str[source]

Command file string for this component.

render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.numerics.SETUP[source]

Stop criteria in the computation of wave setup.

SETUP [eps2] [outp] [niter]

Controls the stopping criterion and amount of output for the SOR solver in the computation of the wave-induced set-up.

Examples

In [1]: from rompy.swan.subcomponents.numerics import SETUP

In [2]: setup = SETUP()

In [3]: print(setup.render())
SETUP

In [4]: setup = SETUP(eps2=1e-4, outp=0, niter=20)

In [5]: print(setup.render())
SETUP eps2=0.0001 outp=0 niter=20
Fields:
field eps2: float | None = None

Relative stopping criterion to terminate the linear solver (SIP or SOR). (SWAN default: 1.e-4 in case of SIP and 1.e-6 in case of SOR)

field model_type: Literal['setup', 'SETUP'] = 'setup'

Model type discriminator

field niter: int | None = None

Maximum number of iterations for the linear solver (SWAN default: 20 in case of SIP and 1000 in case of SOR)

field outp: Literal[0, 1, 2, 3] | None = None

Output for the iterative solver:

  • 0 = no output

  • 1 = additional information about the iteration process is written to the PRINT file

  • 2 = gives a maximal amount of output concerning the iteration process

  • 3 = summary of the iteration process

(SWAN default: 0)

cmd() str[source]

Command file string for this component.

render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.numerics.SIGIMPL[source]

Frequency shifting accuracy.

SIGIMpl [cfl] [eps2] [outp] [niter]

Controls the accuracy of computing the frequency shifting and the stopping criterion and amount of output for the SIP solver (used in the computations in the presence of currents or time varying depth)

Examples

In [1]: from rompy.swan.subcomponents.numerics import SIGIMPL

In [2]: sigimpl = SIGIMPL()

In [3]: print(sigimpl.render())
SIGIMPL

In [4]: sigimpl = SIGIMPL(css=0.5, eps2=1e-4, outp=0, niter=20)

In [5]: print(sigimpl.render())
SIGIMPL css=0.5 eps2=0.0001 outp=0 niter=20
Fields:
field css: float | None = None

A value of css=0 corresponds to a central scheme and has the largest accuracy (diffusion ≈ 0) but the computation may more easily generate spurious fluctuations. A value of css=1 corresponds to a first order upwind scheme and it is more diffusive and therefore preferable if (strong) gradients in depth or current are present (SWAN default: 0.5)

field eps2: float | None = None

Relative stopping criterion to terminate the linear solver (SIP or SOR). (SWAN default: 1.e-4 in case of SIP and 1.e-6 in case of SOR)

field model_type: Literal['sigimpl', 'SIGIMPL'] = 'sigimpl'

Model type discriminator

field niter: int | None = None

Maximum number of iterations for the linear solver (SWAN default: 20 in case of SIP and 1000 in case of SOR)

field outp: Literal[0, 1, 2, 3] | None = None

Output for the iterative solver:

  • 0 = no output

  • 1 = additional information about the iteration process is written to the PRINT file

  • 2 = gives a maximal amount of output concerning the iteration process

  • 3 = summary of the iteration process

(SWAN default: 0)

cmd() str[source]

Command file string for this component.

render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.numerics.STAT[source]

Computation parameters in stationary computation.

Fields:
field alfa: float | None = None

Proportionality constant used in the frequency-dependent under-relaxation technique. Based on experiences, a suggestion for this parameter is alfa = 0.01. In case of diffraction computations, the use of this parameter is recommended (SWAN default: 0.00)

field model_type: Literal['stat', 'STAT'] = 'stat'

Model type discriminator

field mxitst: int | None = None

The maximum number of iterations for stationary computations. The computation stops when this number is exceeded (SWAN default: 50)

cmd() str[source]

Command file string for this component.

render() str

Render the sub-component to a string.

pydantic model rompy.swan.subcomponents.numerics.STOPC[source]

Stopping criteria of Zijlema and Van der Westhuysen (2005).

STOPC [dabs] [drel] [curvat] [npnts] ->STAT|NONSTAT [limiter]

With this option the user can influence the criterion for terminating the iterative procedure in the SWAN computations (both stationary and nonstationary). The criterion makes use of the second derivative, or curvature, of the iteration curve of the significant wave height. As the solution of a simulation approaches full convergence, the curvature of the iteration curve will tend to zero. SWAN stops the process if the relative change in Hs from one iteration to the next is less than drel and the curvature of the iteration curve of Hs normalized with Hs is less than curvat or the absolute change in Hs from one iteration to the next is less than dabs. Both conditions need to be fulfilled in more than fraction npnts percent of all wet grid points.

With respect to the QC modelling, another stopping criteria will be employed. Namely, SWAN stops the iteration process if the absolute change in Hs from one iterate to another is less than dabs * Hinc, where Hinc is the representative incident wave height, or the relative change in Hs from one to the next iteration is less than drel. These criteria must be fulfilled in more than npnts percent of all active, well-defined points.

References

  • Zijlema, M. and Van der Westhuysen, A. (2005). On convergence behaviour and numerical accuracy in stationary SWAN simulations of nearshore wind wave spectra, Coastal Engineering, 52(3), p. 337-256.

Examples

In [1]: from rompy.swan.subcomponents.numerics import STOPC

In [2]: stop = STOPC()

In [3]: print(stop.render())
STOPC

In [4]: stop = STOPC(
   ...:     dabs=0.005,
   ...:     drel=0.01,
   ...:     curvat=0.005,
   ...:     npnts=99.5,
   ...:     mode=dict(model_type="nonstat", mxitns=1),
   ...:     limiter=0.1,
   ...: )
   ...: 

In [5]: print(stop.render())
STOPC dabs=0.005 drel=0.01 curvat=0.005 npnts=99.5 NONSTATIONARY mxitns=1 limiter=0.1
Fields:
field curvat: float | None = None

Maximum curvature of the iteration curve of Hs normalised with Hs (SWAN default: 0.005 [-] (not used in the QC model))

field dabs: float | None = None

Maximum absolute change in Hs from one iteration to the next (SWAN default: 0.005 [m] or 0.05 [-] in case of QC model)

field drel: float | None = None

Maximum relative change in Hs from one iteration to the next (SWAN default: 0.01 [-])

field limiter: float | None = None

Determines the maximum change per iteration of the energy density per spectral-bin given in terms of a fraction of the omni-directional Phillips level (SWAN default: 0.1)

field mode: STAT | NONSTAT | None = None

Termination criteria for stationary or nonstationary runs

field model_type: Literal['stopc', 'STOPC'] = 'stopc'

Model type discriminator

field npnts: float | None = None

Percentage of points in the computational grid above which the stopping criteria needs to be satisfied (SWAN default: 99.5 [-])

cmd() str[source]

Command file string for this component.

render() str

Render the sub-component to a string.