Last updated on Feb 20, 2026.

netsse.model.envir_cond#

Relevant functions for environmental conditions.

Copyright (C) 2023-2026 Technical University of Denmark, R.E.G. Mounet

This code is part of the NetSSE software.

NetSSE is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

NetSSE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

To credit the author, users are encouraged to use below reference:

Mounet, R. E. G., & Nielsen, U. D. NetSSE: An open-source Python package
for network-based sea state estimation from ships, buoys, and other
observation platforms (version 2.2). Technical University of Denmark,
GitLab. February 2026. https://doi.org/10.11583/DTU.26379811.

Last updated on 20-02-2026 by R.E.G. Mounet

Functions#

JONSWAP_DNV(Tp, Hs, omega[, gamma, h])

Computes the JONSWAP spectrum corresponding to the input sea state

fit_spec_tail(f, S, fc[, exponent, fmax, n_tail, ...])

Extend a 1-D wave spectrum \(S(f)\) with an \(f^{-n}\) tail beyond \(f_c\).

lin_disprel(input[, h, direction])

Computes the wavenumbers from wave angular frequencies, or vice-versa, using the linear dispersion relationship.

wavespec1dto2d(S1d, theta, theta0, s)

Transforms a 1-D wave spectrum into a 2-D wave spectrum.

Module Contents#

netsse.model.envir_cond.JONSWAP_DNV(Tp, Hs, omega, gamma='standard', h=0)[source]#

Computes the JONSWAP spectrum corresponding to the input sea state parameters.

The JONSWAP spectrum is formulated as a modification of a Pierson-Moskowitz spectrum for a developing sea state in a fetch limited situation.

Parameters:
  • Tp (float) – Peak period [s].

  • Hs (float) – Significant wave height [m].

  • omega (array_like of shape (Nfreq,)) – Vector of angular frequencies [rad/s].

  • gamma ({'standard','DNV',float}, optional) –

    Peak shape parameter [-]. The value can be user-provided as a float. Alternatively, if 'standard' is input, then gamma will take the standard value of 3.3., while a value 'DNV' as input leads to following the procedure 3.5.5.5 described in DNV-RP-C205.

    Tip

    Use gamma = 1 to output a standard Pierson-Moskowitz spectrum.

  • h (float, default 0) – Water depth [m]. If h is specified as input argument, then the output JONSWAP spectrum is corrected to account for finite water depth, becoming a standard TMA spectrum as per Bouws et al. (1985).

Returns:

S_J – Standard wave spectrum [m^2.s/rad].

Return type:

array_like of shape (Nfreq,)

References

  1. DNV-RP-C205, “Environmental Conditions and Environmental Loads, April 2007.

  2. Bouws, E., Gunther, H., Rosenthal, W., & Vincent, C. L. (1985). Similarity of the wind wave spectrum in finite depth water. 1. Spectral form. Journal of Geophysical Research-Oceans, 90(NC1), 975–986. https://doi.org/10.1029/JC090iC01p00975

See also

lin_disprel

A fast and accurate approximation of the linear wave dispersion relationship in finite water depth.

Example

>>> S_J = JONSWAP_DNV(Tp,Hs,omega,gamma='standard',h=0)
netsse.model.envir_cond.fit_spec_tail(f, S, fc, exponent=5, fmax=None, n_tail=256, amplitude_mode='match_fc', transition_width=0.0)[source]#

Extend a 1-D wave spectrum \(S(f)\) with an \(f^{-n}\) tail beyond \(f_c\).

