4Subsea / waveresponse-python

Vessel motion and wave utilities
https://docs.4insight.io/waveresponse/python/latest/
MIT License
12 stars 4 forks source link

1d spectra with direction #61

Open RubendeBruin opened 5 months ago

RubendeBruin commented 5 months ago

Motivation For quick response calculations or conservative estimates, it can be beneficial to work with one dimensional wave-spectra. This is a wave-spectrum without any spreading.

Suggested implementation This can be implemented as a directional spectrum with only a single heading.

DirectionalSpectrum add:

    @property
    def is_oned(self):
        """
        Check if the spectrum is a 1-D spectrum. This is the case when only a single direction is defined

        Returns
        -------
        bool :
            ``True`` if the spectrum is a 1-D spectrum, and ``False`` otherwise.
        """
        return self._dirs.shape[0] == 1

in constructor, energy conversion to degrees only when 2d:

        if not self.is_oned:
            if degrees:
                self._vals = 180.0 / np.pi * self._vals

in spectrum1d, return the only direction available.

        if freq_hz is None:
            freq_hz = self._freq_hz

        if self.is_oned:

            f = self._freq.copy()
            v = self._vals.copy().flatten()

            if freq_hz:
                return f / (2.0 * np.pi),  (2.0 * np.pi) * v
            else:
                return f, v

        if axis == 1:
            degrees = False

and probably in some other places as well.