netsse.base
===========

.. py:module:: netsse.base

.. autoapi-nested-parse::

   **Class definitions** for the NetSSE software.

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



Classes
-------

.. autoapisummary::

   netsse.base.Buoy
   netsse.base.Collection
   netsse.base.Network
   netsse.base.Operation
   netsse.base.Platform
   netsse.base.SeaState
   netsse.base.SeaStateCollec
   netsse.base.Spectrum
   netsse.base.Vessel
   netsse.base.WaveRadar
   netsse.base.WaveSequence
   netsse.base.WaveSpectrum


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

.. py:class:: Buoy(name = None, owner = 'undefined', operations = [], seastate_collections = [], type = 'undefined')

   Bases: :py:obj:`Platform`


   Initialises the buoy as a platform.

   :param type: Buoy type.

                .. note::
                    Consult :func:`netsse.base.Platform.__init__` for information
                    on the other parameters.
   :type type: str, default 'undefined'

   .. rubric:: Example

   >>> buoy1 = netsse.base.Buoy()


   .. py:attribute:: type
      :value: 'undefined'



.. py:class:: Collection(area = 'undefined', nature = 'undefined', origin='undefined', datetime_start=datetime.now(), datetime_end=datetime.now(), lat_min = 0, lat_max = 0, lon_min = 0, lon_max = 0)

   Initialises the data collection.

   :param area: Area of data collection.
   :type area: str, default 'undefined'
   :param nature: Nature of the data collection.
   :type nature: str, default 'undefined'
   :param origin: Origin or source of the data collection.
   :type origin: str or object, default 'undefined'
   :param datetime_start: Time coverage of the data collection.
   :type datetime_start: datetime object, default datetime.now()
   :param datetime_end: Time coverage of the data collection.
   :type datetime_end: datetime object, default datetime.now()
   :param lat_min: Latitude [deg North] at the southern/northern edge of the geographical
                   domain covered by the data collection.
   :type lat_min: float, default 0
   :param lat_max: Latitude [deg North] at the southern/northern edge of the geographical
                   domain covered by the data collection.
   :type lat_max: float, default 0
   :param lon_min: Longitude [deg East] at the western/eastern edge of the geographical
                   domain covered by the data collection.
   :type lon_min: float, default 0
   :param lon_max: Longitude [deg East] at the western/eastern edge of the geographical
                   domain covered by the data collection.
   :type lon_max: float, default 0

   .. seealso:: :py:obj:`Operation`, :py:obj:`SeaStateCollec`

   .. rubric:: Example

   >>> collec1 = netsse.base.Collection()


   .. py:attribute:: area
      :value: 'undefined'



   .. py:attribute:: datetime_end


   .. py:attribute:: datetime_start


   .. py:attribute:: lat_max
      :value: 0



   .. py:attribute:: lat_min
      :value: 0



   .. py:attribute:: lon_max
      :value: 0



   .. py:attribute:: lon_min
      :value: 0



   .. py:attribute:: nature
      :value: 'undefined'



   .. py:attribute:: origin
      :value: 'undefined'



.. py:class:: Network(name = None, nature = 'undefined', platforms = [])

   Initialises the network.

   :param name: Network name. By default, the name string is generated randomly
                in the format ``NetworkXXXX``.
   :type name: str, optional
   :param nature: Network nature.
   :type nature: str, default 'undefined'
   :param platforms: List of platforms (as `Platform` instances).
   :type platforms: list, default []

   .. seealso:: :py:obj:`Platform`

   .. rubric:: Example

   >>> plaform1 = netsse.base.Platform()
   >>> network = netsse.base.Network(platforms=[plaform1])


   .. py:method:: add_platform(*args, ignore_msg = False)

      Add a `Platform` instance to the list of platforms in the network.

      :param \*args: Platform to be added to the network.
      :type \*args: Platform object
      :param ignore_msg: If `False`, messages are printed to inform about any changes made to the network.
                         If `True`, thoses messages are turned off.
      :type ignore_msg: bool, default False

      .. rubric:: Example

      >>> plaform2 = netsse.base.Platform()
      >>> network.add_platform(platform2,ignore_msg=True)



   .. py:method:: remove_platform(*args, ignore_msg = False)

      Remove a `Platform` instance from the list of platforms in the network.

      :param \*args: Platform to be removed from the network. Identified by the corresponding
                     name or `Platform` instance.
      :type \*args: Platform object or str
      :param ignore_msg: If `False`, messages are printed to inform about any changes made to the network.
                         If `True`, thoses messages are turned off.
      :type ignore_msg: bool, default False

      .. rubric:: Example

      >>> network.remove_platform(platform1,ignore_msg=True)



   .. py:attribute:: name
      :value: None



   .. py:attribute:: nature
      :value: 'undefined'



   .. py:attribute:: platforms
      :value: []