Parameters:
  • f (array_like) – 1-D array of frequencies [Hz], strictly increasing.

  • S (array_like) – 1-D array of spectral densities [m^2/Hz], same length as f.

  • fc (float) – Cutoff frequency \(f_c\) [Hz]; must be within the range of f.

  • exponent (float) – Exponent \(n\) of the power-law tail to fit beyond \(f_c\). Default is 5 for a typical high-frequency wave spectrum tail.

  • fmax (float or None) – Maximum frequency for the extended tail. If None (default), set to 2fc.

  • n_tail (int) – Number of points to generate in \((f_c, f_{\max}]\). Default is 256.

  • amplitude_mode ({"match_fc", "least_squares", "median"}) –

    How to estimate the tail amplitude \(C\) in \(S(f) \sim C f^{-n}\) beyond \(f_c\).

    Options are:

    • match_fc (default): \(C = S(f_c) \cdot f_c^n\) using interpolation at \(f_c\).

    • least_squares: fit \(C\) by minimizing \(\sum (S - C f^{-n})^2\) over a band near \(f_c\).

    • median: \(C = \mathrm{median}(S \cdot f^n)\) over a band near \(f_c\) (robust to outliers).

  • transition_width (float) – Width of cosine blend band [Hz] below \(f_c\) to smoothly transition from original spectrum to the tail. If set to 0 (default), hard splice at \(f_c\).

Returns:

  • f_ext (ndarray) – Extended frequency vector including original f and new tail points.

  • S_ext (ndarray) – Spectrum values aligned with f_ext.

  • C (float) – Tail amplitude used in \(S_{tail} = C \cdot f^{-n}\).

Example

>>> f = np.linspace(0.05, 1.0, 100)
>>> S = 0.1 * f**-3 * np.exp(- (f / 0.3)**2)  # Example spectrum
>>> fc = 0.5
>>> f_ext, S_ext, C = fit_spec_tail(f, S, fc, exponent=5, amplitude_mode="least_squares", transition_width=0.1)
netsse.model.envir_cond.lin_disprel(input, h=None, direction='om2k')[source]#

Computes the wavenumbers from wave angular frequencies, or vice-versa, using the linear dispersion relationship.

If the water depth is specified, then the finite water depth is accounted for. Otherwise, deep water is assumed.

In the “om2k” direction in finite water depth, this function implements a fast and accurate approximation of the linear wave dispersion relationship. In the “k2om” direction, the function always uses the exact linear dispersion relationship.

Parameters:
  • input (array_like or float) – The input, which can either be the wave angular frequencies [rad/s] or the wavenumbers [1/m], depending on the direction.

  • h (array_like or float, optional) – Mean water depth [m]

  • direction ({'om2k','k2om'}, optional) – Direction of the dispersion relation to be solved. If 'om2k', then the function computes the wavenumbers from the angular frequencies. If 'k2om', then the function computes the angular frequencies from the wavenumbers.

Returns:

output – The corresponding wavenumbers [1/m] or wave angular frequencies [rad/s] to input, depending on the direction.

Return type:

array_like or float

Example

>>> k = lin_disprel(omega, h)
netsse.model.envir_cond.wavespec1dto2d(S1d, theta, theta0, s)[source]#

Transforms a 1-D wave spectrum into a 2-D wave spectrum.

A cosine-2s function is used for the directional spreading distribution.

Parameters:
  • S1d (array_like of shape (Nfreq,)) – 1-D wave spectrum.

  • theta (array_like of shape (Ntheta,)) – Vector of wave headings [deg] at which the 2-D spectrum must be computed.

  • theta0 (float) – Mean wave direction [deg].

  • s (float) – Spreading parameter [-], related to the exponent of the cosine function.

Returns:

  • S2d (array_like of shape (Nfreq,Ntheta)) – 2-D wave spectrum, as a function of both the frequency and the wave heading [deg].

  • D_theta (array_like of shape (1,Ntheta)) – Directional spreading function, as a function of the wave heading [deg].

References

Naess, Arvid, and Torgeir Moan. 2010. Stochastic Dynamics of Marine Structures. Stochastic Dynamics of Marine Structures. Vol. 9780521881555. Cambridge University Press. https://doi.org/10.1017/CBO9781139021364.

Example

>>> S2d = wavespec1dto2d(S1d,theta,theta0,s)