Skip to content

Output

Output locations (FRAME, GROUP, CURVE, POINTS, NGRID and others), output quantities and the write commands (BLOCK, TABLE, SPECOUT, NESTOUT).

SWAN Output Components

This module contains components for configuring output locations and parameters for SWAN model results, including spatial points, curves, and nested grids.

logger module-attribute

logger = get_logger(__name__)

SPECIAL_NAMES module-attribute

SPECIAL_NAMES = [
    "BOTTGRID",
    "COMPGRID",
    "BOUNDARY",
    "BOUND_",
]

SNAME_TYPE module-attribute

SNAME_TYPE = Annotated[
    str, Field(min_length=1, max_length=8)
]

DIM_TYPE module-attribute

DIM_TYPE = Annotated[
    Union[SPEC1D, SPEC2D],
    Field(
        description="Choose between 1D or 2D spectra output",
        discriminator="model_type",
    ),
]

FREQ_TYPE module-attribute

FREQ_TYPE = Annotated[
    Union[ABS, REL],
    Field(
        description="Choose between absolute or relative frequency spectra",
        discriminator="model_type",
    ),
]

BaseLocation pydantic-model

BaseLocation(**data: Any)

Bases: BaseComponent, ABC

Base class for SWAN output locations.

{MODEL_TYPE} sname='sname'

This is the base class for all locations components. It is not meant to be used directly.

Note

The name of the set of output locations sname cannot be longer than 8 characters and must not match any SWAN special names such as BOTTGRID (define output over the bottom/current grid) or COMPGRID (define output over the computational grid).

Examples:

from rompy_swan.components.output import BaseLocation
loc = BaseLocation(sname="outsites")
print(loc.render())
LOCATIONS sname='outsites'

Fields:

Validators:

model_type pydantic-field

model_type: Literal['locations', 'LOCATIONS'] = 'locations'

Model type discriminator

sname pydantic-field

sname: SNAME_TYPE

Name of the set of output locations defined by this command

not_special_name pydantic-validator

not_special_name(sname: str) -> str

Ensure sname is not defined as one of the special names.

cmd

cmd() -> str

Command file string for this component.

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

render

render(cmd: Optional[str | list] = None) -> str

Render the component to a string.

Parameters:

Name Type Description Default
cmd Optional[str | list]

Command string or list of command strings to render, by default self.cmd().

None

Returns:

Name Type Description
cdmstr str

The rendered command file component.

FRAME pydantic-model

FRAME(**data: Any)

Bases: BaseLocation

Output locations on a regular grid.

FRAME 'sname' [xpfr] [ypfr] [alpfr] [xlenfr] [ylenfr] [mxfr] [myfr]

With this optional command the user defines output on a rectangular, uniform grid in a regular frame.

If the set of output locations is identical to a part of the computational grid, then the user can use the alternative command GROUP.

Note

Cannot be used in 1D-mode.

Examples:

from rompy_swan.components.output import FRAME
loc = FRAME(
    sname="outgrid",
    grid=dict(xp=173, yp=-40, xlen=2, ylen=2, mx=19, my=19),
)
print(loc.render())
FRAME sname='outgrid' xpfr=173.0 ypfr=-40.0 alpfr=0.0 xlenfr=2.0 ylenfr=2.0 mxfr=19 myfr=19

Fields:

Validators:

model_type pydantic-field

model_type: Literal['frame', 'FRAME'] = 'frame'

Model type discriminator

grid pydantic-field

Frame grid definition

sname pydantic-field

sname: SNAME_TYPE

Name of the set of output locations defined by this command

grid_suffix pydantic-validator

grid_suffix(grid: GRIDREGULAR) -> GRIDREGULAR

cmd

cmd() -> str

Command file string for this component.

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

render

render(cmd: Optional[str | list] = None) -> str

Render the component to a string.

Parameters:

Name Type Description Default
cmd Optional[str | list]

Command string or list of command strings to render, by default self.cmd().

None

Returns:

Name Type Description
cdmstr str

The rendered command file component.

not_special_name pydantic-validator

not_special_name(sname: str) -> str

Ensure sname is not defined as one of the special names.

GROUP pydantic-model

GROUP(**data: Any)

Bases: BaseLocation

Output locations on subset of a grid.

GROUP 'sname' SUBGRID [ix1] [ix2] [iy1] [iy2]

With this optional command the user defines a group of output locations on a rectangular or curvilinear grid that is identical with (part of) the computational grid (rectilinear or curvilinear). Such a group may be convenient for the user to obtain output that is not affected by interpolation errors.

The subgrid contains those points (ix,iy) of the computational grid for which: ix1 <= ix <= ix2 and iy1 <= iy <= iy2 (The origin of the computational grid is ix=0, iy=0)

Limitations: ix1>=0, ix2<=mxc, iy1>=0, iy2<=myc (mxc and myc as defined in the command CGRID which should always precede this command GROUP)

Note

Cannot be used in 1D-mode or in case of unstructured grids.

Note

Regular and curvilinear grids are supported.

Examples:

from rompy_swan.components.output import GROUP
loc = GROUP(sname="subgrid", ix1=20, iy1=0, ix2=50, iy2=100)
print(loc.render())
GROUP sname='subgrid' SUBGRID ix1=20 iy1=0 ix2=50 iy2=100

Fields:

Validators:

model_type pydantic-field

model_type: Literal['group', 'GROUP'] = 'group'

Model type discriminator

ix1 pydantic-field

ix1: int

Lowest index of the computational grid in the ix-direction

iy1 pydantic-field

iy1: int

Lowest index of the computational grid in the iy-direction

ix2 pydantic-field

ix2: int

Highest index of the computational grid in the ix-direction

iy2 pydantic-field

iy2: int

Highest index of the computational grid in the ix-direction

sname pydantic-field

sname: SNAME_TYPE

Name of the set of output locations defined by this command

cmd

cmd() -> str

Command file string for this component.

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

render

render(cmd: Optional[str | list] = None) -> str

Render the component to a string.

Parameters:

Name Type Description Default
cmd Optional[str | list]

Command string or list of command strings to render, by default self.cmd().

None

Returns:

Name Type Description
cdmstr str

The rendered command file component.

not_special_name pydantic-validator

not_special_name(sname: str) -> str

Ensure sname is not defined as one of the special names.

CURVE pydantic-model

CURVE(**data: Any)

Bases: BaseLocation

Output locations along a curve.

CURVE 'sname' [xp1] [yp1] < [int] [xp] [yp] >

