Spectrum
Sub-commands to support spectrum definition
SPECTRUM
Bases: BaseSubComponent
SWAN spectrum specification.
.. code-block:: text
->CIRCLE|SECTOR ([dir1] [dir2]) [mdc] [flow] [fhigh] [msc]
Notes
Directions in the spectra are defined either as a CIRCLE or as a SECTOR. In the
case of a SECTOR, both dir1 and dir2 must be specified. In the case of a
CIRCLE, neither dir1 nor dir2 should be specified.
At least two of flow, fhigh and msc must be specified in which case the
third parameter will be calculated by SWAN such that the frequency resolution
df/f = 0.1 (10% increments).
Examples
.. ipython:: python :okwarning:
from rompy_swan.subcomponents.spectrum import SPECTRUM
spec = SPECTRUM(mdc=36, flow=0.04, fhigh=1.0)
print(spec.render())
spec = SPECTRUM(mdc=36, dir1=0, dir2=180, flow=0.04, msc=31)
print(spec.render())
Source code in rompy_swan/subcomponents/spectrum.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 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 | |
Attributes
model_type
class-attribute
instance-attribute
model_type: Literal['spectrum', 'SPECTRUM'] = Field(default='spectrum', description='Model type discriminator')
mdc
class-attribute
instance-attribute
mdc: int = Field(description='Number of meshes in theta-space. In the case of CIRCLE, this is the number of subdivisions of the 360 degrees of a circle so `dtheta = [360]/[mdc]` is the spectral directional resolution. In the case of SECTOR, `dtheta = ([dir2] - [dir1])/[mdc]`. The minimum number of directional bins is 3 per directional quadrant.')
flow
class-attribute
instance-attribute
flow: Optional[float] = Field(default=None, description='Lowest discrete frequency that is used in the calculation (in Hz).')
fhigh
class-attribute
instance-attribute
fhigh: Optional[float] = Field(default=None, description='Highest discrete frequency that is used in the calculation (in Hz).')
msc
class-attribute
instance-attribute
msc: Optional[int] = Field(default=None, description='One less than the number of frequencies. This defines the grid resolution in frequency-space between the lowest discrete frequency `flow` and the highest discrete frequency `fhigh`. This resolution is not constant, since the frequencies are distributed logarithmical: `fi+1 = yfi` where `y` is a constant. The minimum number of frequencies is 4', ge=3)
dir1
class-attribute
instance-attribute
dir1: Optional[float] = Field(default=None, description='The direction of the right-hand boundary of the sector when looking outward from the sector (required for option SECTOR) in degrees.')
dir2
class-attribute
instance-attribute
dir2: Optional[float] = Field(default=None, description='The direction of the left-hand boundary of the sector when looking outward from the sector (required for option SECTOR) in degrees.')
Functions
check_direction_definition
classmethod
Check that dir1 and dir2 are specified together.
Source code in rompy_swan/subcomponents/spectrum.py
check_frequency_definition
check_frequency_definition() -> SPECTRUM
Check spectral frequencies are prescribed correctly.
Source code in rompy_swan/subcomponents/spectrum.py
cmd
Source code in rompy_swan/subcomponents/spectrum.py
SHAPESPEC
Bases: BaseSubComponent
Spectral shape specification.
.. code-block:: text
BOUND SHAPESPEC JONSWAP|PM|GAUSS|BIN|TMA PEAK|MEAN DSPR [POWER|DEGREES]
This command BOUND SHAPESPEC defines the shape of the spectra (both in frequency and direction) at the boundary of the computational grid in case of parametric spectral input.
Notes
While technically a component BOUND SHAPESPEC, this is only intended to be used
as a subcomponent of the BOUNDSPEC component.
Examples
.. ipython:: python :okwarning:
from rompy_swan.subcomponents.spectrum import SHAPESPEC
shapespec = SHAPESPEC()
print(shapespec.render())
shapespec = SHAPESPEC(
shape=dict(model_type="tma", gamma=3.1, d=12),
per_type="mean",
dspr_type="degrees",
)
print(shapespec.render())
Source code in rompy_swan/subcomponents/spectrum.py
Attributes
model_type
class-attribute
instance-attribute
model_type: Literal['shapespec', 'SHAPESPEC'] = Field(default='shapespec', description='Model type discriminator')
shape
class-attribute
instance-attribute
shape: JONSWAP | PM | GAUSS | BIN | TMA = Field(default_factory=JONSWAP, description='The spectral shape')
per_type
class-attribute
instance-attribute
per_type: Literal['peak', 'mean'] = Field(default='peak', description='The type of characteristic wave period')
dspr_type
class-attribute
instance-attribute
dspr_type: Literal['power', 'degrees'] = Field(default='power', description='The type of directional spreading')
Functions
JONSWAP
Bases: BaseSubComponent
Jonswap spectral shape.
.. code-block:: text
JONSWAP [gamma]
Examples
.. ipython:: python :okwarning:
from rompy_swan.subcomponents.spectrum import JONSWAP
shape = JONSWAP(gamma=3.3)
print(shape.render())
Source code in rompy_swan/subcomponents/spectrum.py
Attributes
model_type
class-attribute
instance-attribute
model_type: Literal['jonswap', 'JONSWAP'] = Field(default='jonswap', description='Model type discriminator')
gamma
class-attribute
instance-attribute
gamma: float = Field(default=3.3, description='Peak enhancement parameter of the JONSWAP spectrum.', gt=0.0)
Functions
TMA
Bases: JONSWAP
TMA spectral shape.
.. code-block:: text
TMA [gamma] [d]
Examples
.. ipython:: python :okwarning:
from rompy_swan.subcomponents.spectrum import TMA
shape = TMA(gamma=2.0, d=18)
print(shape.render())
Source code in rompy_swan/subcomponents/spectrum.py
Attributes
model_type
class-attribute
instance-attribute
d
class-attribute
instance-attribute
Functions
GAUSS
Bases: BaseSubComponent
Gaussian spectral shape.
.. code-block:: text
GAUSS [sigfr]
Examples
.. ipython:: python :okwarning:
from rompy_swan.subcomponents.spectrum import GAUSS
shape = GAUSS(sigfr=0.02)
print(shape.render())
Source code in rompy_swan/subcomponents/spectrum.py
Attributes
model_type
class-attribute
instance-attribute
model_type: Literal['gauss', 'GAUSS'] = Field(default='gauss', description='Model type discriminator')
sigfr
class-attribute
instance-attribute
sigfr: float = Field(description='Width of the Gaussian frequency spectrum expressed as a standard deviation in Hz.', gt=0.0)
Functions
PM
Bases: BaseSubComponent
Pearson-Moskowitz spectral shape.
.. code-block:: text
PM
Examples
.. ipython:: python :okwarning:
from rompy_swan.subcomponents.spectrum import PM
shape = PM()
print(shape.render())
Source code in rompy_swan/subcomponents/spectrum.py
BIN
Bases: BaseSubComponent
Single frequency bin spectral shape.
.. code-block:: text
BIN
Examples
.. ipython:: python :okwarning:
from rompy_swan.subcomponents.spectrum import BIN
shape = BIN()
print(shape.render())