.. py:class:: Operation(id = None, area = 'undefined', nature = 'undefined', origin='undefined', datetime_start=datetime.now(), datetime_end=datetime.now(), lat_min = 0, lat_max = 0, lon_min = 0, lon_max = 0, segments = [])

   Initialises the operation.

   :param id: Operation identifier. By default, the id string is generated randomly
              in the format ``OperXXXXX``.
   :type id: str, optional
   :param segments: List of segments (as `Segment` instances) gathered during the operation.

                    .. note::
                        Consult :func:`netsse.base.Collection.__init__` for information on
                        the other parameters.
   :type segments: list, default []

   .. seealso:: :py:obj:`Collection`, :py:obj:`Platform`, :py:obj:`Segment`

   .. rubric:: Example

   >>> operation1 = netsse.base.Operation()


   .. py:attribute:: id
      :value: None



   .. py:attribute:: segments
      :value: []



.. py:class:: Platform(name = None, owner = 'undefined', operations = [], seastate_collections = [])

   Initialises the platform.

   :param name: Name of the platform. By default, the name string is generated randomly
                in the format ``PlatformXXXXX``.
   :type name: str, optional
   :param owner: Platform owner.
   :type owner: str, default 'undefined'
   :param operations: List of operations.
   :type operations: list, default []
   :param seastate_collections: List of sea state collections (as `SeaStateCollec` instances).
   :type seastate_collections: list, default []

   .. seealso:: :py:obj:`Network`, :py:obj:`Operation`, :py:obj:`SeaStateCollec`, :py:obj:`Vessel`, :py:obj:`Buoy`, :py:obj:`WaveRadar`

   .. rubric:: Example

   >>> operation1 = netsse.base.Operation()
   >>> seastatecollec1 = netsse.base.SeaStateCollec()
   >>> platform1 = netsse.base.Platform(name='MyPlatform',owner='SomeCompany',        ...                                  operations=[operation1],        ...                                  seastate_collections=[seastatecollec1])


   .. py:method:: add_operation(*args, ignore_msg = False)

      Add an `Operation` instance to the list of operations of the platform.

      :param \*args: Operation to be added to the platform.
      :type \*args: Operation object
      :param ignore_msg: If `False`, messages are printed to inform about any changes made to the
                         platform. If `True`, thoses messages are turned off.
      :type ignore_msg: bool, default False

      .. rubric:: Example

      >>> operation2 = netsse.base.Operation()
      >>> platform1.add_operation(operation2,ignore_msg=True)



   .. py:method:: add_seastatecollec(*args, ignore_msg = False)

      Add a `SeaStateCollec` instance to the list of sea state collections
      of the platform.

      :param \*args: Collections to be added to the platform.
      :type \*args: SeaStateCollec object
      :param ignore_msg: If `False`, messages are printed to inform about any changes made to
                         the platform. If `True`, thoses messages are turned off.
      :type ignore_msg: bool, default False

      .. rubric:: Example

      >>> seastatecollec2 = netsse.base.SeaStateCollec()
      >>> platform1.add_seastatecollec(seastatecollec2,ignore_msg=True)



   .. py:method:: remove_operation(*args, ignore_msg = False)

      Remove an existing `Operation` instance from the list of operations of the
      platform.

      :param \*args: Operation to be removed from the network. Identified by the corresponding
                     identifier or `Operation` instance.
      :type \*args: Operation object or str
      :param ignore_msg: If `False`, messages are printed to inform about any changes made to the
                         platform. If `True`, thoses messages are turned off.
      :type ignore_msg: bool, default False

      .. rubric:: Example

      >>> platform1.remove_operation(platform1,ignore_msg=True)



   .. py:method:: remove_seastatecollec(*args, ignore_msg = False)

      Remove an existing `SeaStateCollec` instance from the list of sea state collections
      of the platform.

      :param \*args: Collections to be removed from the network. Identified by the corresponding
                     identifier or `SeaStateCollec` instance.
      :type \*args: SeaStateCollec object or str
      :param ignore_msg: If `False`, messages are printed to inform about any changes made to the
                         platform. If `True`, thoses messages are turned off.
      :type ignore_msg: bool, default False

      .. rubric:: Example

      >>> platform1.remove_seastatecollec(seastatecollec1,ignore_msg=True)



   .. py:attribute:: name
      :value: None



   .. py:attribute:: operations
      :value: []



   .. py:attribute:: owner
      :value: 'undefined'



   .. py:attribute:: seastate_collections
      :value: []