With this optional command the user defines output along a curved line. Actually this curve is a broken line, defined by the user with its corner points. The values of the output quantities along the curve are interpolated from the computational grid. This command may be used more than once to define more curves.

Note

The following pre-defined curves are available and could be used instead of a CURVE component: 'BOUNDARY' and BOUND_0N where N is boundary part number.

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).

Note

Repeat the group < int xp yp > in proper order if there are more corner points on the curve.

Examples:

from rompy_swan.components.output import CURVE
loc = CURVE(
    sname="outcurve",
    xp1=172,
    yp1=-40,
    npts=[3, 3],
    xp=[172.0, 174.0],
    yp=[-38.0, -38.0],
)
print(loc.render())
CURVE sname='outcurve' xp1=172.0 yp1=-40.0 &
    int=3 xp=172.0 yp=-38.0 &
    int=3 xp=174.0 yp=-38.0

Fields:

Validators:

model_type pydantic-field

model_type: Literal['curve', 'CURVE'] = 'curve'

Model type discriminator

xp1 pydantic-field

xp1: float

Problem coordinate of the first point of the curve in the x-direction

yp1 pydantic-field

yp1: float

Problem coordinate of the first point of the curve in the y-direction

npts pydantic-field

npts: list[int]

The int CURVE parameter, SWAN will generate npts-1 equidistant locations between two subsequent corner points of the curve including the two corner points

xp pydantic-field

xp: list[float]

problem coordinates of a corner point of the curve in the x-direction

yp pydantic-field

yp: list[float]

problem coordinates of a corner point of the curve in the y-direction

sname pydantic-field

sname: SNAME_TYPE

Name of the set of output locations defined by this command

ensure_equal_size pydantic-validator

ensure_equal_size() -> CURVE

cmd

cmd() -> str

Command file string for this component.

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

render

render(cmd: Optional[str | list] = None) -> str

Render the component to a string.

Parameters:

Name Type Description Default
cmd Optional[str | list]

Command string or list of command strings to render, by default self.cmd().

None

Returns:

Name Type Description
cdmstr str

The rendered command file component.

not_special_name pydantic-validator

not_special_name(sname: str) -> str

Ensure sname is not defined as one of the special names.

CURVES pydantic-model

CURVES(**data: Any)

Bases: BaseComponent

Output locations along multiple curves.

CURVE 'sname1' [xp1] [yp1] < [int] [xp] [yp] >
CURVE 'sname2' [xp1] [yp1] < [int] [xp] [yp] >
..

This component can be used to prescribe and render multiple CURVE components.

Examples

from rompy_swan.components.output import CURVE, CURVES
loc1 = CURVE(
    sname="c1", xp1=7, yp1=-40, npts=[3, 3], xp=[7, 9], yp=[-38, -38],
)
loc2 = CURVE(
    sname="c2", xp1=3, yp1=-37, npts=[5, 5], xp=[4, 5], yp=[-37, -36],
)
locs = CURVES(curves=[loc1, loc2])
print(locs.render())
CURVE sname='c1' xp1=7.0 yp1=-40.0 &
    int=3 xp=7.0 yp=-38.0 &
    int=3 xp=9.0 yp=-38.0
CURVE sname='c2' xp1=3.0 yp1=-37.0 &
    int=5 xp=4.0 yp=-37.0 &
    int=5 xp=5.0 yp=-36.0

Fields:

model_type pydantic-field

model_type: Literal['curves', 'CURVES'] = 'curves'

Model type discriminator

curves pydantic-field

curves: list[CURVE]

CURVE components

sname property

sname: list[str]

cmd

cmd() -> list[str]

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

render

render(cmd: Optional[str | list] = None) -> str

Render the component to a string.

Parameters:

Name Type Description Default
cmd Optional[str | list]

Command string or list of command strings to render, by default self.cmd().

None

Returns:

Name Type Description
cdmstr str

The rendered command file component.

RAY pydantic-model

RAY(**data: Any)

Bases: BaseComponent

Output locations along a depth contour.

RAY 'rname' [xp1] [yp1] [xq1] [yq1] < [int] [xp] [yp] [xq] [yq] >

With this optional command the user provides SWAN with information to determine output locations along the depth contour line(s) defined subsequently in command ISOLINE (see below).

These locations are determined by SWAN as the intersections of the depth contour line(s) and the set of straight rays defined in this command RAY. These rays are characterized by a set of master rays defined by their start and end positions (xp,yp) and (xq,yq). Between each pair of sequential master rays thus defined SWAN generates int-1 intermediate rays by linear interpolation of the start and end positions.

Rays defined by this component have nothing in common with wave rays (e.g. as obtained from conventional refraction computations).

Note

Cannot be used in 1D-mode.

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).

Note

When using rays the input grid for bottom and water level should not be curvilinear.

Examples:

from rompy_swan.components.output import RAY
loc = RAY(
    rname="outray",
    xp1=171.9,
    yp1=-40.1,
    xq1=172.1,
    yq1=-39.9,
    npts=[3, 3],
    xp=[171.9, 173.9],
    yp=[-38.1, -38.1],
    xq=[172.1, 174.1],
    yq=[-37.9, -37.9],
)
print(loc.render())
RAY rname='outray' xp1=171.9 yp1=-40.1 xq1=172.1 yq1=-39.9 &
    int=3 xp=171.9 yp=-38.1 xq=172.1 yq=-37.9 &
    int=3 xp=173.9 yp=-38.1 xq=174.1 yq=-37.9

Fields:

Validators:

model_type pydantic-field

model_type: Literal['ray', 'RAY'] = 'ray'

Model type discriminator

rname pydantic-field

rname: str

Name of the set of rays defined by this command

xp1 pydantic-field

xp1: float

Problem coordinate of the begin point of the first master ray in the x-direction

yp1 pydantic-field

yp1: float

Problem coordinate of the begin point of the first master ray in the y-direction

xq1 pydantic-field

xq1: float

Problem coordinate of the end point of the first master ray in the x-direction

yq1 pydantic-field

yq1: float

Problem coordinate of the end point of the first master ray in the y-direction

npts pydantic-field

npts: list[int]

The int RAY parameter, number of subdivisions between the previous master ray and the following master ray defined by the following data (number of subdivisions is one morethan the number of interpolated rays)

xp pydantic-field

xp: list[float]

problem coordinates of the begin of each subsequent master ray in the x-direction

yp pydantic-field

yp: list[float]

