wecopttool.waves.omnidirectional_spectrum

omnidirectional_spectrum(f1, nfreq, spectrum_func, spectrum_name='')[source]

Create the xarray.DataArray for an omnidirectional wave spectrum in the wavespectra.SpecArray format.

Examples

Define wave parameters.

>>> from wecopttool.waves import omnidirectional_spectrum as omnispec
>>> from wecopttool.waves import pierson_moskowitz_spectrum as pm
>>> Hs = 5
>>> Tp = 6
>>> fp = 1/Tp

Generate the wave using a Pierson-Moskowitz idealized spectrum.

>>> omnidirectional_spectrum = omnispec(
...     f1=fp/10,
...     nfreq=30,
...     spectrum_func=lambda f: pm(freq=f, fp=fp, hs=Hs),
...     spectrum_name="Pierson-Moskowitz",
...     )
Parameters:
  • f1 (float) – Fundamental frequency f1 [Hz].

  • nfreq (int) – Number of frequencies (not including zero frequency), i.e., freq = [0, f1, 2*f1, ..., nfreq*f1].

  • spectrum_func (Callable) – Wave spectrum function. Maps frequencies to amplitude spectrum. Union[float, ArrayLike] -> Union[float, ndarray]. Units: \(m^2/Hz\).

  • spectrum_name (str) – Name of the spectrum function.

Return type:

DataArray