netsse.analys.dsa
=================

.. py:module:: netsse.analys.dsa

.. autoapi-nested-parse::

   Functions for **transforming spectra** observed from advancing floating platforms.

   .. dropdown:: Copyright (C) 2023-2026 Technical University of Denmark, R.E.G. Mounet
       :color: primary
       :icon: law

       *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:

       .. code-block:: text

           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
---------

.. autoapisummary::

   netsse.analys.dsa.polynom_DSA
   netsse.analys.dsa.trans_2Dmat_DSA


Module Contents
---------------

.. py:function:: polynom_DSA(tau, om0m, weighting='uniform', nu23=None, full_output=False)

   Computes the polynomial approximation of the Doppler Shift.

   .. note::
       This implementation uses the derivations presented in Mounet et al. (2025, 2026).

   :param tau: Array of Doppler shift intensities.
   :type tau: array_like of shape (Ntau,)
   :param om0m: Cut-off frequency of the DSA.
   :type om0m: float
   :param weighting: Weighting method to use:

                     - 'uniform' :
                         Equal weight is given to all frequencies in the range ``[0,om0m]`` in the cost
                         function. This is the default option. It is introduced in Mounet et al. (2025).
                     - 'tripvalpb' :
                         Same as ``'uniform'`` weighting, but the ``om0m`` is set to a value of
                         :math:`(1+\sqrt{2})/(2\tau)` when :math:`\nu>\nu_{23}`. This ensures the DSA features
                         an optimal accuracy in the range of frequencies where the triple-value problem occurs.
                         This idea is introduced in Mounet et al. (2026).
                     - 'lowfreq' :
                         A decreasing (affine) weighting function is applied in the range ``[0,om0m]``, such
                         that low frequencies are given more importance in the cost function. This option is not
                         recommended for general use.
   :type weighting: {'uniform','tripvalpb','lowfreq'}, optional
   :param nu23: Threshold value of ``nu`` for switching between the concave and convex forms of the
                approximation. Default is ``None``, which means that the convex form is not used.
   :type nu23: float, optional
   :param full_output: If True, the function returns ``nu``and ``kappa`` as additional outputs. Default is False.
   :type full_output: bool, optional

   :returns: * **rho_p** (*array_like of shape (Ntau,)*) -- Computed ``rho_p`` values.
             * **nu_p** (*array_like of shape (Ntau,)*) -- Computed ``nu_p`` values.
             * **nu** (*array_like of shape (Ntau,)*) -- Computed ``nu`` values.
             * **kappa** (*array_like of shape (Ntau,)*) -- Computed ``kappa`` values.

   .. seealso::

      :py:obj:`trans_2Dmat_DSA`
          Computes the matrices for applying the Doppler shift approximation (DSA).

   .. rubric:: References

   1. Mounet, R.E.G., Nielsen, U.D., and Takami, T. (2025). "Doppler Shift Approximation in
      Seakeeping Problems: A New Formulation for Ships Advancing at Any Forward Speed." In:
      Proceedings of the 16th International Symposium on Practical Design of Ships and Other
      Floating Structures (PRADS 2025), Ann Arbor, MI, USA. (Accepted).
   2. Mounet, R.E.G., Nielsen, U.D., and Takami, T. (2026). "Approximating the Doppler Shift in
      Sea-Wave Spectra Observed from an Advancing Floating Platform." Applied Mathematical
      Modelling. (Submitted).

   .. rubric:: Example

   >>> rho_p, nu_p = polynom_DSA(tau, om0m, weighting='tripvalpb', full_output=False)