problem coordinates of the begin of each subsequent master ray in the y-direction

xq pydantic-field

xq: list[float]

problem coordinates of the end of each subsequent master ray in the x-direction

yq pydantic-field

yq: list[float]

problem coordinates of the end of each subsequent master ray in the y-direction

ensure_equal_size pydantic-validator

ensure_equal_size() -> CURVE

cmd

cmd() -> str

Command file string for this component.

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

render

render(cmd: Optional[str | list] = None) -> str

Render the component to a string.

Parameters:

Name Type Description Default
cmd Optional[str | list]

Command string or list of command strings to render, by default self.cmd().

None

Returns:

Name Type Description
cdmstr str

The rendered command file component.

ISOLINE pydantic-model

ISOLINE(**data: Any)

Bases: BaseLocation

Output locations along a depth contour.

ISOLINE 'sname' 'rname' DEPTH|BOTTOM [dep]

With this optional command the user defines a set of output locations along one depth or bottom level contour line (in combination with command RAY).

Note

Cannot be used in 1D-mode.

Examples:

from rompy_swan.components.output import ISOLINE
loc = ISOLINE(sname="outcurve", rname="outray", dep_type="depth", dep=12.0)
print(loc.render())
ISOLINE sname='outcurve' rname='outray' DEPTH dep=12.0

Fields:

Validators:

model_type pydantic-field

model_type: Literal['isoline', 'ISOLINE'] = 'isoline'

Model type discriminator

rname pydantic-field

rname: str

Name of the set of rays defined by this command

dep pydantic-field

dep: float

The depth (in m) of the depth contour line along which output locations are generated by SWAN.

dep_type pydantic-field

dep_type: Optional[Literal['depth', 'bottom']] = None

Define if the depth contour is extracted from the DEPTH output (the stationary water depth) or from the BOTTOM output (the depth relative to the datum level with the water level ignored) (SWAN default: DEPTH)

sname pydantic-field

sname: SNAME_TYPE

Name of the set of output locations defined by this command

cmd

cmd() -> str

Command file string for this component.

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

render

render(cmd: Optional[str | list] = None) -> str

Render the component to a string.

Parameters:

Name Type Description Default
cmd Optional[str | list]

Command string or list of command strings to render, by default self.cmd().

None

Returns:

Name Type Description
cdmstr str

The rendered command file component.

not_special_name pydantic-validator

not_special_name(sname: str) -> str

Ensure sname is not defined as one of the special names.

POINTS pydantic-model

POINTS(**data: Any)

Bases: BaseLocation

Isolated output locations.

POINTS 'sname' < [xp] [yp] >

With this optional command the user defines a set of individual output point locations.

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:

from rompy_swan.components.output import POINTS
loc = POINTS(sname="outpts", xp=[172.3, 172.4], yp=[-39, -39])
print(loc.render())
POINTS sname='outpts' &
    xp=172.3 yp=-39.0 &
    xp=172.4 yp=-39.0

Fields:

Validators:

model_type pydantic-field

model_type: Literal['points', 'POINTS'] = 'points'

Model type discriminator

xp pydantic-field

problem coordinates of the points in the x-direction

yp pydantic-field

problem coordinates of the points in the y-direction

sname pydantic-field

sname: SNAME_TYPE

Name of the set of output locations defined by this command

ensure_equal_size pydantic-validator

ensure_equal_size() -> POINTS

cmd

cmd() -> str

Command file string for this component.

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

render

render(cmd: Optional[str | list] = None) -> str

Render the component to a string.

Parameters:

Name Type Description Default
cmd Optional[str | list]

Command string or list of command strings to render, by default self.cmd().

None

Returns:

Name Type Description
cdmstr str

The rendered command file component.

not_special_name pydantic-validator

not_special_name(sname: str) -> str

Ensure sname is not defined as one of the special names.

POINTS_FILE pydantic-model

POINTS_FILE(**data: Any)

Bases: BaseLocation

Isolated output locations.

POINTS 'sname' FILE 'fname'

With this optional command the user defines a set of individual output point locations from text file. The file should have one point per row with x-coordinates and y-coordinates in the first and second columns respectively.

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:

from rompy_swan.components.output import POINTS_FILE
loc = POINTS_FILE(sname="outpts", fname="./output_locations.txt")
print(loc.render())
POINTS sname='outpts' FILE fname='./output_locations.txt'

Fields:

Validators:

model_type pydantic-field

model_type: Literal["points_file", "POINTS_FILE"] = (
    "points_file"
)

Model type discriminator

fname pydantic-field

fname: str

Name of the file containing the output locations

sname pydantic-field

sname: SNAME_TYPE

Name of the set of output locations defined by this command

cmd

cmd() -> str

Command file string for this component.

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

render

render(cmd: Optional[str | list] = None) -> str

Render the component to a string.

Parameters:

Name Type Description Default
cmd Optional[str | list]

Command string or list of command strings to render, by default self.cmd().

None

Returns:

Name Type Description
cdmstr str

The rendered command file component.

not_special_name pydantic-validator

not_special_name(sname: str) -> str

Ensure sname is not defined as one of the special names.

NGRID pydantic-model

NGRID(**data: Any)

Bases: BaseLocation

Output locations for a nested grid.

NGRID 'sname' [xpn] [ypn] [alpn] [xlenn] [ylenn] [mxn] [myn]

If the user wishes to carry out nested SWAN runs, a separate coarse-grid SWAN run is required. With this optional command NGRID, the user defines in the present coarse-grid run, a set of output locations along the boundary of the subsequent nested computational grid. The set of output locations thus defined is of the type NGRID.

Note

Command NESTOUT is required after this command NGRID to generate some data for the (subsequent) nested run.

Note

Cannot be used in 1D-mode.

Examples:

from rompy_swan.components.output import NGRID
loc = NGRID(
    sname="outnest",
    grid=dict(xp=173, yp=-40, xlen=2, ylen=2, mx=19, my=19),
)
print(loc.render())
NGRID sname='outnest' xpn=173.0 ypn=-40.0 alpn=0.0 xlenn=2.0 ylenn=2.0 mxn=19 myn=19

Fields:

Validators:

model_type pydantic-field

model_type: Literal['ngrid', 'NGRID'] = 'ngrid'

Model type discriminator

sname pydantic-field

sname: SNAME_TYPE = 'nest'

Name of the NGRID output component, overridden by the parent NEST component if used within one

grid pydantic-field

NGRID grid definition

grid_suffix pydantic-validator

