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.
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.
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())
Fields:
-
model_type(Literal['locations', 'LOCATIONS']) -
sname(SNAME_TYPE)
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
¶
Ensure sname is not defined as one of the special names.
check_for_typos
classmethod
¶
Suggest the closest field name for an unknown input key.
A field can be given by its name or, like in pydantic, by its alias.
render
¶
FRAME
pydantic-model
¶
FRAME(**data: Any)
Bases: BaseLocation
Output locations on a regular grid.
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())
Fields:
-
sname(SNAME_TYPE) -
model_type(Literal['frame', 'FRAME']) -
grid(GRIDREGULAR)
Validators:
model_type
pydantic-field
¶
model_type: Literal['frame', 'FRAME'] = 'frame'
Model type discriminator
sname
pydantic-field
¶
sname: SNAME_TYPE
Name of the set of output locations defined by this command
check_for_typos
classmethod
¶
Suggest the closest field name for an unknown input key.
A field can be given by its name or, like in pydantic, by its alias.
render
¶
GROUP
pydantic-model
¶
GROUP(**data: Any)
Bases: BaseLocation
Output locations on subset of a grid.
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())
Fields:
Validators:
model_type
pydantic-field
¶
model_type: Literal['group', 'GROUP'] = 'group'
Model type discriminator
sname
pydantic-field
¶
sname: SNAME_TYPE
Name of the set of output locations defined by this command
check_for_typos
classmethod
¶
Suggest the closest field name for an unknown input key.
A field can be given by its name or, like in pydantic, by its alias.
render
¶
CURVE
pydantic-model
¶
CURVE(**data: Any)
Bases: BaseLocation
Output locations along a curve.
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())
Fields:
-
sname(SNAME_TYPE) -
model_type(Literal['curve', 'CURVE']) -
xp1(float) -
yp1(float) -
npts(list[int]) -
xp(list[float]) -
yp(list[float])
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
¶
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
¶
problem coordinates of a corner point of the curve in the x-direction
yp
pydantic-field
¶
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
check_for_typos
classmethod
¶
Suggest the closest field name for an unknown input key.
A field can be given by its name or, like in pydantic, by its alias.
render
¶
CURVES
pydantic-model
¶
CURVES(**data: Any)
Bases: BaseComponent
Output locations along multiple curves.
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(Literal['curves', 'CURVES']) -
curves(list[CURVE])
RAY
pydantic-model
¶
RAY(**data: Any)
Bases: BaseComponent
Output locations along a depth contour.
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:
-
model_type(Literal['ray', 'RAY']) -
rname(str) -
xp1(float) -
yp1(float) -
xq1(float) -
yq1(float) -
npts(list[int]) -
xp(list[float]) -
yp(list[float]) -
xq(list[float]) -
yq(list[float])
Validators:
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
¶
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
¶
problem coordinates of the begin of each subsequent master ray in the x-direction
yp
pydantic-field
¶
problem coordinates of the begin of each subsequent master ray in the y-direction
xq
pydantic-field
¶
problem coordinates of the end of each subsequent master ray in the x-direction
yq
pydantic-field
¶
problem coordinates of the end of each subsequent master ray in the y-direction
check_for_typos
classmethod
¶
Suggest the closest field name for an unknown input key.
A field can be given by its name or, like in pydantic, by its alias.
render
¶
ISOLINE
pydantic-model
¶
ISOLINE(**data: Any)
Bases: BaseLocation
Output locations along a depth contour.
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())
Fields:
-
sname(SNAME_TYPE) -
model_type(Literal['isoline', 'ISOLINE']) -
rname(str) -
dep(float) -
dep_type(Optional[Literal['depth', 'bottom']])
Validators:
model_type
pydantic-field
¶
model_type: Literal['isoline', 'ISOLINE'] = 'isoline'
Model type discriminator
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
¶
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
check_for_typos
classmethod
¶
Suggest the closest field name for an unknown input key.
A field can be given by its name or, like in pydantic, by its alias.
render
¶
POINTS
pydantic-model
¶
POINTS(**data: Any)
Bases: BaseLocation
Isolated output locations.
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())
Fields:
-
sname(SNAME_TYPE) -
model_type(Literal['points', 'POINTS']) -
xp(Optional[list[float]]) -
yp(Optional[list[float]])
Validators:
model_type
pydantic-field
¶
model_type: Literal['points', 'POINTS'] = 'points'
Model type discriminator
sname
pydantic-field
¶
sname: SNAME_TYPE
Name of the set of output locations defined by this command
check_for_typos
classmethod
¶
Suggest the closest field name for an unknown input key.
A field can be given by its name or, like in pydantic, by its alias.
render
¶
POINTS_FILE
pydantic-model
¶
POINTS_FILE(**data: Any)
Bases: BaseLocation
Isolated output locations.
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())
Fields:
-
sname(SNAME_TYPE) -
model_type(Literal['points_file', 'POINTS_FILE']) -
fname(str)
Validators:
model_type
pydantic-field
¶
model_type: Literal["points_file", "POINTS_FILE"] = (
"points_file"
)
Model type discriminator
sname
pydantic-field
¶
sname: SNAME_TYPE
Name of the set of output locations defined by this command
check_for_typos
classmethod
¶
Suggest the closest field name for an unknown input key.
A field can be given by its name or, like in pydantic, by its alias.
render
¶
NGRID
pydantic-model
¶
NGRID(**data: Any)
Bases: BaseLocation
Output locations for a nested grid.
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())
Fields:
-
model_type(Literal['ngrid', 'NGRID']) -
sname(SNAME_TYPE) -
grid(GRIDREGULAR)
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
check_for_typos
classmethod
¶
Suggest the closest field name for an unknown input key.
A field can be given by its name or, like in pydantic, by its alias.
render
¶
NGRID_UNSTRUCTURED
pydantic-model
¶
NGRID_UNSTRUCTURED(**data: Any)
Bases: BaseLocation
Output locations for a nested grid.
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())
Fields:
-
model_type(Literal['ngrid_unstructured', 'NGRID_UNSTRUCTURED']) -
sname(SNAME_TYPE) -
kind(Optional[Literal['triangle', 'easymesh']]) -
fname(str)
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
¶
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.
check_for_typos
classmethod
¶
Suggest the closest field name for an unknown input key.
A field can be given by its name or, like in pydantic, by its alias.
render
¶
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(Literal['quantity', 'QUANTITY']) -
output(list[BlockOptions]) -
short(Optional[str]) -
long(Optional[str]) -
lexp(Optional[float]) -
hexp(Optional[float]) -
excv(Optional[float]) -
power(Optional[float]) -
ref(Optional[str]) -
fswell(Optional[float]) -
noswll(Optional[int]) -
fmin(Optional[float]) -
fmax(Optional[float]) -
coord(Optional[Literal['problemcoord', 'frame']])
model_type
pydantic-field
¶
model_type: Literal['quantity', 'QUANTITY'] = 'quantity'
Model type discriminator
short
pydantic-field
¶
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 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
hexp
pydantic-field
¶
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
¶
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 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
¶
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
¶
Upper limit of frequency range used for computing the quantity HSWELL (SWAN default: 0.1 Hz)
noswll
pydantic-field
¶
Number of swells to output for watershed quantities
fmin
pydantic-field
¶
Lower limit of frequency range used for computing integral parameters (SWAN Default: 0.0 Hz)
fmax
pydantic-field
¶
Upper limit of frequency range used for computing integral parameters (SWAN default: 1000.0 Hz, acts as infinity)
coord
pydantic-field
¶
Define if vectors and directions refer to the problem coordinate system ('problemcoord') or sets created by command FRAME ('frame') (SWAN default: problemcoord)
check_for_typos
classmethod
¶
Suggest the closest field name for an unknown input key.
A field can be given by its name or, like in pydantic, by its alias.
render
¶
QUANTITIES
pydantic-model
¶
QUANTITIES(**data: Any)
Bases: BaseComponent
Define output settings for multiple 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(Literal['quantities', 'QUANTITIES']) -
quantities(list[QUANTITY])
OUTPUT_OPTIONS
pydantic-model
¶
OUTPUT_OPTIONS(**data: Any)
Bases: BaseComponent
Set format of output.
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())
Fields:
-
model_type(Literal['output_options', 'OUTPUT_OPTIONS']) -
comment(Optional[str]) -
field(Optional[int]) -
ndec_block(Optional[int]) -
len(Optional[int]) -
ndec_spec(Optional[int])
model_type
pydantic-field
¶
model_type: Literal["output_options", "OUTPUT_OPTIONS"] = (
"output_options"
)
Model type discriminator
comment
pydantic-field
¶
Comment character used in comment lines in the output (SWAN default: %)
field
pydantic-field
¶
Length of one data field in a table (SWAN default: 12)
ndec_block
pydantic-field
¶
Number of decimals in block output (SWAN default: 4)
len
pydantic-field
¶
Number of data on one line of block output (SWAN default: 6)
ndec_spec
pydantic-field
¶
Number of decimals in spectra output (SWAN default: 4)
check_for_typos
classmethod
¶
Suggest the closest field name for an unknown input key.
A field can be given by its name or, like in pydantic, by its alias.
render
¶
BaseWrite
pydantic-model
¶
BaseWrite(**data: Any)
Bases: BaseComponent, ABC
Base class for SWAN output writing.
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:
-
model_type(Literal['write', 'WRITE']) -
sname(SNAME_TYPE) -
fname(str) -
times(Optional[TimeRangeOpen])
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
check_for_typos
classmethod
¶
Suggest the closest field name for an unknown input key.
A field can be given by its name or, like in pydantic, by its alias.
render
¶
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:
-
sname(SNAME_TYPE) -
fname(str) -
times(Optional[TimeRangeOpen]) -
model_type(Literal['block', 'BLOCK']) -
header(Optional[bool]) -
idla(Optional[IDLA]) -
output(list[BlockOptions]) -
unit(Optional[float])
Validators:
model_type
pydantic-field
¶
model_type: Literal['block', 'BLOCK'] = 'block'
Model type discriminator
header
pydantic-field
¶
Indicate if the output should be written to a file with header lines (SWAN default: True)
idla
pydantic-field
¶
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)
unit
pydantic-field
¶
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)
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
check_for_typos
classmethod
¶
Suggest the closest field name for an unknown input key.
A field can be given by its name or, like in pydantic, by its alias.
render
¶
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(Literal['blocks']) -
components(list[BLOCK])
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:
-
sname(SNAME_TYPE) -
fname(str) -
times(Optional[TimeRangeOpen]) -
model_type(Literal['table', 'TABLE']) -
format(Optional[Literal['header', 'noheader', 'indexed']]) -
output(list[BlockOptions])
Validators:
model_type
pydantic-field
¶
model_type: Literal['table', 'TABLE'] = 'table'
Model type discriminator
format
pydantic-field
¶
Indicate if the table should be written to a file as a HEADER, NOHEADER or INDEXED table format (SWAN default: HEADER)
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
check_for_typos
classmethod
¶
Suggest the closest field name for an unknown input key.
A field can be given by its name or, like in pydantic, by its alias.
render
¶
SPECOUT
pydantic-model
¶
SPECOUT(**data: Any)
Bases: BaseWrite
Write to data file the wave spectra.
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:
-
sname(SNAME_TYPE) -
fname(str) -
times(Optional[TimeRangeOpen]) -
model_type(Literal['specout', 'SPECOUT']) -
dim(Optional[DIM_TYPE]) -
freq(Optional[FREQ_TYPE])
Validators:
model_type
pydantic-field
¶
model_type: Literal['specout', 'SPECOUT'] = 'specout'
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
check_for_typos
classmethod
¶
Suggest the closest field name for an unknown input key.
A field can be given by its name or, like in pydantic, by its alias.
render
¶
NESTOUT
pydantic-model
¶
NESTOUT(**data: Any)
Bases: BaseWrite
Write to 2D boundary spectra.
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())
Fields:
-
fname(str) -
times(Optional[TimeRangeOpen]) -
model_type(Literal['nestout', 'NESTOUT']) -
sname(SNAME_TYPE)
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
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
check_for_typos
classmethod
¶
Suggest the closest field name for an unknown input key.
A field can be given by its name or, like in pydantic, by its alias.
render
¶
NEST
pydantic-model
¶
NEST(**data: Any)
Bases: BaseComponent
Coupled NGRID and NESTOUT component for nested runs.
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:
-
model_type(Literal['nest', 'NEST']) -
sname(SNAME_TYPE) -
ngrid(Union[NGRID, NGRID_UNSTRUCTURED]) -
nestout(NESTOUT)
Validators:
ngrid
pydantic-field
¶
ngrid: Union[NGRID, NGRID_UNSTRUCTURED]
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
¶
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.
check_for_typos
classmethod
¶
Suggest the closest field name for an unknown input key.
A field can be given by its name or, like in pydantic, by its alias.
render
¶
TEST
pydantic-model
¶
TEST(**data: Any)
Bases: BaseComponent
Write intermediate results.
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:
-
model_type(Literal['test', 'TEST']) -
itest(Optional[int]) -
itrace(Optional[int]) -
points(Union[XY, IJ]) -
fname_par(Optional[str]) -
fname_s1d(Optional[str]) -
fname_s2d(Optional[str])
Validators:
itest
pydantic-field
¶
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
¶
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 where detailed print output is produced (max of 50 points)
fname_par
pydantic-field
¶
Name of the file where the integral parameters are written to
fname_s1d
pydantic-field
¶
Name of the file where the 1D variance density and 6 source terms are written to
fname_s2d
pydantic-field
¶
Name of the file where the 2D variance density and 6 source terms are written to
check_for_typos
classmethod
¶
Suggest the closest field name for an unknown input key.
A field can be given by its name or, like in pydantic, by its alias.