.. py:class:: SeaState(Hs=0, Tp=0, timestamp=datetime.now(), lat=0, lon=0, depth=0, duration=30 * 60)

   Initialises the sea state at a given time and geographical position in the ocean.

   :param Hs: Significant wave height [m].
   :type Hs: float, default 0
   :param Tp: Peak wave period [s].
   :type Tp: float, default 0
   :param timestamp: Timestamp at which the sea state applies.
   :type timestamp: datetime object, default datetime.now()
   :param lat: Latitude [degrees North].
   :type lat: float, default 0
   :param lon: Longitude [degrees East].
   :type lon: float, default 0
   :param depth: Water depth [m] at the studied location.
   :type depth: float, default 0
   :param duration: Time duration of the sea state [s], by default 30*60 = 1800 s.
   :type duration: float, optional

   .. rubric:: Examples

   >>> seastate = SeaState(Hs,Tp,timestamp,lat,lon,depth,duration)


   .. py:method:: set_params(Hs, Tp)

      Sets the sea state parameters :math:`H_s` and :math:`T_p` to new
      user-defined values.

      :param Hs: Significant wave height [m].
      :type Hs: float
      :param Tp: Peak wave period [s].
      :type Tp: float

      .. rubric:: Examples

      >>> seastate.set_params(Hs,Tp)



   .. py:attribute:: depth
      :value: 0



   .. py:attribute:: duration
      :value: 1800



   .. py:attribute:: lat
      :value: 0



   .. py:attribute:: lon
      :value: 0



   .. py:attribute:: timestamp


.. py:class:: SeaStateCollec(id = None, area = 'undefined', nature = 'undefined', origin='undefined', datetime_start=datetime.now(), datetime_end=datetime.now(), lat_min = 0, lat_max = 0, lon_min = 0, lon_max = 0, seastates = [])

   Initialises the sea state collection.

   :param id: Data collection identifier. By default, the `id` string is generated
              randomly in the format ``CollecXXXXX``.
   :type id: str, optional
   :param seastates: List of sea states (as `SeaState` instances) gathered in the data
                     collection.

                     .. note::
                         Consult :func:`netsse.base.Collection.__init__` for information on
                         the other parameters.
   :type seastates: list, default []

   .. seealso:: :py:obj:`Collection`, :py:obj:`Platform`, :py:obj:`SeaState`

   .. rubric:: Example

   >>> seastatecollec1 = netsse.base.SeaStateCollec()


   .. py:attribute:: id
      :value: None



   .. py:attribute:: seastates
      :value: []