grid_suffix(grid: GRIDREGULAR) -> GRIDREGULAR

cmd

cmd() -> str

Command file string for this component.

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

render

render(cmd: Optional[str | list] = None) -> str

Render the component to a string.

Parameters:

Name Type Description Default
cmd Optional[str | list]

Command string or list of command strings to render, by default self.cmd().

None

Returns:

Name Type Description
cdmstr str

The rendered command file component.

not_special_name pydantic-validator

not_special_name(sname: str) -> str

Ensure sname is not defined as one of the special names.

NGRID_UNSTRUCTURED pydantic-model

NGRID_UNSTRUCTURED(**data: Any)

Bases: BaseLocation

Output locations for a nested grid.

NGRID 'sname' UNSTRUCTURED ->TRIANGLE|EASYMESH 'fname'

If the user wishes to carry out nested SWAN runs, a separate coarse-grid SWAN run is required. With this optional command NGRID, the user defines in the present coarse-grid run, a set of output locations along the boundary of the subsequent nested computational grid. The set of output locations thus defined is of the type NGRID.

With this option the user indicates that the subsequent nested grid is unstructured Only grids generated by Triangle and Easymesh are supported by SWAN.

Note

Command NESTOUT is required after this command NGRID to generate some data for the (subsequent) nested run.

Examples:

from rompy_swan.components.output import NGRID_UNSTRUCTURED
loc = NGRID_UNSTRUCTURED(sname="outnest", kind="triangle", fname="ngrid.txt")
print(loc.render())
NGRID sname='outnest' UNSTRUCTURED TRIANGLE fname='ngrid.txt'

Fields:

Validators:

model_type pydantic-field

model_type: Literal[
    "ngrid_unstructured", "NGRID_UNSTRUCTURED"
] = "ngrid_unstructured"

Model type discriminator

sname pydantic-field

sname: SNAME_TYPE = 'nest'

Name of the NGRID output component, overridden by the parent NEST component if used within one

kind pydantic-field

kind: Optional[Literal["triangle", "easymesh"]] = "triangle"

Indicate if nested grid is generated by Triangle or Easymesh. The base name of the grid specified in the fname parameter is used internally by SWAN to define the .node and .ele files in case of the former or the .n and .e files in case of the latter.

fname pydantic-field

fname: str

Basename of the required files, i.e. without extension

cmd

cmd() -> str

Command file string for this component.

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

render

render(cmd: Optional[str | list] = None) -> str

Render the component to a string.

Parameters:

Name Type Description Default
cmd Optional[str | list]

Command string or list of command strings to render, by default self.cmd().

None

Returns:

Name Type Description
cdmstr str

The rendered command file component.

not_special_name pydantic-validator

not_special_name(sname: str) -> str

Ensure sname is not defined as one of the special names.

QUANTITY pydantic-model

QUANTITY(**data: Any)

Bases: BaseComponent

Define output settings.

QUANTITY < output > 'short' 'long' [lexp] [hexp] [excv] [power] [ref] &
    [fswell] [fmin] [fmax] ->PROBLEMCOORD|FRAME

Examples:
---------
QUANTITY Xp hexp=100.
QUANTITY HS TM01 RTMM10 excv=-9.
QUANTITY HS TM02 FSPR fmin=0.03 fmax=0.5
QUANTITY Hswell fswell=0.08
QUANTITY Per short='Tm-1,0' power=0.
QUANTITY Transp Force Frame

With this command the user can influence:

  • The naming of output quantities
  • The accuracy of writing output quantities
  • The definition of some output quantities
  • Reference direction for vectors
Note

The following data are accepted only in combination with some specific quantities:

  • power
  • ref
  • fswell
  • fmin
  • fmax
  • PROBLEMCOORD
  • FRAME
Note

PROBLEMCOORD: Vector components are relative to the x- and y-axes of the problem coordinate system (see command SET):

  • Directions are counterclockwise relative to the positive x-axis of the problem coordinate system if Cartesian direction convention is used.
  • Directions are relative to North (clockwise) if Nautical direction convention is used.
Note

FRAME: If output is requested on sets created by command FRAME or automatically (see command SET) (COMPGRID or BOTTGRID):

  • Vector components are relative to the x- and y-axes of the frame coordinate system.
  • Directions are counterclockwise relative to the positive x-axis of the frame coordinate system if Cartesian direction convention is used.
  • Directions are relative to North (clockwise) if Nautical direction convention is used.

Examples:

from rompy_swan.components.output import QUANTITY
quant = QUANTITY(output=["xp"], hexp=100)
print(quant.render())
quant = QUANTITY(output=["hsign", "tm01", "rtmm10"], excv=-9)
print(quant.render())
quant = QUANTITY(output=["hsign", "tm02", "fspr"], fmin=0.03, fmax=0.5)
print(quant.render())
quant = QUANTITY(output=["hsign"], fswell=0.08)
print(quant.render())
quant = QUANTITY(output=["per"], short="Tm-1,0", power=0)
print(quant.render())
quant = QUANTITY(output=["transp", "force"], coord="frame")
print(quant.render())
QUANTITY XP hexp=100.0
QUANTITY HSIGN TM01 RTMM10 excv=-9.0
QUANTITY HSIGN TM02 FSPR fmin=0.03 fmax=0.5
QUANTITY HSIGN fswell=0.08
QUANTITY PER short='Tm-1,0' power=0.0
QUANTITY TRANSP FORCE FRAME

Fields:

model_type pydantic-field

model_type: Literal['quantity', 'QUANTITY'] = 'quantity'

Model type discriminator

output pydantic-field

output: list[BlockOptions]

The output variables to define settings for

short pydantic-field

short: Optional[str] = None

Short name of the output quantity (e.g. the name in the heading of a table written by SWAN). If this option is not used, SWAN will use a realistic name

long pydantic-field

long: Optional[str] = None

Long name of the output quantity (e.g. the name in the heading of a block output written by SWAN). If this option is not used, SWAN will use a realistic name

lexp pydantic-field

lexp: Optional[float] = None

Lowest expected value of the output quantity

hexp pydantic-field

hexp: Optional[float] = None

Highest expected value of the output quantity; the highest expected value is used by SWAN to determine the number of decimals in a table with heading. So the QUANTITY command can be used in case the default number of decimals in a table is unsatisfactory

excv pydantic-field

excv: Optional[float] = None

In case there is no valid value (e.g. wave height in a dry point) this exception value is written in a table or block output

power pydantic-field

