{"id":13948610,"url":"https://github.com/wavespectra/wavespectra","last_synced_at":"2025-10-21T20:06:50.400Z","repository":{"id":37733006,"uuid":"205463939","full_name":"wavespectra/wavespectra","owner":"wavespectra","description":"Library for ocean wave spectra","archived":false,"fork":false,"pushed_at":"2024-09-18T09:37:18.000Z","size":4456,"stargazers_count":68,"open_issues_count":7,"forks_count":27,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-10-29T21:02:02.008Z","etag":null,"topics":["ocean","python","spectra","statistics","wave","xarray"],"latest_commit_sha":null,"homepage":"https://wavespectra.readthedocs.io/en/latest/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wavespectra.png","metadata":{"files":{"readme":"README.rst","changelog":"HISTORY.rst","contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":"docs/support.rst","governance":null,"roadmap":null,"authors":"AUTHORS.rst","dei":null}},"created_at":"2019-08-30T22:19:36.000Z","updated_at":"2024-10-18T14:42:50.000Z","dependencies_parsed_at":"2024-03-17T04:42:47.021Z","dependency_job_id":"7aea41e5-001e-41ac-b3e9-1064843f46d2","html_url":"https://github.com/wavespectra/wavespectra","commit_stats":{"total_commits":1049,"total_committers":22,"mean_commits":47.68181818181818,"dds":0.6081982840800763,"last_synced_commit":"66b38b2dcc1515a63974ad4c24fd241d5f08feae"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wavespectra%2Fwavespectra","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wavespectra%2Fwavespectra/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wavespectra%2Fwavespectra/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wavespectra%2Fwavespectra/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wavespectra","download_url":"https://codeload.github.com/wavespectra/wavespectra/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222132611,"owners_count":16936615,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ocean","python","spectra","statistics","wave","xarray"],"created_at":"2024-08-08T05:01:26.074Z","updated_at":"2025-10-21T20:06:45.137Z","avatar_url":"https://github.com/wavespectra.png","language":"Python","readme":"wavespectra\n===========\nPython library for ocean wave spectra.\n\n.. image:: https://zenodo.org/badge/205463939.svg\n   :target: https://zenodo.org/badge/latestdoi/205463939\n.. image:: https://img.shields.io/github/actions/workflow/status/wavespectra/wavespectra/python-publish.yml\n    :target: https://github.com/wavespectra/wavespectra/actions\n    :alt: GitHub Workflow Status (with event)\n.. image:: https://coveralls.io/repos/github/wavespectra/wavespectra/badge.svg?branch=master\n    :target: https://coveralls.io/github/wavespectra/wavespectra?branch=master\n.. image:: https://readthedocs.org/projects/wavespectra/badge/?version=latest\n    :target: https://wavespectra.readthedocs.io/en/latest/\n.. image:: https://img.shields.io/pypi/v/wavespectra.svg\n    :target: https://pypi.org/project/wavespectra/\n.. image:: https://img.shields.io/pypi/dm/wavespectra\n    :target: https://pypistats.org/packages/wavespectra\n    :alt: PyPI - Downloads\n.. image:: https://anaconda.org/conda-forge/wavespectra/badges/version.svg\n    :target: https://anaconda.org/conda-forge/wavespectra\n.. image:: https://anaconda.org/conda-forge/wavespectra/badges/platforms.svg\n    :target: https://anaconda.org/conda-forge/wavespectra\n.. image:: https://img.shields.io/badge/code%20style-black-000000.svg\n    :target: https://github.com/python/black\n.. image:: https://img.shields.io/pypi/pyversions/wavespectra\n    :target: https://pypi.org/project/wavespectra/\n    :alt: PyPI - Python Version\n\nMain contents:\n--------------\n* SpecArray_: extends xarray's `DataArray`_ with methods to manipulate wave spectra and calculate spectral statistics.\n* SpecDataset_: wrapper around `SpecArray`_ with methods for selecting and saving spectra in different formats.\n\nDocumentation:\n--------------\nThe documentation is hosted on ReadTheDocs at https://wavespectra.readthedocs.io/en/latest/.\n\nInstall:\n--------\nWhere to get it\n~~~~~~~~~~~~~~~\nThe source code is currently hosted on GitHub at: https://github.com/wavespectra/wavespectra\n\nBinary installers for the latest released version are available at the `Python package index`_.\n\nInstall from pypi\n~~~~~~~~~~~~~~~~~\n.. code:: bash\n\n   # Default install, miss some dependencies and functionality\n   pip install wavespectra\n\n   # Complete install\n   pip install wavespectra[extra]\n\nInstall from conda\n~~~~~~~~~~~~~~~~~~~\n.. code:: bash\n\n    # wavespectra is available in the conda-forge channel\n    conda install -c conda-forge wavespectra\n\nInstall from sources\n~~~~~~~~~~~~~~~~~~~~\nInstall requirements. Navigate to the base root of wavespectra_ and execute:\n\n.. code:: bash\n\n   # Default install, miss some dependencies and functionality\n   pip install -r requirements/default.txt\n\n   # Also, for complete install\n   pip install -r requirements/extra.txt\n\nThen install wavespectra:\n\n.. code:: bash\n\n   python setup.py install\n\n   # Run pytest integration\n   python setup.py test\n\nAlternatively, to install in `development mode`_:\n\n.. code:: bash\n\n   pip install -e .\n\nCode structure:\n---------------\nThe two main classes SpecArray_ and SpecDataset_ are defined as `xarray accessors`_. The accessors are registered on xarray's DataArray_ and Dataset_ respectively as a new namespace called `spec`.\n\nTo use methods in the accessor classes simply import the classes into your code and they will be available to your xarray.Dataset or xarray.DataArray instances through the `spec` attribute, e.g.\n\n.. code:: python\n\n   import datetime\n   import numpy as np\n   import xarray as xr\n\n   from wavespectra.specarray import SpecArray\n   from wavespectra.specdataset import SpecDataset\n\n   coords = {'time': [datetime.datetime(2017,01,n+1) for n in range(2)],\n             'freq': [0.05,0.1],\n             'dir': np.arange(0,360,120)}\n   efth = xr.DataArray(data=np.random.rand(2,2,3),\n                       coords=coords,\n                       dims=('time','freq', 'dir'),\n                       name='efth')\n\n   In [1]: efth\n   Out[1]:\n   \u003cxarray.DataArray (time: 2, freq: 2, dir: 3)\u003e\n   array([[[ 0.100607,  0.328229,  0.332708],\n           [ 0.532   ,  0.665938,  0.177731]],\n\n          [[ 0.469371,  0.002963,  0.627179],\n           [ 0.004523,  0.682717,  0.09766 ]]])\n   Coordinates:\n     * freq     (freq) float64 0.05 0.1\n     * dir      (dir) int64 0 120 240\n     * time     (time) datetime64[ns] 2017-01-01 2017-01-02\n\n   In [2]: efth.spec\n   Out[2]:\n   \u003cSpecArray (time: 2, freq: 2, dir: 3)\u003e\n   array([[[ 0.100607,  0.328229,  0.332708],\n           [ 0.532   ,  0.665938,  0.177731]],\n\n          [[ 0.469371,  0.002963,  0.627179],\n           [ 0.004523,  0.682717,  0.09766 ]]])\n   Coordinates:\n     * freq     (freq) float64 0.05 0.1\n     * dir      (dir) int64 0 120 240\n     * time     (time) datetime64[ns] 2017-01-01 2017-01-02\n\n   In [3]: efth.spec.hs()\n   Out[3]:\n   \u003cxarray.DataArray 'hs' (time: 2)\u003e\n   array([ 10.128485,   9.510618])\n   Coordinates:\n     * time     (time) datetime64[ns] 2017-01-01 2017-01-02\n   Attributes:\n       standard_name: sea_surface_wave_significant_height\n       units: m\n\nSpecDataset provides a wrapper around the methods in SpecArray. For instance, these produce same result:\n\n.. code:: python\n\n   In [4]: dset = efth.to_dataset(name='efth')\n\n   In [5]: tm01 = dset.spec.tm01()\n\n   In [6]: tm01.identical(dset.efth.spec.tm01())\n   Out[6]: True\n\nData requirements:\n------------------\n\nSpecArray_ methods require DataArray_ to have the following attributes:\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n- wave frequency coordinate in `Hz` named as `freq` (required).\n- wave frequency coordinate in `Hz` named as `freq` (required).\n- wave direction coordinate in `degree` (coming from) named as `dir` (optional for 1D, required for 2D spectra).\n- wave energy density data in `m2/Hz/degree` (2D) or `m2/Hz` (1D) named as `efth`\n\nSpecDataset_ methods require xarray's Dataset_ to have the following attributes:\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n- spectra DataArray named as `efth`, complying with the above specifications\n\nExamples:\n---------\n\nDefine and plot spectra history from example SWAN_ spectra file:\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code:: python\n\n   from wavespectra import read_swan\n\n   dset = read_swan('/source/wavespectra/tests/manus.spec')\n   spec_hist = dset.isel(lat=0, lon=0).sel(freq=slice(0.05,0.2)).spec.oned().T\n   spec_hist.plot.contourf(levels=10)\n\n.. _SpecArray: https://github.com/wavespectra/wavespectra/blob/master/wavespectra/specarray.py\n.. _SpecDataset: https://github.com/wavespectra/wavespectra/blob/master/wavespectra/specdataset.py\n.. _DataArray: http://xarray.pydata.org/en/stable/generated/xarray.DataArray.html\n.. _Dataset: http://xarray.pydata.org/en/stable/generated/xarray.Dataset.html\n.. _readspec: https://github.com/wavespectra/wavespectra/blob/master/wavespectra/readspec.py\n.. _xarray accessors: http://xarray.pydata.org/en/stable/internals.html?highlight=accessor\n.. _SWAN: http://swanmodel.sourceforge.net/online_doc/swanuse/node50.html\n.. _Python package index: https://pypi.python.org/pypi/wavespectra\n.. _wavespectra: https://github.com/wavespectra/wavespectra\n.. _development mode: https://pip.pypa.io/en/latest/reference/pip_install/#editable-installs\n","funding_links":[],"categories":["Hydrosphere","By location","Software"],"sub_categories":["Waves and Currents","Global","Oceanography"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwavespectra%2Fwavespectra","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwavespectra%2Fwavespectra","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwavespectra%2Fwavespectra/lists"}