Output
SWAN output commands
Locations
BaseLocation
Bases: BaseComponent, ABC
Base class for SWAN output locations.
.. code-block:: text
{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
.. ipython:: python :okwarning:
from rompy_swan.components.output import BaseLocation
loc = BaseLocation(sname="outsites")
print(loc.render())
Source code in rompy_swan/components/output.py
Attributes
model_type
class-attribute
instance-attribute
model_type: Literal['locations', 'LOCATIONS'] = Field(default='locations', description='Model type discriminator')
sname
class-attribute
instance-attribute
sname: str = Field(description='Name of the set of output locations defined by this command', max_length=8)
Functions
not_special_name
classmethod
Ensure sname is not defined as one of the special names.
Source code in rompy_swan/components/output.py
FRAME
Bases: BaseLocation
Output locations on a regular grid.
.. code-block:: text
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
.. ipython:: python :okwarning:
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())
Source code in rompy_swan/components/output.py
Attributes
model_type
class-attribute
instance-attribute
model_type: Literal['frame', 'FRAME'] = Field(default='frame', description='Model type discriminator')
grid
class-attribute
instance-attribute
grid: GRIDREGULAR = Field(description='Frame grid definition')
Functions
grid_suffix
classmethod
grid_suffix(grid: GRIDREGULAR) -> GRIDREGULAR
GROUP
Bases: BaseLocation
Output locations on subset of a grid.
.. code-block:: text
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
.. ipython:: python :okwarning:
from rompy_swan.components.output import GROUP
loc = GROUP(sname="subgrid", ix1=20, iy1=0, ix2=50, iy2=100)
print(loc.render())
Source code in rompy_swan/components/output.py
Attributes
model_type
class-attribute
instance-attribute
model_type: Literal['group', 'GROUP'] = Field(default='group', description='Model type discriminator')
ix1
class-attribute
instance-attribute
iy1
class-attribute
instance-attribute
ix2
class-attribute
instance-attribute
iy2
class-attribute
instance-attribute
Functions
cmd
CURVE
Bases: BaseLocation
Output locations along a curve.
.. code-block:: text
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
.. ipython:: python :okwarning:
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())
Source code in rompy_swan/components/output.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | |
Attributes
model_type
class-attribute
instance-attribute
model_type: Literal['curve', 'CURVE'] = Field(default='curve', description='Model type discriminator')
xp1
class-attribute
instance-attribute
xp1: float = Field(description='Problem coordinate of the first point of the curve in the x-direction')
yp1
class-attribute
instance-attribute
yp1: float = Field(description='Problem coordinate of the first point of the curve in the y-direction')
npts
class-attribute
instance-attribute
npts: list[int] = Field(description='The `int` CURVE parameter, SWAN will generate `npts-1` equidistant locations between two subsequent corner points of the curve including the two corner points', min_length=1)
xp
class-attribute
instance-attribute
xp: list[float] = Field(description='problem coordinates of a corner point of the curve in the x-direction', min_length=1)
yp
class-attribute
instance-attribute
yp: list[float] = Field(description='problem coordinates of a corner point of the curve in the y-direction', min_length=1)
Functions
ensure_equal_size
ensure_equal_size() -> CURVE
cmd
Command file string for this component.
CURVES
Bases: BaseComponent
Output locations along multiple curves.
.. code-block:: text
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
.. ipython:: python :okwarning:
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())
Source code in rompy_swan/components/output.py
Attributes
model_type
class-attribute
instance-attribute
model_type: Literal['curves', 'CURVES'] = Field(default='curves', description='Model type discriminator')
curves
class-attribute
instance-attribute
curves: list[CURVE] = Field(description='CURVE components')
Functions
RAY
Bases: BaseComponent
Output locations along a depth contour.
.. code-block:: text
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
.. ipython:: python :okwarning:
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())
Source code in rompy_swan/components/output.py
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 | |
Attributes
model_type
class-attribute
instance-attribute
rname
class-attribute
instance-attribute
xp1
class-attribute
instance-attribute
xp1: float = Field(description='Problem coordinate of the begin point of the first master ray in the x-direction')
yp1
class-attribute
instance-attribute
yp1: float = Field(description='Problem coordinate of the begin point of the first master ray in the y-direction')
xq1
class-attribute
instance-attribute
xq1: float = Field(description='Problem coordinate of the end point of the first master ray in the x-direction')
yq1
class-attribute
instance-attribute
yq1: float = Field(description='Problem coordinate of the end point of the first master ray in the y-direction')
npts
class-attribute
instance-attribute
npts: list[int] = Field(description='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)', min_length=1)
xp
class-attribute
instance-attribute
xp: list[float] = Field(description='problem coordinates of the begin of each subsequent master ray in the x-direction', min_length=1)
yp
class-attribute
instance-attribute
yp: list[float] = Field(description='problem coordinates of the begin of each subsequent master ray in the y-direction', min_length=1)
xq
class-attribute
instance-attribute
xq: list[float] = Field(description='problem coordinates of the end of each subsequent master ray in the x-direction', min_length=1)
yq
class-attribute
instance-attribute
yq: list[float] = Field(description='problem coordinates of the end of each subsequent master ray in the y-direction', min_length=1)
Functions
ensure_equal_size
ensure_equal_size() -> CURVE
cmd
Command file string for this component.
Source code in rompy_swan/components/output.py
ISOLINE
Bases: BaseLocation
Output locations along a depth contour.
.. code-block:: text
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
.. ipython:: python :okwarning:
from rompy_swan.components.output import ISOLINE
loc = ISOLINE(sname="outcurve", rname="outray", dep_type="depth", dep=12.0)
print(loc.render())
Source code in rompy_swan/components/output.py
Attributes
model_type
class-attribute
instance-attribute
model_type: Literal['isoline', 'ISOLINE'] = Field(default='isoline', description='Model type discriminator')
rname
class-attribute
instance-attribute
dep
class-attribute
instance-attribute
dep: float = Field(description='The depth (in m) of the depth contour line along which output locations are generated by SWAN.')
dep_type
class-attribute
instance-attribute
dep_type: Optional[Literal['depth', 'bottom']] = Field(default=None, description='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)')
Functions
cmd
Command file string for this component.
POINTS
Bases: BaseLocation
Isolated output locations.
.. code-block:: text
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
.. ipython:: python :okwarning:
from rompy_swan.components.output import POINTS
loc = POINTS(sname="outpts", xp=[172.3, 172.4], yp=[-39, -39])
print(loc.render())
Source code in rompy_swan/components/output.py
Attributes
model_type
class-attribute
instance-attribute
model_type: Literal['points', 'POINTS'] = Field(default='points', description='Model type discriminator')
xp
class-attribute
instance-attribute
xp: Optional[list[float]] = Field(description='problem coordinates of the points in the x-direction', min_length=1)
yp
class-attribute
instance-attribute
yp: Optional[list[float]] = Field(description='problem coordinates of the points in the y-direction', min_length=1)
Functions
ensure_equal_size
ensure_equal_size() -> POINTS
POINTS_FILE
Bases: BaseLocation
Isolated output locations.
.. code-block:: text
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
.. ipython:: python :okwarning:
from rompy_swan.components.output import POINTS_FILE
loc = POINTS_FILE(sname="outpts", fname="./output_locations.txt")
print(loc.render())
Source code in rompy_swan/components/output.py
NGRID
Bases: BaseLocation
Output locations for a nested grid.
.. code-block:: text
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
.. ipython:: python :okwarning:
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())
Source code in rompy_swan/components/output.py
Attributes
model_type
class-attribute
instance-attribute
model_type: Literal['ngrid', 'NGRID'] = Field(default='ngrid', description='Model type discriminator')
grid
class-attribute
instance-attribute
grid: GRIDREGULAR = Field(description='NGRID grid definition')
Functions
grid_suffix
classmethod
grid_suffix(grid: GRIDREGULAR) -> GRIDREGULAR
NGRID_UNSTRUCTURED
Bases: BaseLocation
Output locations for a nested grid.
.. code-block:: text
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
.. ipython:: python :okwarning:
from rompy_swan.components.output import NGRID_UNSTRUCTURED
loc = NGRID_UNSTRUCTURED(sname="outnest", kind="triangle", fname="ngrid.txt")
print(loc.render())
Source code in rompy_swan/components/output.py
Attributes
model_type
class-attribute
instance-attribute
model_type: Literal['ngrid_unstructured', 'NGRID_UNSTRUCTURED'] = Field(default='ngrid_unstructured', description='Model type discriminator')
kind
class-attribute
instance-attribute
kind: Optional[Literal['triangle', 'easymesh']] = Field(default='triangle', description='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
class-attribute
instance-attribute
fname: str = Field(description='Basename of the required files, i.e. without extension', max_length=32)
Functions
cmd
Command file string for this component.
Settings
QUANTITY
Bases: BaseComponent
Define output settings.
.. code-block:: text
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
.. ipython:: python :okwarning:
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())
Source code in rompy_swan/components/output.py
743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 | |
Attributes
model_type
class-attribute
instance-attribute
model_type: Literal['quantity', 'QUANTITY'] = Field(default='quantity', description='Model type discriminator')
output
class-attribute
instance-attribute
output: list[BlockOptions] = Field(description='The output variables to define settings for', min_length=1)
short
class-attribute
instance-attribute
short: Optional[str] = Field(default=None, description='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', max_length=16)
long
class-attribute
instance-attribute
long: Optional[str] = Field(default=None, description='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', max_length=16)
lexp
class-attribute
instance-attribute
lexp: Optional[float] = Field(default=None, description='Lowest expected value of the output quantity')
hexp
class-attribute
instance-attribute
hexp: Optional[float] = Field(default=None, description='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
class-attribute
instance-attribute
excv: Optional[float] = Field(default=None, description='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
class-attribute
instance-attribute
power: Optional[float] = Field(default=None, description='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
class-attribute
instance-attribute
ref: Optional[str] = Field(default=None, description='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
class-attribute
instance-attribute
fswell: Optional[float] = Field(default=None, description='Upper limit of frequency range used for computing the quantity HSWELL (SWAN default: 0.1 Hz)')
noswll
class-attribute
instance-attribute
noswll: Optional[int] = Field(default=None, description='Number of swells to output for watershed quantities ')
fmin
class-attribute
instance-attribute
fmin: Optional[float] = Field(default=None, description='Lower limit of frequency range used for computing integral parameters (SWAN Default: 0.0 Hz)')
fmax
class-attribute
instance-attribute
fmax: Optional[float] = Field(default=None, description='Upper limit of frequency range used for computing integral parameters (SWAN default: 1000.0 Hz, acts as infinity)')
coord
class-attribute
instance-attribute
coord: Optional[Literal['problemcoord', 'frame']] = Field(default=None, description="Define if vectors and directions refer to the problem coordinate system ('problemcoord') or sets created by command FRAME ('frame') (SWAN default: problemcoord)")
Functions
cmd
Command file string for this component.
Source code in rompy_swan/components/output.py
QUANTITIES
Bases: BaseComponent
Define output settings for multiple output.
.. code-block:: text
QUANTITY < output > ...
QUANTITY < output > ...
..
This component can be used to prescribe and render multiple QUANTITY components.
Examples
.. ipython:: python :okwarning:
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())
Source code in rompy_swan/components/output.py
Attributes
model_type
class-attribute
instance-attribute
model_type: Literal['quantities', 'QUANTITIES'] = Field(default='quantities', description='Model type discriminator')
quantities
class-attribute
instance-attribute
quantities: list[QUANTITY] = Field(description='QUANTITY components')
Functions
OUTPUT_OPTIONS
Bases: BaseComponent
Set format of output.
.. code-block:: text
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
.. ipython:: python :okwarning:
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())
Source code in rompy_swan/components/output.py
993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 | |
Attributes
model_type
class-attribute
instance-attribute
model_type: Literal['block', 'BLOCK'] = Field(default='block', description='Model type discriminator')
comment
class-attribute
instance-attribute
comment: Optional[str] = Field(default=None, description='Comment character used in comment lines in the output (SWAN default: %)', min_length=1, max_length=1)
field
class-attribute
instance-attribute
field: Optional[int] = Field(default=None, description='Length of one data field in a table (SWAN default: 12)', ge=8, le=16)
ndec_block
class-attribute
instance-attribute
ndec_block: Optional[int] = Field(default=None, description='Number of decimals in block output (SWAN default: 4)', ge=0, le=9)
len
class-attribute
instance-attribute
len: Optional[int] = Field(default=None, description='Number of data on one line of block output (SWAN default: 6)', ge=1, le=9999)
ndec_spec
class-attribute
instance-attribute
ndec_spec: Optional[int] = Field(default=None, description='Number of decimals in spectra output (SWAN default: 4)', ge=0, le=9)
Functions
cmd
Command file string for this component.
Source code in rompy_swan/components/output.py
Write
BaseWrite
Bases: BaseComponent, ABC
Base class for SWAN output writing.
.. code-block:: text
{MODEL_TYPE} sname='sname'
This is the base class for all write components. It is not meant to be used directly.
Examples
.. ipython:: python :okwarning:
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())
Source code in rompy_swan/components/output.py
1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 | |
Attributes
model_type
class-attribute
instance-attribute
model_type: Literal['write', 'WRITE'] = Field(default='write', description='Model type discriminator')
sname
class-attribute
instance-attribute
sname: str = Field(description='Name of the set of output locations in which the output is to be written', max_length=8)
fname
class-attribute
instance-attribute
fname: str = Field(description='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
class-attribute
instance-attribute
times: Optional[TimeRangeOpen] = Field(default=None, description='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')
Functions
validate_special_names
validate_special_names() -> BaseWrite
Source code in rompy_swan/components/output.py
validate_times
validate_times() -> BaseWrite
BLOCK
Bases: BaseWrite
Write spatial distributions.
.. code-block:: text
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
.. ipython:: python :okwarning:
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())
Source code in rompy_swan/components/output.py
1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 | |
Attributes
model_type
class-attribute
instance-attribute
model_type: Literal['block', 'BLOCK'] = Field(default='block', description='Model type discriminator')
header
class-attribute
instance-attribute
header: Optional[bool] = Field(default=None, description='Indicate if the output should be written to a file with header lines (SWAN default: True)')
idla
class-attribute
instance-attribute
idla: Optional[IDLA] = Field(default=None, description='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
class-attribute
instance-attribute
output: list[BlockOptions] = Field(description='The output variables to output to block file', min_length=1)
unit
class-attribute
instance-attribute
unit: Optional[float] = Field(default=None, description='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`)')
Functions
validate_idla
classmethod
Source code in rompy_swan/components/output.py
cmd
Command file string for this component.
Source code in rompy_swan/components/output.py
TABLE
Bases: BaseWrite
Write spatial distributions.
.. code-block:: text
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
.. ipython:: python :okwarning:
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())
Source code in rompy_swan/components/output.py
1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 | |
Attributes
model_type
class-attribute
instance-attribute
model_type: Literal['table', 'TABLE'] = Field(default='table', description='Model type discriminator')
format
class-attribute
instance-attribute
format: Optional[Literal['header', 'noheader', 'indexed']] = Field(default=None, description='Indicate if the table should be written to a file as a HEADER, NOHEADER or INDEXED table format (SWAN default: HEADER)')
output
class-attribute
instance-attribute
output: list[BlockOptions] = Field(description='The output variables to output to block file', min_length=1)
Functions
cmd
Command file string for this component.
Source code in rompy_swan/components/output.py
SPECOUT
Bases: BaseWrite
Write to data file the wave spectra.
.. code-block:: text
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
.. ipython:: python :okwarning:
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())
Source code in rompy_swan/components/output.py
1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 | |
Attributes
model_type
class-attribute
instance-attribute
model_type: Literal['specout', 'SPECOUT'] = Field(default='specout', description='Model type discriminator')
Functions
cmd
Command file string for this component.
Source code in rompy_swan/components/output.py
NESTOUT
Bases: BaseWrite
Write to 2D boundary spectra.
.. code-block:: text
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
.. ipython:: python :okwarning:
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())
Source code in rompy_swan/components/output.py
TEST
Bases: BaseComponent
Write intermediate results.
.. code-block:: text
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
.. ipython:: python :okwarning:
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())
TODO: Support k in POINTS IJ.
Source code in rompy_swan/components/output.py
1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 | |
Attributes
model_type
class-attribute
instance-attribute
itest
class-attribute
instance-attribute
itest: Optional[int] = Field(default=None, description='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
class-attribute
instance-attribute
itrace: Optional[int] = Field(default=None, description='SWAN writes a message (name of subroutine) to the PRINT file at the first `itrace` entries of each subroutine (SWAN default: 0)')
points
class-attribute
instance-attribute
points: Union[XY, IJ] = Field(description='Points where detailed print output is produced (max of 50 points)', discriminator='model_type')
fname_par
class-attribute
instance-attribute
fname_par: Optional[str] = Field(default=None, description='Name of the file where the integral parameters are written to')
fname_s1d
class-attribute
instance-attribute
fname_s1d: Optional[str] = Field(default=None, description='Name of the file where the 1D variance density and 6 source terms are written to')
fname_s2d
class-attribute
instance-attribute
fname_s2d: Optional[str] = Field(default=None, description='Name of the file where the 2D variance density and 6 source terms are written to')
Functions
validate_points
classmethod
at_least_one
at_least_one() -> TEST
Warns if no test file is being specified.
Source code in rompy_swan/components/output.py
cmd
Command file string for this component.