power: Optional[float] = None

power p appearing in the definition of PER, RPER and WLEN. Note that the value for power given for PER affects also the value of RPER; the power for WLEN is independent of that of PER or RPER (SWAN default: 1)

ref pydantic-field

ref: Optional[str] = None

Reference time used for the quantity TSEC. Default value: starting time of the first computation, except in cases where this is later than the time of the earliest input. In these cases, the time of the earliest input is used

fswell pydantic-field

fswell: Optional[float] = None

Upper limit of frequency range used for computing the quantity HSWELL (SWAN default: 0.1 Hz)

noswll pydantic-field

noswll: Optional[int] = None

Number of swells to output for watershed quantities

fmin pydantic-field

fmin: Optional[float] = None

Lower limit of frequency range used for computing integral parameters (SWAN Default: 0.0 Hz)

fmax pydantic-field

fmax: Optional[float] = None

Upper limit of frequency range used for computing integral parameters (SWAN default: 1000.0 Hz, acts as infinity)

coord pydantic-field

coord: Optional[Literal['problemcoord', 'frame']] = None

Define if vectors and directions refer to the problem coordinate system ('problemcoord') or sets created by command FRAME ('frame') (SWAN default: problemcoord)

cmd

cmd() -> str

Command file string for this component.

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

render

render(cmd: Optional[str | list] = None) -> str

Render the component to a string.

Parameters:

Name Type Description Default
cmd Optional[str | list]

Command string or list of command strings to render, by default self.cmd().

None

Returns:

Name Type Description
cdmstr str

The rendered command file component.

QUANTITIES pydantic-model

QUANTITIES(**data: Any)

Bases: BaseComponent

Define output settings for multiple output.

QUANTITY < output > ...
QUANTITY < output > ...
..

This component can be used to prescribe and render multiple QUANTITY components.

Examples

from rompy_swan.components.output import QUANTITY, QUANTITIES
q1 = QUANTITY(output=["xp"], hexp=100)
q2 = QUANTITY(output=["hsign", "tm01", "rtmm10"], excv=-9)
q3 = QUANTITY(output=["hsign", "tm02", "fspr"], fmin=0.03, fmax=0.5)
q4 = QUANTITY(output=["hsign"], fswell=0.08)
q5 = QUANTITY(output=["per"], short="Tm-1,0", power=0)
q6 = QUANTITY(output=["transp", "force"], coord="frame")
quantities = QUANTITIES(quantities=[q1, q2, q3, q4, q5, q6])
print(quantities.render())
QUANTITY XP hexp=100.0
QUANTITY HSIGN TM01 RTMM10 excv=-9.0
QUANTITY HSIGN TM02 FSPR fmin=0.03 fmax=0.5
QUANTITY HSIGN fswell=0.08
QUANTITY PER short='Tm-1,0' power=0.0
QUANTITY TRANSP FORCE FRAME

Fields:

model_type pydantic-field

model_type: Literal["quantities", "QUANTITIES"] = (
    "quantities"
)

Model type discriminator

quantities pydantic-field

quantities: list[QUANTITY]

QUANTITY components

cmd

cmd() -> list

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

render

render(cmd: Optional[str | list] = None) -> str

Render the component to a string.

Parameters:

Name Type Description Default
cmd Optional[str | list]

Command string or list of command strings to render, by default self.cmd().

None

Returns:

Name Type Description
cdmstr str

The rendered command file component.

OUTPUT_OPTIONS pydantic-model

OUTPUT_OPTIONS(**data: Any)

Bases: BaseComponent

Set format of output.

OUTPUT OPTIons 'comment' (TABLE [field]) (BLOCK [ndec] [len]) (SPEC [ndec])

This command enables the user to influence the format of block, table and spectral output.

Examples

from rompy_swan.components.output import OUTPUT_OPTIONS
opts = OUTPUT_OPTIONS(
    comment="!", field=10, ndec_block=4, len=20, ndec_spec=6,
)
print(opts.render())
OUTPUT OPTIONS comment='!' TABLE field=10 BLOCK ndec=4 len=20 SPEC ndec=6

Fields:

model_type pydantic-field

model_type: Literal["output_options", "OUTPUT_OPTIONS"] = (
    "output_options"
)

Model type discriminator

comment pydantic-field

comment: Optional[str] = None

Comment character used in comment lines in the output (SWAN default: %)

field pydantic-field

field: Optional[int] = None

Length of one data field in a table (SWAN default: 12)

ndec_block pydantic-field

ndec_block: Optional[int] = None

Number of decimals in block output (SWAN default: 4)

len pydantic-field

len: Optional[int] = None

Number of data on one line of block output (SWAN default: 6)

ndec_spec pydantic-field

ndec_spec: Optional[int] = None

Number of decimals in spectra output (SWAN default: 4)

cmd

cmd() -> str

Command file string for this component.

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

render

render(cmd: Optional[str | list] = None) -> str

Render the component to a string.

Parameters:

Name Type Description Default
cmd Optional[str | list]

Command string or list of command strings to render, by default self.cmd().

None

Returns:

Name Type Description
cdmstr str

The rendered command file component.

BaseWrite pydantic-model

BaseWrite(**data: Any)

Bases: BaseComponent, ABC

Base class for SWAN output writing.

{MODEL_TYPE} sname='sname'

This is the base class for all write components. It is not meant to be used directly.

Examples

from rompy_swan.components.output import BaseWrite
write = BaseWrite(
    sname="outgrid",
    fname="./output-grid.nc",
    times=dict(
        tbeg="2012-01-01T00:00:00",
        delt="PT30M",
        tfmt=1,
        dfmt="min",
        suffix="",
    )
)
print(write.render())

Fields:

Validators:

model_type pydantic-field

model_type: Literal['write', 'WRITE'] = 'write'

Model type discriminator

sname pydantic-field

sname: SNAME_TYPE

Name of the set of output locations in which the output is to be written

fname pydantic-field

fname: str

Name of the data file where the output is written to The file format is defined by the file extension, use .mat for MATLAB binary (single precision) or .nc for netCDF format. If any other extension is used the ASCII format is assumed

times pydantic-field

times: Optional[TimeRangeOpen] = None

Time specification if the user requires output at various times. If this option is not specified data will be written for the last time step of the computation

suffix property

suffix: str

validate_special_names pydantic-validator

validate_special_names() -> BaseWrite

validate_times pydantic-validator

validate_times() -> BaseWrite

cmd

cmd() -> str

