Components API¶
CGRID Components¶
REGULAR ¶
Bases: CGRID
SWAN regular computational grid.
.. code-block:: text
CGRID REGULAR [xpc] [ypc] [alpc] [xlenc] [ylenc] [mxc] [myc] &
->CIRCLE|SECTOR [mdc] [flow] [fhigh] [msc]
This is a group component that includes a CGRID and a READGRID component.
Note¶
In 1D-mode, alpc should be equal to the direction alpinp.
Examples¶
.. ipython:: python :okwarning:
from rompy_swan.components.cgrid import REGULAR
cgrid = REGULAR(
grid=dict(xp=0, yp=0, alp=0, xlen=2000, ylen=1300, mx=100, my=100),
spectrum=dict(mdc=36, flow=0.04, fhigh=1.0),
)
print(cgrid.render())
Source code in src/rompy_swan/components/cgrid.py
Attributes¶
model_type
class-attribute
instance-attribute
¶
model_type: Literal['regular', 'REGULAR'] = Field(default='regular', description='Model type discriminator')
grid
class-attribute
instance-attribute
¶
grid: GRIDREGULAR = Field(description='Computational grid definition')
Functions¶
CURVILINEAR ¶
Bases: CGRID
SWAN curvilinear computational grid.
.. code-block:: text
CGRID CURVILINEAR [mxc] [myc] (EXCEPTION [xexc] [yexc])
->CIRCLE|SECTOR [mdc] [flow] [fhigh] [msc]
READGRID COORDINATES [fac] 'fname' [idla] [nhedf] [nhedvec] &
FREE|FORMAT ('form'|[idfm])
This is a group component that includes a CGRID and a READGRID component.
Examples¶
.. ipython:: python :okwarning:
from rompy_swan.components.cgrid import CURVILINEAR
cgrid = CURVILINEAR(
mxc=199,
myc=199,
readcoord=dict(fname="./coords.txt"),
spectrum=dict(mdc=36, flow=0.04, fhigh=1.0),
)
print(cgrid.render())
Source code in src/rompy_swan/components/cgrid.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | |
Attributes¶
model_type
class-attribute
instance-attribute
¶
model_type: Literal['curvilinear', 'CURVILINEAR'] = Field(default='curvilinear', description='Model type discriminator')
mxc
class-attribute
instance-attribute
¶
mxc: int = Field(description='Number of meshes in computational grid in ξ-direction (this number is one less than the number of grid points in this domain).')
myc
class-attribute
instance-attribute
¶
myc: int = Field(description='Number of meshes in computational grid in η-direction (this number is one less than the number of grid points in this domain).')
xexc
class-attribute
instance-attribute
¶
xexc: Optional[float] = Field(default=None, description='the value which the user uses to indicate that a grid point is to be ignored in the computations (this value is provided by the user at the location of the x-coordinate considered in the file of the x-coordinates, see command READGRID COOR).')
yexc
class-attribute
instance-attribute
¶
yexc: Optional[float] = Field(default=None, description='the value which the user uses to indicate that a grid point is to be ignored in the computations (this value is provided by the user at the location of the y-coordinate considered in the file of the y-coordinates, see command READGRID COOR).')
readcoord
class-attribute
instance-attribute
¶
readcoord: READCOORD = Field(description='Grid coordinates reader.')
Functions¶
xexc_and_yexc_or_neither ¶
xexc_and_yexc_or_neither() -> CURVILINEAR
cmd ¶
UNSTRUCTURED ¶
Bases: CGRID
SWAN unstructured computational grid.
.. code-block:: text
CGRID UNSTRUCTURED CIRCLE|SECTOR [mdc] [flow] [fhigh] [msc]
READGRID UNSTRUCTURED [grid_type] ('fname')
This is a group component that includes a CGRID and a READGRID component.
Examples¶
.. ipython:: python :okwarning:
from rompy_swan.components.cgrid import UNSTRUCTURED
cgrid = UNSTRUCTURED(
grid_type="adcirc",
spectrum=dict(mdc=36, flow=0.04, fhigh=1.0),
)
print(cgrid.render())
Source code in src/rompy_swan/components/cgrid.py
Attributes¶
model_type
class-attribute
instance-attribute
¶
model_type: Literal['unstructured'] = Field(default='unstructured', description='Model type discriminator')
grid_type
class-attribute
instance-attribute
¶
grid_type: Literal['adcirc', 'triangle', 'easymesh'] = Field(default='adcirc', description='Unstructured grid type')
fname
class-attribute
instance-attribute
¶
fname: Optional[str] = Field(default=None, description='Name of the file containing the unstructured grid', max_length=36)
Functions¶
check_fname_required ¶
check_fname_required() -> UNSTRUCTURED
Check that fname needs to be provided.
Source code in src/rompy_swan/components/cgrid.py
cmd ¶
Source code in src/rompy_swan/components/cgrid.py
Startup Components¶
PROJECT ¶
Bases: BaseComponent
SWAN Project.
.. code-block:: text
PROJECT 'name' 'nr' 'title' 'title2 'title3'
With this required command the user defines a number of strings to identify the SWAN run (project name e.g., an engineering project) in the print and plot file.
Examples¶
.. ipython:: python :okwarning:
from rompy_swan.components.startup import PROJECT
proj = PROJECT(nr="01")
print(proj.render())
proj = PROJECT(
name="waus",
nr="001",
title1="Western Australia",
title2="Perth Nest"
)
print(proj.render())
Source code in src/rompy_swan/components/startup.py
Attributes¶
model_type
class-attribute
instance-attribute
¶
model_type: Literal['project', 'PROJECT'] = Field(default='project', description='Model type discriminator')
name
class-attribute
instance-attribute
¶
name: Optional[str] = Field(default=None, description='Is the name of the project, at most 16 characters long', max_length=16)
nr
class-attribute
instance-attribute
¶
nr: str = Field(description='Is the run identification (to be provided as a character string; e.g. the run number) to distinguish this run among other runs for the same project; it is at most 4 characters long. It is the only required information in this command.', max_length=4)
title1
class-attribute
instance-attribute
¶
title1: Optional[str] = Field(default=None, description="A string of at most 72 characters provided by the user to appear in the output of the program for the user's convenience (SWAN default: blanks)", max_length=72)
title2
class-attribute
instance-attribute
¶
title3
class-attribute
instance-attribute
¶
Functions¶
cmd ¶
Source code in src/rompy_swan/components/startup.py
SET ¶
Bases: BaseComponent
SWAN setting commands.
.. code-block:: text
SET [level] [nor] [depmin] [maxmes] [maxerr] [grav] [rho] [cdcap] &
[inrhog] [hsrerr] NAUTICAL|->CARTESIAN [pwtail] [froudmax] [icewind]
With this optional command the user assigns values to various general parameters.
Notes¶
The error level maxerr is coded as follows:
- 1: warnings
- 2: errors (possibly automatically repaired or repairable by SWAN)
- 3: severe errors
Default values for pwtail depend on formulations of physics:
- command GEN1:
pwtail = 5 - command GEN2:
pwtail = 5 - command GEN3 KOMEN:
pwtail = 4 - command GEN3 WESTH:
pwtail = 4 - command GEN3 JANSSEN:
pwtail = 5
Examples¶
.. ipython:: python :okwarning:
from rompy_swan.components.startup import SET
set = SET(level=0.5, direction_convention="nautical")
print(set.render())
set = SET(
level=-1.0,
nor=90,
depmin=0.01,
maxerr=3,
grav=9.81,
rho=1025,
cdcap=2.5e-3,
inrhog=0,
hsrerr=0.1,
direction_convention="nautical",
)
print(set.render())
Source code in src/rompy_swan/components/startup.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 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 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 | |
Attributes¶
model_type
class-attribute
instance-attribute
¶
level
class-attribute
instance-attribute
¶
level: Optional[float] = Field(default=None, description='Increase in water level that is constant in space and time can be given with this option, `level` is the value of this increase (in m). For a variable water level reference is made to the commands INPGRID and READINP (SWAN default: 0)', examples=[0])
nor
class-attribute
instance-attribute
¶
nor: Optional[float] = Field(default=None, description='Direction of North with respect to the x-axis (measured counterclockwise); default `nor = 90`, i.e. x-axis of the problem coordinate system points East. When spherical coordinates are used (see command COORD) the value of `nor` may not be modified', ge=-360.0, le=360.0)
depmin
class-attribute
instance-attribute
¶
depmin: Optional[float] = Field(default=None, description='Threshold depth (in m). In the computation any positive depth smaller than `depmin` is made equal to `depmin` (SWAN default: 0.05)', ge=0.0)
maxmes
class-attribute
instance-attribute
¶
maxmes: Optional[int] = Field(default=None, description='Maximum number of error messages during the computation at which the computation is terminated. During the computational process messages are written to the print file (SWAN default: 200)', ge=0)
maxerr
class-attribute
instance-attribute
¶
maxerr: Optional[Literal[1, 2, 3]] = Field(default=None, description='During pre-processing SWAN checks input data. Depending on the severity of the errors encountered during this pre-processing, SWAN does not start computations. The user can influence the error level above which SWAN will not start computations (at the level indicated the computations will continue) (SWAN default: 1)')
grav
class-attribute
instance-attribute
¶
grav: Optional[float] = Field(default=None, description='The gravitational acceleration (in m/s2) (SWAN default: 9.81)', ge=0.0)
rho
class-attribute
instance-attribute
¶
rho: Optional[float] = Field(default=None, description='The water density (in kg/m3) (SWAN default: 1025)', ge=0.0)
cdcap
class-attribute
instance-attribute
¶
cdcap: Optional[float] = Field(default=None, description='The maximum value for the wind drag coefficient. A value of 99999 meansno cutting off the drag coefficient. A suggestion for this parameter is `cdcap = 2.5x 10-3` (SWAN default: 99999) ', ge=0.0)
inrhog
class-attribute
instance-attribute
¶
inrhog: Optional[Literal[0, 1]] = Field(default=None, description='To indicate whether the user requires output based on variance or based on true energy (see Section 2.5). `inrhog` = 0: output based on variance, `inrhog` = 1: output based on true energy (SWAN default: 0)')
hsrerr
class-attribute
instance-attribute
¶
hsrerr: Optional[float] = Field(default=None, description='The relative difference between the user imposed significant wave height and the significant wave height computed by SWAN (anywhere along the computational grid boundary) above which a warning will be given. This relative difference is the difference normalized with the user provided significant wave height. This warning will be given for each boundary grid point where the problem occurs (with its x- and y-index number of the computational grid). The cause of the difference is explained in Section 2.6.3. To suppress these warnings (in particular for nonstationary computations), set `hsrerr` at a very high value or use command OFF BNDCHK (SWAN default: 0.10) (ONLY MEANT FOR STRUCTURED GRIDS)', ge=0.0)
direction_convention
class-attribute
instance-attribute
¶
direction_convention: Literal['nautical', 'cartesian'] = Field(description='Direction convention: `nautical` indicates that the Nautical convention for wind and wave direction (SWAN input and output) will be used, `cartesian` indicates that the Cartesian convention for wind and wave direction will be used. For definition, see Section 2.5 or Appendix A (SWAN default: `cartesian`)')
pwtail
class-attribute
instance-attribute
¶
pwtail: Optional[int] = Field(default=None, description='Power of high frequency tail; defines the shape of the spectral tail above the highest prognostic frequency `fhigh` (see command CGRID). The energy density is assumed to be proportional to frequency to the power `pwtail`. If the user wishes to use another value, then this SET command should be located in the command file after GEN1, GEN2 or GEN3 command (these will override the SET command with respect to `pwtail`)', ge=0)
froudmax
class-attribute
instance-attribute
¶
froudmax: Optional[float] = Field(default=None, description='Is the maximum Froude number (`U/√gd` with `U` the current and `d` the water depth). The currents taken from a circulation model may mismatch with given water depth `d` in the sense that the Froude number becomes larger than 1. For this, the current velocities will be maximized by Froude number times `sqrt(gh)` (SWAN default: 0.8)', ge=0.0)
icewind
class-attribute
instance-attribute
¶
icewind: Optional[Literal[0, 1]] = Field(default=None, description='Controls the scaling of wind input by open water fraction. Default value of zero corresponds to the case where wind input is scaled by the open water fraction. If `icewind = 1` then sea ice does not affect wind input directly. (Though there is still indirect effect via the sea ice sink term; see command SICE) (SWAN default: 0)')
Functions¶
pwtail_after_gen
classmethod
¶
cmd ¶
Source code in src/rompy_swan/components/startup.py
MODE ¶
Bases: BaseComponent
SWAN Mode.
.. code-block:: text
MODE ->STATIONARY|NONSTATIONARY ->TWODIMENSIONAL|ONEDIMENSIONAL
With this optional command the user indicates that the run will be either stationary or nonstationary and one-dimensional (1D-mode) or two-dimensional (2D-mode). Nonstationary means either (see command COMPUTE):
- (a) one nonstationary computations or
- (b) a sequence of stationary computations or
- (c) a mix of (a) and (b)
Examples¶
.. ipython:: python :okwarning:
from rompy_swan.components.startup import MODE
mode = MODE()
print(mode.render())
mode = MODE(kind="nonstationary", dim="twodimensional")
print(mode.render())
Source code in src/rompy_swan/components/startup.py
Attributes¶
model_type
class-attribute
instance-attribute
¶
model_type: Literal['mode', 'MODE'] = Field(default='mode', description='Model type discriminator.')
kind
class-attribute
instance-attribute
¶
kind: Literal['stationary', 'nonstationary'] = Field(default='stationary', description='Indicates if run will be stationary or nonstationary')
dim
class-attribute
instance-attribute
¶
dim: Literal['onedimensional', 'twodimensional'] = Field(default='twodimensional', description='Indicates that the run will be either one-dimensional (1D-mode) or two-dimensional (2D-mode)')
Functions¶
COORDINATES ¶
Bases: BaseComponent
SWAN Coordinates.
.. code-block:: text
COORDINATES ->CARTESIAN|SPHERICAL REPEATING
Command to choose between Cartesian and spherical coordinates (see Section 2.5). A nested SWAN run must use the same coordinate system as the coarse grid SWAN run.
Examples¶
.. ipython:: python :okwarning:
from rompy_swan.components.startup import COORDINATES
coords = COORDINATES()
print(coords.render())
coords = COORDINATES(
kind=dict(model_type="spherical", projection="ccm"),
reapeating=True,
)
print(coords.render())
Source code in src/rompy_swan/components/startup.py
Attributes¶
model_type
class-attribute
instance-attribute
¶
model_type: Literal['coordinates', 'COORDINATES'] = Field(default='coordinates', description='Model type discriminator')
kind
class-attribute
instance-attribute
¶
reapeating
class-attribute
instance-attribute
¶
reapeating: bool = Field(default=False, description='This option is only for academic cases. It means that wave energy leaving at one end of the domain (in computational x-direction) enter at the other side; it is as if the wave field repeats itself in x-direction with the length of the domain in x-direction. This option cannot be used in combination with computation of set-up (see command SETUP). This option is available only with regular grids')
Functions¶
Boundary Components¶
BOUNDSPEC ¶
Bases: BaseComponent
Boundary along sides or segment.
.. code-block:: text
BOUNDSPEC ->SIDE|SEGMENT CONSTANT|VARIABLE PAR|FILE
This command BOUNDSPEC defines parametric spectra at the boundary. It consists of two parts, the first part defines the boundary side or segment where the spectra will be given, the second part defines the spectral parameters of these spectra. Note that in fact only the incoming wave components of these spectra are used by SWAN. The fact that complete spectra are calculated at the model boundaries from the spectral parameters should not be misinterpreted. Only the incoming components are effective in the computation.
TODO: Add support for unstructured grid (k).
Examples¶
.. ipython:: python :okwarning:
from rompy_swan.components.boundary import BOUNDSPEC
boundary = BOUNDSPEC(
shapespec=dict(model_type="shapespec", shape=dict(model_type="pm")),
location=dict(model_type="side", side="west", direction="ccw"),
data=dict(model_type="constantpar", hs=2, per=8, dir=270, dd=30),
)
print(boundary.render())
boundary = BOUNDSPEC(
shapespec=dict(model_type="shapespec", shape=dict(model_type="pm")),
location=dict(
model_type="segment",
points=dict(model_type="ij", i=[0, 0], j=[0, 3])
),
data=dict(model_type="constantpar", hs=2, per=8, dir=270, dd=30),
)
print(boundary.render())
Source code in src/rompy_swan/components/boundary.py
Attributes¶
model_type
class-attribute
instance-attribute
¶
model_type: Literal['boundspec', 'BOUNDSPEC'] = Field(default='boundspec', description='Model type discriminator')
shapespec
class-attribute
instance-attribute
¶
location
class-attribute
instance-attribute
¶
data
class-attribute
instance-attribute
¶
data: CONSTANTPAR | CONSTANTFILE | VARIABLEPAR | VARIABLEFILE = Field(description='Spectral data')
Functions¶
BOUNDNEST1 ¶
Bases: BaseComponent
Boundary spectra from a coarser SWAN nest.
.. code-block:: text
BOUNDNEST1 NEST 'fname' ->CLOSED|OPEN
With this optional command a nested SWAN run can be carried out with the boundary conditions obtained from a coarse grid SWAN run (generated in that previous SWAN run with command NESTOUT). The spectral frequencies and directions of the coarse grid run do not have to coincide with the frequencies and directions used in the nested SWAN run; SWAN will interpolate to these frequencies and directions in the nested run (see Section 2.6.3). To generate the nest boundary in the coarse grid run, use command NGRID. For the nested run, use the command CGRID with identical geographical information except the number of meshes (which will be much higher for the nested run). This BOUNDNEST1 command is not available for 1D computations; in such cases the commands SPECOUT and BOUNDSPEC can be used for the same purpose. A nested SWAN run must use the same coordinate system as the coarse grid SWAN run. For a curvilinear grid, it is advised to use the commands POINTS or CURVE and SPECOUT instead of NGRID and NESTOUT.
Examples¶
.. ipython:: python :okwarning:
from rompy_swan.components.boundary import BOUNDNEST1
boundary = BOUNDNEST1(fname="boundary.swn", rectangle="closed")
print(boundary.render())
Source code in src/rompy_swan/components/boundary.py
Attributes¶
model_type
class-attribute
instance-attribute
¶
model_type: Literal['boundnest1', 'BOUNDNEST1'] = Field(default='boundnest1', description='Model type discriminator')
fname
class-attribute
instance-attribute
¶
fname: str = Field(description='Name of the file containing the boundary conditions for the present run, created by the previous SWAN coarse grid run. This file is structured according to the rules given in Appendix D for 2D spectra', min_length=1, max_length=36)
rectangle
class-attribute
instance-attribute
¶
rectangle: Literal['closed', 'open'] = Field(default='closed', description='Boundary is defined over a closed (default) or an open rectangle. Boundary generated from the NESTOUT command is aways closed')
Functions¶
BOUNDNEST2 ¶
Bases: BaseComponent
Boundary spectra from WAM.
.. code-block:: text
BOUNDNEST2 WAMNEST 'fname' FREE|UNFORMATTED ->CRAY|WKSTAT [xgc] [ygc] [lwdate]
With this optional command (not fully tested) a nested SWAN run can be carried out with the boundary conditions obtained from a coarse grid WAM run (WAM Cycle 4.5, source code as distributed by the Max Planck Institute in Hamburg). The spectral frequencies and directions of the coarse grid run do not have to coincide with the frequencies and directions used in the nested SWAN run; SWAN will interpolate to these frequencies and directions in the nested run (see Section 2.6.3). Note that SWAN will accept output of a WAM output location only if the SWAN grid point on the nest boundary lies within a rectangle between two consecutive WAM output locations with a width equal to 0.1 times the distance between these output locations on either side of the line between these WAM output locations. This BOUNDNEST2 command is not available for 1D computations. Only boundary conditions generated by WAM Cycle 4.5 can be read properly by SWAN. A nested SWAN run may use either Cartesian or spherical coordinates. A curvilinear grid may be used in the nested grid but the boundaries of this nest should conform to the rectangular course grid nest boundaries. WAM output files are unformatted (binary); this usually implies that WAM and SWAN have to run on the same computer. For those cases where WAM and SWAN run on different types of machines (binary files do not transfer properly), the option FREE is available in this command. The distributed version of WAM does not support the required free format nesting output; WAM users who modify WAM such that it can make formatted output, must modify WAM such that the files made by WAM can be read in free format, i.e. with at least a blank or comma between numbers.
Note¶
the contents of 'fname' file could look like:
.. code-block:: text
CBO9212010000
CBO9212020000
CBO9212030000
Examples¶
.. ipython:: python :okwarning:
from rompy_swan.components.boundary import BOUNDNEST2
boundary = BOUNDNEST2(fname="boundary.wam", format="cray", lwdate=12)
print(boundary.render())
Source code in src/rompy_swan/components/boundary.py
191 192 193 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 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | |
Attributes¶
model_type
class-attribute
instance-attribute
¶
model_type: Literal['boundnest2', 'BOUNDNEST2'] = Field(default='boundnest2', description='Model type discriminator')
fname
class-attribute
instance-attribute
¶
fname: str = Field(description='A file name that contains all the names of WAM files containing the nested boundary conditions in time-sequence (usually one file per day)', min_length=1, max_length=36)
format
class-attribute
instance-attribute
¶
format: Literal['cray', 'wkstat', 'free'] = Field(description='Format of the WAM file. `cray`: CRAY version of WAM, `wkstat`: WORKSTATION version of WAM, `free`: Free format (these files are not generated standard by WAM)')
xgc
class-attribute
instance-attribute
¶
xgc: Optional[float] = Field(default=None, description='If SWAN is used with Cartesian coordinates: longitude of south-west corner of SWAN computational grid (in degrees); if the south-west corner of the nest in the WAM computation is on land this value is required. If SWAN is used with spherical coordinates then `xgc` is ignored by SWAN (SWAN default: the location of the first spectrum encountered in the nest file')
ygc
class-attribute
instance-attribute
¶
ygc: Optional[float] = Field(default=None, description='If SWAN is used with Cartesian coordinates: latitude of south-west corner of SWAN computational grid (in degrees); if the south-west corner of the nest in the WAM computation is on land this value is required. If SWAN is used with spherical coordinates then `ygc` is ignored by SWAN (SWAN default: the location of the first spectrum encountered in the nest file')
lwdate
class-attribute
instance-attribute
¶
lwdate: Literal[10, 12, 14] = Field(default=12, description='Length of character string for date-time as used in the WAM files. Possible values are: 10 (i.e. YYMMDDHHMM), 12 (i.e. YYMMDDHHMMSS) or 14 (i.e. YYYYMMDDHHMMSS) (SWAN default: `lwdate` = 12)')
Functions¶
cmd ¶
Source code in src/rompy_swan/components/boundary.py
BOUNDNEST3 ¶
Bases: BaseComponent
Boundary spectra from WAVEWATCHIII.
.. code-block:: text
BOUNDNEST3 WW3 'fname' FREE|UNFORMATTED ->CLOSED|OPEN [xgc] [ygc]
With this optional command a nested SWAN run can be carried out with the boundary conditions obtained from a coarse grid WAVEWATCH III run. The spectral frequencies and directions of the coarse grid run do not have to coincide with the frequencies and directions used in the nested SWAN run; SWAN will interpolate to these frequencies and directions in the nested run (see Section 2.6.3). The output files of WAVEWATCH III have to be created with the post-processor of WAVEWATCH III as output transfer files (formatted or unformatted) with WW_3 OUTP (output type 1 sub type 3) at the locations along the nest boundary (i.e. computational grid points in WAVEWATCH III). These locations are equal to the corner points of the SWAN nested grid and optionally also distributed between the corner points of the SWAN nested grid (the boundary of the WAVEWATCH III nested grid need not be closed and may cover land). The locations should be output by WAVEWATCH III in sequence (going along the nest boundary, clockwise or counterclockwise). Note that SWAN will accept output of a WAVEWATCH III output location only if the SWAN grid point on the nest boundary lies within a rectangle between two consecutive WAVEWATCH III output locations with a width equal to 0.1 times the distance between these output locations on either side of the line between these WAVEWATCH III output locations. This BOUNDNEST3 command is not available for 1D computations. A nested SWAN run may use either Cartesian or spherical coordinates. A curvilinear grid may be used in the nested grid but the boundaries of this nest should conform to the rectangular course grid nest boundaries.
Examples¶
.. ipython:: python :okwarning:
from rompy_swan.components.boundary import BOUNDNEST3
boundary = BOUNDNEST3(
fname="boundary.ww3",
format="free",
rectangle="closed",
)
print(boundary.render())
Source code in src/rompy_swan/components/boundary.py
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 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 | |
Attributes¶
model_type
class-attribute
instance-attribute
¶
model_type: Literal['boundnest3', 'BOUNDNEST3'] = Field(default='boundnest3', description='Model type discriminator')
fname
class-attribute
instance-attribute
¶
fname: str = Field(description='The name of the file that contains the spectra computed by WAVEWATCH III', min_length=1, max_length=36)
format
class-attribute
instance-attribute
¶
format: Literal['unformatted', 'free'] = Field(description='Format of the WW3 file. `unformatted`: The input WW3 files are binary, `free`: The input WW3 files are formatted')
rectangle
class-attribute
instance-attribute
¶
rectangle: Literal['closed', 'open'] = Field(default='closed', description='Boundary is defined over a closed (default) or an open rectangle. Boundary generated from the NESTOUT command is aways closed')
xgc
class-attribute
instance-attribute
¶
xgc: Optional[float] = Field(default=None, description='If SWAN is used with Cartesian coordinates: longitude of south-west corner of SWAN computational grid (in degrees); if the south-west corner of the nest in the WAM computation is on land this value is required. If SWAN is used with spherical coordinates then `xgc` is ignored by SWAN (SWAN default: the location of the first spectrum encountered in the nest file. ')
ygc
class-attribute
instance-attribute
¶
ygc: Optional[float] = Field(default=None, description='If SWAN is used with Cartesian coordinates: latitude of south-west corner of SWAN computational grid (in degrees); if the south-west corner of the nest in the WAM computation is on land this value is required. If SWAN is used with spherical coordinates then `ygc` is ignored by SWAN (SWAN default: the location of the first spectrum encountered in the nest file. ')
Functions¶
cmd ¶
Source code in src/rompy_swan/components/boundary.py
INITIAL ¶
Bases: BaseComponent
Initial conditions.
.. code-block:: text
INITIAL -> DEFAULT|ZERO|PAR|HOTSTART
This command can be used to specify the initial values for a stationary (INITIAL HOTSTART only) or nonstationary computation. The initial values thus specified override the default initialization (see Section 2.6.3). Note that it is possible to obtain an initial state by carrying out a previous stationary or nonstationary computation.
Examples¶
.. ipython:: python :okwarning:
from rompy_swan.components.boundary import INITIAL
init = INITIAL()
print(init.render())
init = INITIAL(
kind=dict(model_type="hotmultiple", fname="hotstart.swn", format="free")
)
print(init.render())
Source code in src/rompy_swan/components/boundary.py
Attributes¶
model_type
class-attribute
instance-attribute
¶
model_type: Literal['initial', 'INITIAL'] = Field(default='initial', description='Model type discriminator')
kind
class-attribute
instance-attribute
¶
kind: DEFAULT | ZERO | PAR | HOTSINGLE | HOTMULTIPLE = Field(default_factory=DEFAULT, description='Initial condition type')
Functions¶
Physics Components¶
GEN1 ¶
Bases: BaseComponent
First generation source terms GEN1.
.. code-block:: text
GEN1 [cf10] [cf20] [cf30] [cf40] [edmlpm] [cdrag] [umin] [cfpm]
With this command the user indicates that SWAN should run in first-generation mode (see Scientific/Technical documentation).
Examples¶
.. ipython:: python :okwarning:
from rompy_swan.components.physics import GEN1
gen = GEN1()
print(gen.render())
kwargs = dict(
cf10=188.0,
cf20=0.59,
cf30=0.12,
cf40=250.0,
edmlpm=0.0036,
cdrag=0.0012,
umin=1.0,
cfpm=0.13
)
gen = GEN1(**kwargs)
print(gen.render())
Source code in src/rompy_swan/components/physics.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |
Attributes¶
model_type
class-attribute
instance-attribute
¶
cf10
class-attribute
instance-attribute
¶
cf10: Optional[float] = Field(default=None, description='Controls the linear wave growth (SWAN default: 188.0)')
cf20
class-attribute
instance-attribute
¶
cf20: Optional[float] = Field(default=None, description='Controls the exponential wave growth (SWAN default: 0.59)')
cf30
class-attribute
instance-attribute
¶
cf30: Optional[float] = Field(default=None, description='Controls the exponential wave growth (SWAN default: 0.12)')
cf40
class-attribute
instance-attribute
¶
cf40: Optional[float] = Field(default=None, description='Controls the dissipation rate, i.e., the time decay scale (SWAN default: 250.0)')
edmlpm
class-attribute
instance-attribute
¶
edmlpm: Optional[float] = Field(default=None, description='Maximum non-dimensionless energy density of the wind sea part of the spectrum according to Pierson Moskowitz (SWAN default: 0.0036)')
cdrag
class-attribute
instance-attribute
¶
umin
class-attribute
instance-attribute
¶
umin: Optional[float] = Field(default=None, description='Minimum wind velocity (relative to current; all wind speeds are taken at 10 m above sea level) (SWAN default: 1)')
cfpm
class-attribute
instance-attribute
¶
cfpm: Optional[float] = Field(default=None, description='Coefficient which determines the Pierson Moskowitz frequency: `delta_PM = 2pi g / U_10` (SWAN default: 0.13)')
Functions¶
cmd ¶
Command line string for this component.
Source code in src/rompy_swan/components/physics.py
GEN2 ¶
Bases: GEN1
Second generation source terms GEN2.
.. code-block:: text
GEN2 [cf10] [cf20] [cf30] [cf40] [cf50] [cf60] [edmlpm] [cdrag] [umin] [cfpm]
With this command the user indicates that SWAN should run in second-generation mode (see Scientific/Technical documentation).
Examples¶
.. ipython:: python :okwarning:
from rompy_swan.components.physics import GEN2
gen = GEN2()
print(gen.render())
kwargs = dict(
cf10=188.0,
cf20=0.59,
cf30=0.12,
cf40=250.0,
cf50=0.0023,
cf60=-0.223,
edmlpm=0.0036,
cdrag=0.0012,
umin=1.0,
cfpm=0.13
)
gen = GEN2(**kwargs)
print(gen.render())
Source code in src/rompy_swan/components/physics.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 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 | |
Attributes¶
model_type
class-attribute
instance-attribute
¶
cf50
class-attribute
instance-attribute
¶
cf50: Optional[float] = Field(default=None, description='Controls the spectral energy scale of the limit spectrum (SWAN default: 0.0023)')
cf60
class-attribute
instance-attribute
¶
cf60: Optional[float] = Field(default=None, description='Ccontrols the spectral energy scale of the limit spectrum (SWAN default: -0.223')
Functions¶
cmd ¶
Command line string for this component.
Source code in src/rompy_swan/components/physics.py
GEN3 ¶
Bases: BaseComponent
Third generation source terms GEN3.
.. code-block:: text
GEN3 JANSSEN|KOMEN|->WESTHUYSEN|ST6 AGROW [a]
With this command the user indicates that SWAN should run in third-generation mode for wind input, quadruplet interactions and whitecapping.
Examples¶
.. ipython:: python :okwarning:
from rompy_swan.components.physics import GEN3
gen = GEN3(
source_terms=dict(
model_type="westhuysen",
wind_drag="wu",
agrow=True,
),
)
print(gen.render())
from rompy_swan.subcomponents.physics import ST6C1
gen = GEN3(source_terms=ST6C1())
print(gen.render())
Source code in src/rompy_swan/components/physics.py
Attributes¶
model_type
class-attribute
instance-attribute
¶
source_terms
class-attribute
instance-attribute
¶
source_terms: SOURCE_TERMS = Field(default_factory=WESTHUYSEN, description='SWAN source terms to be used (SWAN default: WESTHUYSEN)', discriminator='model_type')
Functions¶
BREAKING_CONSTANT ¶
Bases: BaseComponent
Constant wave breaking index.
.. code-block:: text
BREAKING CONSTANT [alpha] [gamma]
Indicates that a constant breaker index is to be used.
Examples¶
.. ipython:: python :okwarning:
from rompy_swan.components.physics import BREAKING_CONSTANT
breaking = BREAKING_CONSTANT()
print(breaking.render())
breaking = BREAKING_CONSTANT(alpha=1.0, gamma=0.73)
print(breaking.render())
Source code in src/rompy_swan/components/physics.py
Attributes¶
model_type
class-attribute
instance-attribute
¶
model_type: Literal['constant', 'CONSTANT'] = Field(default='constant', description='Model type discriminator')
alpha
class-attribute
instance-attribute
¶
alpha: Optional[float] = Field(default=None, description='Proportionality coefficient of the rate of dissipation (SWAN default: 1.0)')
gamma
class-attribute
instance-attribute
¶
gamma: Optional[float] = Field(default=None, description='The breaker index, i.e. the ratio of maximum individual wave height over depth (SWAN default: 0.73)')
Functions¶
cmd ¶
Command file string for this component.
Source code in src/rompy_swan/components/physics.py
BREAKING_BKD ¶
Bases: BaseComponent
Variable wave breaking index.
.. code-block:: text
BREAKING BKD [alpha] [gamma0] [a1] [a2] [a3]
Indicates that the breaker index scales with both the bottom slope (beta)
and the dimensionless depth (kd).
Examples¶
.. ipython:: python :okwarning:
from rompy_swan.components.physics import BREAKING_BKD
breaking = BREAKING_BKD()
print(breaking.render())
breaking = BREAKING_BKD(alpha=1.0, gamma0=0.54, a1=7.59, a2=-8.06, a3=8.09)
print(breaking.render())
Source code in src/rompy_swan/components/physics.py
Attributes¶
model_type
class-attribute
instance-attribute
¶
alpha
class-attribute
instance-attribute
¶
alpha: Optional[float] = Field(default=None, description='Proportionality coefficient of the rate of dissipation (SWAN default: 1.0)')
gamma0
class-attribute
instance-attribute
¶
gamma0: Optional[float] = Field(default=None, description='The reference $gamma$ for horizontal slopes (SWAN default: 0.54)')
a1
class-attribute
instance-attribute
¶
a1: Optional[float] = Field(default=None, description='First tunable coefficient for the breaker index (SWAN default: 7.59)')
a2
class-attribute
instance-attribute
¶
a2: Optional[float] = Field(default=None, description='Second tunable coefficient for the breaker index (SWAN default: -8.06)')
a3
class-attribute
instance-attribute
¶
a3: Optional[float] = Field(default=None, description='Third tunable coefficient for the breaker index (SWAN default: 8.09)')
Functions¶
cmd ¶
Command file string for this component.
Source code in src/rompy_swan/components/physics.py
FRICTION_JONSWAP ¶
Bases: BaseComponent
Hasselmann et al. (1973) Jonswap friction.
.. code-block:: text
FRICTION JONSWAP CONSTANT [cfjon]
Indicates that the semi-empirical expression derived from the JONSWAP results for bottom friction dissipation (Hasselmann et al., 1973, JONSWAP) should be activated. This option is default.
References¶
Hasselmann, K., Barnett, T.P., Bouws, E., Carlson, H., Cartwright, D.E., Enke, K., Ewing, J.A., Gienapp, A., Hasselmann, D.E., Kruseman, P. and Meerburg, A., 1973. Measurements of wind-wave growth and swell decay during the Joint North Sea Wave Project (JONSWAP). Deutches Hydrographisches Institut, Hamburg, Germany, Rep. No. 12, 95 pp.
Examples¶
.. ipython:: python :okwarning:
from rompy_swan.components.physics import FRICTION_JONSWAP
friction = FRICTION_JONSWAP()
print(friction.render())
friction = FRICTION_JONSWAP(cfjon=0.038)
print(friction.render())
TODO: Implement VARIABLE option?
Source code in src/rompy_swan/components/physics.py
Attributes¶
model_type
class-attribute
instance-attribute
¶
model_type: Literal['jonswap', 'JONSWAP'] = Field(default='jonswap', description='Model type discriminator')
cfjon
class-attribute
instance-attribute
¶
cfjon: Optional[float] = Field(default=None, description='Coefficient of the JONSWAP formulation (SWAN default: 0.038)')
Functions¶
cmd ¶
FRICTION_COLLINS ¶
Bases: BaseComponent
Collins (1972) friction.
.. code-block:: text
FRICTION COLLINS [cfw]
Note that cfw is allowed to vary over the computational region; in that case use
the commands INPGRID FRICTION and READINP FRICTION to define and read the friction
data. This command FRICTION is still required to define the type of friction
expression. The value of cfw in this command is then not required (it will be
ignored).
References¶
Collins, J.I., 1972. Prediction of shallow-water spectra. Journal of Geophysical Research, 77(15), pp.2693-2707.
Examples¶
.. ipython:: python :okwarning:
from rompy_swan.components.physics import FRICTION_COLLINS
friction = FRICTION_COLLINS()
print(friction.render())
friction = FRICTION_COLLINS(cfw=0.038)
print(friction.render())
Source code in src/rompy_swan/components/physics.py
Attributes¶
model_type
class-attribute
instance-attribute
¶
model_type: Literal['collins', 'COLLINS'] = Field(default='collins', description='Model type discriminator')
cfw
class-attribute
instance-attribute
¶
cfw: Optional[float] = Field(default=None, description='Collins bottom friction coefficient (SWAN default: 0.015)')
Functions¶
FRICTION_MADSEN ¶
Bases: BaseComponent
Madsen et al (1988) friction.
.. code-block:: text
FRICTION MADSEN [kn]
Note that kn is allowed to vary over the computational region; in that case use
the commands INPGRID FRICTION and READINP FRICTION to define and read the friction
data. This command FRICTION is still required to define the type of friction
expression. The value of kn in this command is then not required (it will be
ignored).
References¶
Madsen, O.S., Poon, Y.K. and Graber, H.C., 1988. Spectral wave attenuation by bottom friction: Theory. In Coastal engineering 1988 (pp. 492-504).
Madsen, O.S. and Rosengaus, M.M., 1988. Spectral wave attenuation by bottom friction: Experiments. In Coastal Engineering 1988 (pp. 849-857).
Examples¶
.. ipython:: python :okwarning:
from rompy_swan.components.physics import FRICTION_MADSEN
friction = FRICTION_MADSEN()
print(friction.render())
friction = FRICTION_MADSEN(kn=0.038)
print(friction.render())
Source code in src/rompy_swan/components/physics.py
Attributes¶
model_type
class-attribute
instance-attribute
¶
model_type: Literal['madsen', 'MADSEN'] = Field(default='madsen', description='Model type discriminator')
kn
class-attribute
instance-attribute
¶
kn: Optional[float] = Field(default=None, description='equivalent roughness length scale of the bottom (in m) (SWAN default: 0.05)')
Functions¶
Numerics Components¶
PROP ¶
Bases: BaseComponent
Propagation scheme.
.. code-block:: text
PROP BSTB|GSE
Notes¶
- The scheme defaults to
S&LandSORDUPfor nonstationary and stationary simulations if not specified. - All schemes (BSBT, SORDUP and S&L) can be used in combination with curvilinear grids. With the higher order schemes (S&L and SORDUP) it is important to use a gradually varying grid otherwise there may be a severe loss of accuracy. If sharp transitions in the grid cannot be avoided it is safer to use the BSBT scheme.
- In the computation with unstructured meshes, a lowest order upwind scheme will be employed. This scheme is very robust but rather diffusive. This may only be significant for the case when swell waves propagate over relative large distances (in the order of thousands of kilometers) within the model domain. However and most fortunately, in such a case this will alleviate the garden-sprinkler effect.
- Alleviating the garden-sprinkler effect by adding some diffusion makes the SWAN
computation conditionally stable. You can either use (i) a smaller time step,
(ii) a lower value of
waveage, (iii) better resolution in the directional space, or (iv) worse resolution in the geographic space, in order of preference, to make the model stable when necessary.
Examples¶
.. ipython:: python :okwarning:
from rompy_swan.components.numerics import PROP
prop = PROP()
print(prop.render())
prop = PROP(scheme=dict(model_type="bsbt"))
print(prop.render())
prop = PROP(
scheme=dict(
model_type="gse",
waveage=dict(delt="PT5H", dfmt="hr"),
),
)
print(prop.render())
Source code in src/rompy_swan/components/numerics.py
NUMERIC ¶
Bases: BaseComponent
Numerical properties.
.. code-block:: text
NUMeric ( STOPC [dabs] [drel] [curvat] [npnts] ->STAT|NONSTAT [limiter] ) &
( DIRimpl [cdd] ) ( SIGIMpl [css] [eps2] [outp] [niter] ) &
( CTheta [cfl] ) ( CSigma [cfl] ) ( SETUP [eps2] [outp] [niter] )
Examples¶
.. ipython:: python :okwarning:
from rompy_swan.components.numerics import NUMERIC
numeric = NUMERIC()
print(numeric.render())
numeric = NUMERIC(
stop=dict(
model_type="stopc",
dabs=0.05,
drel=0.01,
curvat=0.05,
npnts=99.5,
),
dirimpl=dict(cdd=0.5),
sigimpl=dict(css=0.5, eps2=1e-4, outp=0, niter=20),
ctheta=dict(cfl=0.9),
csigma=dict(cfl=0.9),
setup=dict(eps2=1e-4, outp=0, niter=20),
)
print(numeric.render())
Source code in src/rompy_swan/components/numerics.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
Attributes¶
model_type
class-attribute
instance-attribute
¶
model_type: Literal['numeric', 'NUMERIC'] = Field(default='numeric', description='Model type discriminator')
stop
class-attribute
instance-attribute
¶
stop: Optional[Union[STOPC, ACCUR]] = Field(default=None, description='Iteration termination criteria', discriminator='model_type')
dirimpl
class-attribute
instance-attribute
¶
dirimpl: Optional[DIRIMPL] = Field(default=None, description='Numerical scheme for refraction')
sigimpl
class-attribute
instance-attribute
¶
sigimpl: Optional[SIGIMPL] = Field(default=None, description='Frequency shifting accuracy')
ctheta
class-attribute
instance-attribute
¶
ctheta: Optional[CTHETA] = Field(default=None, description='Prevents excessive directional turning')
csigma
class-attribute
instance-attribute
¶
csigma: Optional[CSIGMA] = Field(default=None, description='Prevents excessive frequency shifting')
setup
class-attribute
instance-attribute
¶
setup: Optional[SETUP] = Field(default=None, description='Stop criteria in the computation of wave setup')
Functions¶
cmd ¶
Command file string for this component.
Source code in src/rompy_swan/components/numerics.py
Output Components¶
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 src/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 src/rompy_swan/components/output.py
cmd ¶
Command file string for this component.
Source code in src/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 src/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 src/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 src/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 src/rompy_swan/components/output.py
Group Components¶
STARTUP ¶
Bases: BaseGroupComponent
Startup group component.
.. code-block:: text
PROJECT ...
SET ...
MODE ...
COORDINATES ...
This group component is used to group individual startup components. Only fields that are explicitly prescribed are rendered by this group component.
Examples¶
.. ipython:: python :okwarning:
from rompy_swan.components.startup import PROJECT, SET, MODE, COORDINATES
from rompy_swan.components.group import STARTUP
proj = PROJECT(nr="01")
set = SET(level=0.5, direction_convention="nautical")
mode = MODE(kind="nonstationary", dim="twodimensional")
coords = COORDINATES(kind=dict(model_type="spherical", projection="ccm"))
startup = STARTUP(
project=proj,
set=set,
mode=mode,
coordinates=coords,
)
print(startup.render())
Source code in src/rompy_swan/components/group.py
Attributes¶
model_type
class-attribute
instance-attribute
¶
model_type: Literal['startup', 'STARTUP'] = Field(default='startup', description='Model type discriminator')
coordinates
class-attribute
instance-attribute
¶
Functions¶
cmd ¶
Command file string for this component.
Source code in src/rompy_swan/components/group.py
PHYSICS ¶
Bases: BaseGroupComponent
Physics group component.
The physics group component is a convenience to allow specifying several individual components in a single command and check for consistency between them.
Exemples¶
.. ipython:: python :okwarning:
from rompy_swan.components.group import PHYSICS
gen = {"model_type": "gen3", "source_terms": {"model_type": "komen"}}
phys = PHYSICS(gen=gen)
print(phys.render())
phys = PHYSICS(
gen=dict(model_type="gen3", source_terms={"model_type": "st6c1"}),
negatinp={"model_type": "negatinp", "rdcoef": 0.04},
sswell={"model_type": "zieger"},
breaking={"model_type": "constant", "alpha": 1.0, "gamma": 0.73},
friction={"model_type": "jonswap", "cfjon": 0.038},
)
print(phys.render())
Source code in src/rompy_swan/components/group.py
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 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 | |
Attributes¶
model_type
class-attribute
instance-attribute
¶
model_type: Literal['physics', 'PHYSICS'] = Field(default='physics', description='Model type discriminator')
negatinp
class-attribute
instance-attribute
¶
wcapping
class-attribute
instance-attribute
¶
quadrupl
class-attribute
instance-attribute
¶
breaking
class-attribute
instance-attribute
¶
friction
class-attribute
instance-attribute
¶
vegetation
class-attribute
instance-attribute
¶
turbulence
class-attribute
instance-attribute
¶
obstacle
class-attribute
instance-attribute
¶
diffraction
class-attribute
instance-attribute
¶
surfbeat
class-attribute
instance-attribute
¶
deactivate
class-attribute
instance-attribute
¶
Functions¶
deactivate_physics
classmethod
¶
Convert OFF to OFFS so list is rendered.
negatinp_only_with_zieger ¶
negatinp_only_with_zieger() -> PHYSICS
Log a warning if NEGATINP is used with a non-ZIEGER SSWELL.
Source code in src/rompy_swan/components/group.py
cmd ¶
Source code in src/rompy_swan/components/group.py
INPGRIDS ¶
Bases: BaseGroupComponent
SWAN input grids group component.
.. code-block:: text
INPGRID ...
READGRID ...
INPGRID ...
READGRID ...
...
This group component is a convenience to allow defining and rendering a list of input grid components.
Examples¶
.. ipython:: python :okwarning:
from rompy_swan.components.inpgrid import REGULAR, ICE
from rompy_swan.components.group import INPGRIDS
inpgrid_bottom = REGULAR(
grid_type="bottom",
excval=-99.0,
xpinp=172.0,
ypinp=-41.0,
alpinp=0.0,
mxinp=99,
myinp=99,
dxinp=0.005,
dyinp=0.005,
readinp=dict(fname1="bottom.txt"),
)
inpgrid_wind = REGULAR(
grid_type="wind",
excval=-99.0,
xpinp=172.0,
ypinp=-41.0,
alpinp=0.0,
mxinp=99,
myinp=99,
dxinp=0.005,
dyinp=0.005,
readinp=dict(fname1="wind.txt"),
nonstationary=dict(
tbeg="2019-01-01T00:00:00",
tend="2019-01-07 00:00:00",
delt=3600,
dfmt="hr",
),
)
inpgrid_ice_cte = ICE(aice=0.8, hice=2.0)
inpgrids = INPGRIDS(inpgrids=[inpgrid_bottom, inpgrid_wind, inpgrid_ice_cte])
print(inpgrids.render())
Source code in src/rompy_swan/components/group.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 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 | |
Attributes¶
model_type
class-attribute
instance-attribute
¶
inpgrids
class-attribute
instance-attribute
¶
Functions¶
ensure_unique_grid_type
classmethod
¶
Ensure that each grid type is unique.
Source code in src/rompy_swan/components/group.py
OUTPUT ¶
Bases: BaseGroupComponent
Output group component.
.. code-block:: text
FRAME 'sname' ...
GROUP 'sname' ...
CURVE 'sname' ...
RAY 'rname' ...
ISOLINE 'sname' 'rname' ...
POINTS 'sname ...
NGRID 'sname' ...
QUANTITY ...
OUTPUT OPTIONS ...
BLOCK 'sname' ...
TABLE 'sname' ...
SPECOUT 'sname' ...
NESTOUT 'sname ...
This group component is used to define multiple types of output locations and write components in a single model. Only fields that are explicitly prescribed are rendered by this group component.
Note¶
The components prescribed are validated according to some constraints as defined in the SWAN manual:
- The name
'sname'of each Locations component must be unique. - The Locations
'sname'assigned to each write component must be defined. - The BLOCK component must be associated with either a
FRAMEorGROUP. - The ISOLINE write component must be associated with a
RAYcomponent. - The NGRID and NESTOUT components must be defined together.
Examples¶
.. ipython:: python :okwarning:
from rompy_swan.components.output import POINTS, BLOCK, QUANTITIES, TABLE
from rompy_swan.components.group import OUTPUT
points = POINTS(sname="outpts", xp=[172.3, 172.4], yp=[-39, -39])
quantity = QUANTITIES(
quantities=[
dict(output=["depth", "hsign", "tps", "dir", "tm01"], excv=-9),
]
)
times = dict(tbeg="2012-01-01T00:00:00", delt="PT30M", tfmt=1, dfmt="min")
block = BLOCK(
model_type="block",
sname="COMPGRID",
fname="./swangrid.nc",
output=["depth", "hsign", "tps", "dir"],
times=times,
)
table = TABLE(
sname="outpts",
format="noheader",
fname="./swantable.nc",
output=["hsign", "hswell", "dir", "tps", "tm01", "watlev", "qp"],
times=times,
)
out = OUTPUT(
points=points,
quantity=quantity,
block=block,
table=table,
)
print(out.render())
Source code in src/rompy_swan/components/group.py
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 | |
Attributes¶
model_type
class-attribute
instance-attribute
¶
model_type: Literal['output', 'OUTPUT'] = Field(default='output', description='Model type discriminator')
quantity
class-attribute
instance-attribute
¶
output_options
class-attribute
instance-attribute
¶
Functions¶
write_locations_exists ¶
write_locations_exists() -> OUTPUT
Ensure the location component requested by a write component exists.
Source code in src/rompy_swan/components/group.py
locations_sname_unique ¶
locations_sname_unique() -> OUTPUT
Ensure same sname isn't used in more than one set of output locations.
Source code in src/rompy_swan/components/group.py
block_with_frame_or_group ¶
block_with_frame_or_group() -> OUTPUT
Ensure Block is only defined for FRAME or GROUP locations.
Source code in src/rompy_swan/components/group.py
isoline_ray_defined ¶
isoline_ray_defined() -> OUTPUT
Ensure the isoline ray has been defined.
Source code in src/rompy_swan/components/group.py
ngrid_and_nestout ¶
ngrid_and_nestout() -> OUTPUT
Ensure NGRID and NESTOUT are specified together.
Source code in src/rompy_swan/components/group.py
cmd ¶
Command file string for this component.
Source code in src/rompy_swan/components/group.py
LOCKUP ¶
Bases: BaseComponent
Lockup group component.
.. code-block:: text
COMPUTE ...
HOTFILE ...
COMPUTE ...
HOTFILE ...
...
STOP
This is a group component to specify SWAN "Lockup" commands including multiple
COMPUTE commands that may or may not be interleaved with HOTFILE commands,
and a final STOP command.
Examples¶
.. ipython:: python :okwarning:
from rompy_swan.components.group import LOCKUP
lockup = LOCKUP(
compute=dict(
model_type="stat",
times=dict(
model_type="nonstationary",
tbeg="1990-01-01T00:00:00",
tend="1990-01-01T03:00:00",
delt="PT1H",
dfmt="hr",
),
hotfile=dict(fname="hotfile"),
hottimes=[-1],
),
)
print(lockup.render())