.. py:class:: Spectrum(freq=np.linspace(0, 1, 100), ord=np.zeros((100, )), unit_freq='Hz')

.. py:class:: Vessel(name = None, owner = 'undefined', operations = [], seastate_collections = [], type = 'undefined', params = {}, raos = [])

   Bases: :py:obj:`Platform`


   Initialises the wave radar as a platform.

   :param type: Wave radar type.
   :type type: str, default 'undefined'
   :param params: Vessel main dimensions and other geometrical parameters.
   :type params: dict, default {}
   :param raos: Vessel response amplitude operators.

                .. note::
                    Consult :func:`netsse.base.Platform.__init__` for information
                    on the other parameters.
   :type raos: list, default []

   .. rubric:: Example

   >>> vessel1 = netsse.base.Vessel(params={'L':200,'B':25,'T':30})


   .. py:method:: add_rao(*args)


   .. py:attribute:: params


   .. py:attribute:: raos
      :value: []



   .. py:attribute:: type
      :value: 'undefined'



.. py:class:: WaveRadar(name = None, owner = 'undefined', operations = [], seastate_collections = [], type = 'undefined')

   Bases: :py:obj:`Platform`


   Initialises the wave radar as a platform.

   :param type: Wave radar type.

                .. note::
                    Consult :func:`netsse.base.Platform.__init__` for information
                    on the other parameters.
   :type type: str, default 'undefined'

   .. rubric:: Example

   >>> radar1 = netsse.base.WaveRadar()


   .. py:attribute:: type
      :value: 'undefined'



.. py:class:: WaveSequence(Hs=0, Tp=0, timestamp=datetime.now(), lat=0, lon=0, depth=0, wave=None, time=None, fs=10)

   Bases: :py:obj:`SeaState`


   Initialises the wave sequence.

   :param wave: Sea surface elevation time-series [m]. By default ``None``.
   :type wave: array-like of shape (Nt,), optional
   :param time: Vector of time [s], by default ``None``.
   :type time: array-like of shape (Nt,), optional

   :param fs: Sampling frequency [Hz].

              .. note::
                  Consult :func:`netsse.base.SeaState.__init__` for information on the other
                  parameters.
   :type fs: float, default 10

   :raises ValueError: In case the input ``time`` and ``wave`` vectors do not have the same length.

   .. rubric:: Examples

   >>> waveseq =
   ...     WaveSequence(Hs, Tp, timestamp, lat, lon, depth, wave, time)


   .. py:method:: get_wavespec(method='Welch', nperseg=2**8, fmax=0)


   .. py:attribute:: duration


   .. py:attribute:: fs


.. py:class:: WaveSpectrum(Hs=np.nan, Tp=np.nan, freq=np.linspace(0, 1, 100), ord=np.zeros((100, )), unit_freq='Hz', timestamp=datetime.now(), lat=0, lon=0, depth=0, duration=30 * 60)

   Bases: :py:obj:`Spectrum`, :py:obj:`SeaState`


   Initialises the sea state at a given time and geographical position in the ocean.

   :param Hs: Significant wave height [m].
   :type Hs: float, default 0
   :param Tp: Peak wave period [s].
   :type Tp: float, default 0
   :param timestamp: Timestamp at which the sea state applies.
   :type timestamp: datetime object, default datetime.now()
   :param lat: Latitude [degrees North].
   :type lat: float, default 0
   :param lon: Longitude [degrees East].
   :type lon: float, default 0
   :param depth: Water depth [m] at the studied location.
   :type depth: float, default 0
   :param duration: Time duration of the sea state [s], by default 30*60 = 1800 s.
   :type duration: float, optional

   .. rubric:: Examples

   >>> seastate = SeaState(Hs,Tp,timestamp,lat,lon,depth,duration)


   .. py:method:: get_params(smooth_Tp=True)


   .. py:method:: set_from_standard(method='JONSWAP', gamma=3.3)


   .. py:method:: set_from_waveseq(waveseq, method='Welch', nperseg=2**8, fmax=0)