Command file string for this component.

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

render

render(cmd: Optional[str | list] = None) -> str

Render the component to a string.

Parameters:

Name Type Description Default
cmd Optional[str | list]

Command string or list of command strings to render, by default self.cmd().

None

Returns:

Name Type Description
cdmstr str

The rendered command file component.

BLOCK pydantic-model

BLOCK(**data: Any)

Bases: BaseWrite

Write spatial distributions.

BLOCK 'sname' ->HEADER|NOHEADER 'fname' (LAYOUT [idla]) < output > &
    [unit] (OUTPUT [tbegblk] [deltblk]) SEC|MIN|HR|DAY

With this optional command the user indicates that one or more spatial distributions should be written to a file.

Note

The SWAN special frames 'BOTTGRID' or 'COMPGRID' can be set with the sname field.

Note

The text of the header indicates run identification (see command PROJECT), time, frame or group name ('sname'), variable and unit. The number of header lines is 8.

Note

Cannot be used in 1D-mode.

Examples:

from rompy_swan.components.output import BLOCK
block = BLOCK(sname="outgrid", fname="./depth-frame.nc", output=["depth"])
print(block.render())
block = BLOCK(
    sname="COMPGRID",
    header=False,
    fname="./output-grid.nc",
    idla=3,
    output=["hsign", "hswell", "dir", "tps", "tm01", "watlev", "qp"],
    times=dict(
        tbeg="2012-01-01T00:00:00",
        delt="PT30M",
        tfmt=1,
        dfmt="min",
        suffix="",
    )
)
print(block.render())
BLOCK sname='outgrid' fname='./depth-frame.nc' DEPTH
BLOCK sname='COMPGRID' NOHEADER fname='./output-grid.nc' LAYOUT idla=3 &
    HSIGN &
    HSWELL &
    DIR &
    TPS &
    TM01 &
    WATLEV &
    QP &
    OUTPUT tbegblk=20120101.000000 deltblk=30.0 MIN

Fields:

Validators:

model_type pydantic-field

model_type: Literal['block', 'BLOCK'] = 'block'

Model type discriminator

header pydantic-field

header: Optional[bool] = None

Indicate if the output should be written to a file with header lines (SWAN default: True)

idla pydantic-field

idla: Optional[IDLA] = None

Prescribe the lay-out of the output to file (supported options here are 1, 3, 4). Option 4 is recommended for postprocessing an ASCII file by MATLAB, however option 3 is recommended in case of binary MATLAB output (SWAN default: 1)

output pydantic-field

output: list[BlockOptions]

The output variables to output to block file

unit pydantic-field

unit: Optional[float] = None

Controls the scaling of the output. The program divides computed values by unit before writing to file, so the user should multiply the written value by unit to obtain the proper value. By default, if HEADER is selected, value is written as a 5 position integer. SWAN takes unit such that the largest number occurring in the block can be printed. If NOHEADER is selected, values are printed in floating-point format by default (unit=1)

suffix property

suffix: str

sname pydantic-field

sname: SNAME_TYPE

Name of the set of output locations in which the output is to be written

fname pydantic-field

fname: str

Name of the data file where the output is written to The file format is defined by the file extension, use .mat for MATLAB binary (single precision) or .nc for netCDF format. If any other extension is used the ASCII format is assumed

times pydantic-field

times: Optional[TimeRangeOpen] = None

Time specification if the user requires output at various times. If this option is not specified data will be written for the last time step of the computation

validate_idla pydantic-validator

validate_idla(idla: IDLA) -> IDLA

cmd

cmd() -> str

Command file string for this component.

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

render

render(cmd: Optional[str | list] = None) -> str

Render the component to a string.

Parameters:

Name Type Description Default
cmd Optional[str | list]

Command string or list of command strings to render, by default self.cmd().

None

Returns:

Name Type Description
cdmstr str

The rendered command file component.

validate_special_names pydantic-validator

validate_special_names() -> BaseWrite

validate_times pydantic-validator

validate_times() -> BaseWrite

BLOCKS pydantic-model

BLOCKS(**data: Any)

Bases: MultiComponents

Write multiple spatial distributions.

BLOCK 'sname' ->HEADER|NOHEADER 'fname1' (LAYOUT [idla]) < output > &
    [unit] (OUTPUT [tbegblk] [deltblk]) SEC|MIN|HR|DAY
BLOCK 'sname' ->HEADER|NOHEADER 'fname2' (LAYOUT [idla]) < output > &
    [unit] (OUTPUT [tbegblk] [deltblk]) SEC|MIN|HR|DAY
..

This component can be used to prescribe and render multiple BLOCK components.

Examples

from rompy_swan.components.output import BLOCK, BLOCKS
block1 = BLOCK(sname="outgrid", fname="./depth.txt", output=["depth"])
block2 = BLOCK(sname="outgrid", fname="./output.nc", output=["hsign", "hswell"])
blocks = BLOCKS(components=[block1, block2])
print(blocks.render())
BLOCK sname='outgrid' fname='./depth.txt' DEPTH
BLOCK sname='outgrid' fname='./output.nc' &
    HSIGN &
    HSWELL

Fields:

model_type pydantic-field

model_type: Literal['blocks'] = 'blocks'

Model type discriminator

components pydantic-field

components: list[BLOCK]

BLOCK components

sname property

sname: list[str]

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

cmd

cmd() -> list[str]

render

render(cmd: Optional[str | list] = None) -> str

Render the component to a string.

Parameters:

Name Type Description Default
cmd Optional[str | list]

Command string or list of command strings to render, by default self.cmd().

None

Returns:

Name Type Description
cdmstr str

The rendered command file component.

TABLE pydantic-model

TABLE(**data: Any)

Bases: BaseWrite

Write spatial distributions.

TABLE 'sname' ->HEADER|NOHEADER|INDEXED 'fname'  < output > &
    (OUTPUT [tbegblk] [deltblk]) SEC|MIN|HR|DAY

With this optional command the user indicates that for each location of the output location set 'sname' (see commands POINTS, CURVE, FRAME or GROUP) one or more variables should be written to a file. The keywords HEADER and NOHEADER determine the appearance of the table; the filename determines the destination of the data.

Note