.. py:function:: trans_2Dmat_DSA(freq_in, beta, U, freq_out=None, unit_freq='rad/s', unit_beta='deg', conv='from', max_freq=None, nu23=None, transform='abs2enc', weighting='uniform', highfreq_matching=True)

   Computes the transformation matrices for applying the Doppler shift approximation (DSA) at the given forward speed and for the given frequency and direction discretizations.

   .. note::
       This implementation uses the derivations presented in Mounet et al. (2025, 2026).

   :param freq_in: Input frequencies.
   :type freq_in: array_like of shape (NfreqIN,)
   :param beta: Relative wave heading angles.
   :type beta: array_like of shape (Nbeta,)
   :param U: Forward speed of the observer [m/s].
   :type U: float
   :param freq_out: Output frequencies. If None, it is set to freq_in.
   :type freq_out: array_like of shape (NfreqOUT), optional
   :param unit_freq: Unit of the frequencies:

                     - 'rad/s' :
                         The variables ``freq_in`` and ``freq_out`` denote the angular frequencies in radians
                         per second. The default is 'rad/s'.
                     - 'Hz' :
                         Frequencies are in Hertz.
   :type unit_freq: {'rad/s','Hz'}, optional
   :param unit_beta: Unit of the relative wave heading angles ``beta`` ('deg' or 'rad'). Default is 'deg'.
   :type unit_beta: {'deg','rad'}, optional
   :param conv: The convention that is used to express the direction ``beta`` of wave spectrum:

                - 'from' :
                    The naval architecture convention, indicating where the waves are COMING FROM.
                - 'to' :
                    The oceanographic convention, indicating where the waves are GOING TO.
                    The default is "from" direction.
   :type conv: {'from','to'}, optional
   :param max_freq: Cut-off frequency. If None, it is set to the maximum of ``freq_in``.
   :type max_freq: float, optional
   :param nu23: Threshold value of ``nu`` for switching between the concave and convex forms of the
                approximation. Default is ``None``, which means that the convex form is not used.
   :type nu23: float, optional
   :param transform: Type of transformation ('abs2enc' or 'enc2abs'). Default is 'abs2enc'.
   :type transform: str, optional
   :param weighting: Weighting method to use:

                     - 'uniform' :
                         Equal weight is given to all frequencies in the range [0,om0m] in the cost function.
                         This is the default option. It is introduced in Mounet et al. (2025).
                     - 'tripvalpb' :
                         Same as ``'uniform'`` weighting, but the ``om0m`` is set to a value of
                         :math:`(1+\sqrt{2})/(2\tau)` when :math:`\nu>\nu_{23}`. This ensures the DSA features
                         an optimal accuracy in the range of frequencies where the triple-value problem occurs.
                         This idea is introduced in Mounet et al. (2026).
                     - 'lowfreq' :
                         A decreasing (affine) weighting function is applied to frequencies in the range
                         [0,om0m], such that low frequencies are given more importance in the cost function.
                         This option is not recommended for general use.
   :type weighting: {'uniform','tripvalpb','lowfreq'}, optional
   :param highfreq_matching: If ``True``, the convex form of the DSA is overriden to become exact beyond the point where
                             the DSA and the exact Doppler shift intersect each other in Region III of the mapping.
                             If ``False``, the DSA is kept unchanged otherwise. Default is True.
   :type highfreq_matching: bool, optional

   :returns: * **Omega_in_fromout** (*ndarray of shape (NfreqOUT,Nbeta)*) -- Approximated input frequencies as a function of the target frequencies and wave directions.
             * **C** (*ndarray of shape (NfreqOUT*Nbeta,NfreqIN*Nbeta)*) -- Linear interpolation matrix.
             * **D_wave** (*ndarray of shape (NfreqOUT*Nbeta,NfreqOUT*Nbeta)*) -- 2D-to-2D transformation matrix for wave spectra.
             * **S** (*ndarray of shape (NfreqOUT,NfreqOUT*Nbeta)*) -- 2D-to-1D summation matrix.

   .. seealso::

      :py:obj:`polynom_DSA`
          Computes the polynomial approximation of the Doppler Shift.

   .. rubric:: References

   1. Mounet, R.E.G., Nielsen, U.D., and Takami, T. (2025). "Doppler Shift Approximation in
      Seakeeping Problems: A New Formulation for Ships Advancing at Any Forward Speed." In:
      Proceedings of the 16th International Symposium on Practical Design of Ships and Other
      Floating Structures (PRADS 2025), Ann Arbor, MI, USA. (Accepted).
   2. Mounet, R.E.G., Nielsen, U.D., and Takami, T. (2026). "Approximating the Doppler Shift in
      Sea-Wave Spectra Observed from an Advancing Floating Platform." Applied Mathematical
      Modelling. (Submitted).

   .. rubric:: Example

   >>> _, C, D, S = trans_2Dmat_DSA(
   ...     freq_in, beta, U, freq_out, unit_freq='Hz', unit_beta='deg', conv='from', max_freq=0.3,
   ...     transform='abs2enc', weighting="uniform", highfreq_matching=True)