HEADER: output is written in fixed format to file with headers giving name of variable and unit per column (numbers too large to be written will be shown as ****. The number of header lines is 4.

NOHEADER: output is written in floating point format to file and has no headers.

INDEXED: output compatible with GIS tools such as ARCVIEW, ARCINFO, etc. The user should give two TABLE commands, one to produce one file with XP and YP as output quantities, the other with HS, RTM01 or other output quantities.

Examples:

from rompy_swan.components.output import TABLE
table = TABLE(
    sname="outpts",
    format="noheader",
    fname="./output_table.nc",
    output=["hsign", "hswell", "dir", "tps", "tm01", "watlev", "qp"],
    times=dict(tbeg="2012-01-01T00:00:00", delt="PT30M", dfmt="min"),
)
print(table.render())
TABLE sname='outpts' NOHEADER fname='./output_table.nc' &
    HSIGN &
    HSWELL &
    DIR &
    TPS &
    TM01 &
    WATLEV &
    QP &
    OUTPUT tbegtbl=20120101.000000 delttbl=30.0 MIN

Fields:

Validators:

model_type pydantic-field

model_type: Literal['table', 'TABLE'] = 'table'

Model type discriminator

format pydantic-field

format: Optional[
    Literal["header", "noheader", "indexed"]
] = None

Indicate if the table should be written to a file as a HEADER, NOHEADER or INDEXED table format (SWAN default: HEADER)

output pydantic-field

output: list[BlockOptions]

The output variables to output to block file

suffix property

suffix: str

sname pydantic-field

sname: SNAME_TYPE

Name of the set of output locations in which the output is to be written

fname pydantic-field

fname: str

Name of the data file where the output is written to The file format is defined by the file extension, use .mat for MATLAB binary (single precision) or .nc for netCDF format. If any other extension is used the ASCII format is assumed

times pydantic-field

times: Optional[TimeRangeOpen] = None

Time specification if the user requires output at various times. If this option is not specified data will be written for the last time step of the computation

cmd

cmd() -> str

Command file string for this component.

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

render

render(cmd: Optional[str | list] = None) -> str

Render the component to a string.

Parameters:

Name Type Description Default
cmd Optional[str | list]

Command string or list of command strings to render, by default self.cmd().

None

Returns:

Name Type Description
cdmstr str

The rendered command file component.

validate_special_names pydantic-validator

validate_special_names() -> BaseWrite

validate_times pydantic-validator

validate_times() -> BaseWrite

SPECOUT pydantic-model

SPECOUT(**data: Any)

Bases: BaseWrite

Write to data file the wave spectra.

SPECOUT 'sname' SPEC1D|->SPEC2D ->ABS|REL 'fname' &
    (OUTPUT [tbeg] [delt] SEC|MIN|HR|DAY)

With this optional command the user indicates that for each location of the output location set 'sname' (see commands POINTS, CURVE, FRAME or GROUP) the 1D or 2D variance / energy (see command SET) density spectrum (either the relative frequency or the absolute frequency spectrum) is to be written to a data file.

Note

This write command supports the following location types: POINTS, CURVE, FRAME and GROUP.

Note

This output file can be used for defining boundary conditions for subsequent SWAN runs (command BOUNDSPEC).

Examples:

from rompy_swan.components.output import SPECOUT
out = SPECOUT(sname="outpts", fname="./specout.swn")
print(out.render())
out = SPECOUT(
    sname="outpts",
    dim=dict(model_type="spec2d"),
    freq=dict(model_type="rel"),
    fname="./specout.nc",
    times=dict(tbeg="2012-01-01T00:00:00", delt="PT30M", dfmt="min"),
)
print(out.render())
SPECOUT sname='outpts' fname='./specout.swn'
SPECOUT sname='outpts' SPEC2D REL fname='./specout.nc' OUTPUT tbegspc=20120101.000000 deltspc=30.0 MIN

Fields:

Validators:

model_type pydantic-field

model_type: Literal['specout', 'SPECOUT'] = 'specout'

Model type discriminator

dim pydantic-field

dim: Optional[DIM_TYPE] = None

freq pydantic-field

freq: Optional[FREQ_TYPE] = None

suffix property

suffix: str

sname pydantic-field

sname: SNAME_TYPE

Name of the set of output locations in which the output is to be written

fname pydantic-field

fname: str

Name of the data file where the output is written to The file format is defined by the file extension, use .mat for MATLAB binary (single precision) or .nc for netCDF format. If any other extension is used the ASCII format is assumed

times pydantic-field

times: Optional[TimeRangeOpen] = None

Time specification if the user requires output at various times. If this option is not specified data will be written for the last time step of the computation

cmd

cmd() -> str

Command file string for this component.

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

render

render(cmd: Optional[str | list] = None) -> str

Render the component to a string.

Parameters:

Name Type Description Default
cmd Optional[str | list]

Command string or list of command strings to render, by default self.cmd().

None

Returns:

Name Type Description
cdmstr str

The rendered command file component.

validate_special_names pydantic-validator

validate_special_names() -> BaseWrite

validate_times pydantic-validator

validate_times() -> BaseWrite

NESTOUT pydantic-model

NESTOUT(**data: Any)

Bases: BaseWrite

Write to 2D boundary spectra.

NESTOUT 'sname' 'fname' (OUTPUT [tbegnst] [deltnst] ->SEC|MIN|HR|DAY)

Write to data file two-dimensional action density spectra (relative frequency) along the boundary of a nested grid (see command NGRID) to be used in a subsequent SWAN run.

Note

Cannot be used in 1D-mode.

Examples:

from rompy_swan.components.output import NESTOUT
out = NESTOUT(
    sname="outnest",
    fname="./nestout.swn",
    times=dict(tbeg="2012-01-01T00:00:00", delt="PT30M", dfmt="min"),
)
print(out.render())
NESTOUT sname='outnest' fname='./nestout.swn' OUTPUT tbegnst=20120101.000000 deltnst=30.0 MIN

Fields:

Validators:

model_type pydantic-field

model_type: Literal['nestout', 'NESTOUT'] = 'nestout'

Model type discriminator

sname pydantic-field

sname: SNAME_TYPE = 'nest'

Name of the NESTOUT output component, overridden by the parent NEST component if used within one

suffix property

suffix: str

fname pydantic-field

fname: str

Name of the data file where the output is written to The file format is defined by the file extension, use .mat for MATLAB binary (single precision) or .nc for netCDF format. If any other extension is used the ASCII format is assumed

times pydantic-field

times: Optional[TimeRangeOpen] = None

Time specification if the user requires output at various times. If this option is not specified data will be written for the last time step of the computation

cmd

cmd() -> str

Command file string for this component.

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

render

render(cmd: Optional[str | list] = None) -> str

Render the component to a string.

Parameters:

Name Type Description Default
cmd Optional[str | list]

Command string or list of command strings to render, by default self.cmd().

None

Returns:

Name Type Description
cdmstr str

The rendered command file component.

validate_special_names pydantic-validator

validate_special_names() -> BaseWrite

validate_times pydantic-validator

validate_times() -> BaseWrite

NEST pydantic-model

NEST(**data: Any)

Bases: BaseComponent

Coupled NGRID and NESTOUT component for nested runs.

NGRID 'sname' ...
NESTOUT 'sname' ...

This component couples together an NGRID location definition with its corresponding NESTOUT write command. This ensures that nested grid outputs are properly paired and allows multiple nested grids to be defined in a single model configuration.

Note

The sname field is automatically assigned to both the NGRID and NESTOUT components to ensure they are properly linked.

Examples:

from rompy_swan.components.output import NEST
nest = NEST(
    sname="child1",
    ngrid=dict(
        model_type="ngrid",
        grid=dict(xp=167.0, yp=-45.5, xlen=0.1, ylen=0.1, mx=12, my=14),
    ),
    nestout=dict(
        fname="nestout_child1.swn",
        times=dict(tfmt=1, dfmt="hr"),
    ),
)
print(nest.render())
NGRID sname='child1' xpn=167.0 ypn=-45.5 alpn=0.0 xlenn=0.1 ylenn=0.1 mxn=12 myn=14
NESTOUT sname='child1' fname='nestout_child1.swn' OUTPUT tbegnst=19700101.000000 deltnst=1.0 HR

Fields:

Validators:

model_type pydantic-field

model_type: Literal['nest', 'NEST'] = 'nest'

Model type discriminator

sname pydantic-field

sname: SNAME_TYPE

Name of the nested grid (used for both NGRID and NESTOUT)

ngrid pydantic-field

NGRID location component defining the nested grid boundary

nestout pydantic-field

nestout: NESTOUT

NESTOUT write component for the nested grid boundary spectra

not_special_name pydantic-validator

not_special_name(sname: str) -> str

Ensure sname is not defined as one of the special names.

warn_sname_override pydantic-validator

warn_sname_override() -> NEST

Warn if the user explicitly set a different sname on child components.

set_sname pydantic-validator

set_sname() -> NEST

Set sname on child components from the parent NEST sname.

cmd

cmd() -> list

Command file strings for this component.

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

render

render(cmd: Optional[str | list] = None) -> str

Render the component to a string.

Parameters:

Name Type Description Default
cmd Optional[str | list]

Command string or list of command strings to render, by default self.cmd().

None

Returns:

Name Type Description
cdmstr str

The rendered command file component.

TEST pydantic-model

TEST(**data: Any)

Bases: BaseComponent

Write intermediate results.

TEST [itest] [itrace] POINTS XY|IJ (PAR 'fname') (S1D 'fname') (S2D 'fname')
Note

The 6 source terms written due to the presence of the keyword S1D or S2D are: wind input, whitecapping, bottom friction, breaking, 3- and 4- wave interactions.

Examples:

from rompy_swan.components.output import TEST
test = TEST(
    itest=10,
    points=dict(model_type="ij", i=[0, 0], j=[10, 20]),
    fname_par="integral_parameters.test",
    fname_s1d="1d_variance_density.test",
    fname_s2d="2d_variance_density.test",
)
print(test.render())
import numpy as np
test = TEST(
    points=dict(
        model_type="xy",
        x=np.linspace(172.5, 174.0, 25),
        y=25*[-38],
    ),
    fname_s2d="2d_variance_density.test",
)
print(test.render())
TEST itest=10 POINTS IJ &
    i=0 j=10 &
    i=0 j=20 &
    PAR fname='integral_parameters.test' S1D fname='1d_variance_density.test' S2D fname='2d_variance_density.test'
TEST POINTS XY &
    172.50000000 -38.00000000 &
    172.56250000 -38.00000000 &
    172.62500000 -38.00000000 &
    172.68750000 -38.00000000 &
    172.75000000 -38.00000000 &
    172.81250000 -38.00000000 &
    172.87500000 -38.00000000 &
    172.93750000 -38.00000000 &
    173.00000000 -38.00000000 &
    173.06250000 -38.00000000 &
    173.12500000 -38.00000000 &
    173.18750000 -38.00000000 &
    173.25000000 -38.00000000 &
    173.31250000 -38.00000000 &
    173.37500000 -38.00000000 &
    173.43750000 -38.00000000 &
    173.50000000 -38.00000000 &
    173.56250000 -38.00000000 &
    173.62500000 -38.00000000 &
    173.68750000 -38.00000000 &
    173.75000000 -38.00000000 &
    173.81250000 -38.00000000 &
    173.87500000 -38.00000000 &
    173.93750000 -38.00000000 &
    174.00000000 -38.00000000 &
    S2D fname='2d_variance_density.test'

TODO: Support k in POINTS IJ.

Fields:

Validators:

model_type pydantic-field

model_type: Literal['test', 'TEST'] = 'test'

Model type discriminator

itest pydantic-field

itest: Optional[int] = None

The level of test output, for values under 100 the amount is usually reasonable, for values above 200 it can be very large. Values of up to 50 can be interpreted by the user (SWAN default: 1)

itrace pydantic-field

itrace: Optional[int] = None

SWAN writes a message (name of subroutine) to the PRINT file at the first itrace entries of each subroutine (SWAN default: 0)

points pydantic-field

points: Union[XY, IJ]

Points where detailed print output is produced (max of 50 points)

fname_par pydantic-field

fname_par: Optional[str] = None

Name of the file where the integral parameters are written to

fname_s1d pydantic-field

fname_s1d: Optional[str] = None

Name of the file where the 1D variance density and 6 source terms are written to

fname_s2d pydantic-field

fname_s2d: Optional[str] = None

Name of the file where the 2D variance density and 6 source terms are written to

validate_points pydantic-validator

validate_points(points: Union[XY, IJ]) -> Union[XY, IJ]

at_least_one pydantic-validator

at_least_one() -> TEST

Warns if no test file is being specified.

cmd

cmd() -> str

Command file string for this component.

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

render

render(cmd: Optional[str | list] = None) -> str

Render the component to a string.

Parameters:

Name Type Description Default
cmd Optional[str | list]

Command string or list of command strings to render, by default self.cmd().

None

Returns:

Name Type Description
cdmstr str

The rendered command file component.