Name | wavespectra JSON |
Version |
4.2.0
JSON |
| download |
home_page | None |
Summary | Library for ocean wave spectra |
upload_time | 2024-11-13 06:06:28 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | Copyright (c) 2018 MetOcean Solutions Ltd Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
wave
spectra
ocean
xarray
statistics
analysis
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
wavespectra
===========
Python library for ocean wave spectra.
.. image:: https://zenodo.org/badge/205463939.svg
:target: https://zenodo.org/badge/latestdoi/205463939
.. image:: https://img.shields.io/github/actions/workflow/status/wavespectra/wavespectra/python-publish.yml
:target: https://github.com/wavespectra/wavespectra/actions
:alt: GitHub Workflow Status (with event)
.. image:: https://coveralls.io/repos/github/wavespectra/wavespectra/badge.svg?branch=master
:target: https://coveralls.io/github/wavespectra/wavespectra?branch=master
.. image:: https://readthedocs.org/projects/wavespectra/badge/?version=latest
:target: https://wavespectra.readthedocs.io/en/latest/
.. image:: https://img.shields.io/pypi/v/wavespectra.svg
:target: https://pypi.org/project/wavespectra/
.. image:: https://img.shields.io/pypi/dm/wavespectra
:target: https://pypistats.org/packages/wavespectra
:alt: PyPI - Downloads
.. image:: https://anaconda.org/conda-forge/wavespectra/badges/version.svg
:target: https://anaconda.org/conda-forge/wavespectra
.. image:: https://anaconda.org/conda-forge/wavespectra/badges/platforms.svg
:target: https://anaconda.org/conda-forge/wavespectra
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/python/black
.. image:: https://img.shields.io/pypi/pyversions/wavespectra
:target: https://pypi.org/project/wavespectra/
:alt: PyPI - Python Version
Main contents:
--------------
* SpecArray_: extends xarray's `DataArray`_ with methods to manipulate wave spectra and calculate spectral statistics.
* SpecDataset_: wrapper around `SpecArray`_ with methods for selecting and saving spectra in different formats.
Documentation:
--------------
The documentation is hosted on ReadTheDocs at https://wavespectra.readthedocs.io/en/latest/.
Install:
--------
Where to get it
~~~~~~~~~~~~~~~
The source code is currently hosted on GitHub at: https://github.com/wavespectra/wavespectra
Binary installers for the latest released version are available at the `Python package index`_.
Install from pypi
~~~~~~~~~~~~~~~~~
.. code:: bash
# Default install, miss some dependencies and functionality
pip install wavespectra
# Complete install
pip install wavespectra[extra]
Install from conda
~~~~~~~~~~~~~~~~~~~
.. code:: bash
# wavespectra is available in the conda-forge channel
conda install -c conda-forge wavespectra
Install from sources
~~~~~~~~~~~~~~~~~~~~
Install requirements. Navigate to the base root of wavespectra_ and execute:
.. code:: bash
# Default install, miss some dependencies and functionality
pip install -r requirements/default.txt
# Also, for complete install
pip install -r requirements/extra.txt
Then install wavespectra:
.. code:: bash
python setup.py install
# Run pytest integration
python setup.py test
Alternatively, to install in `development mode`_:
.. code:: bash
pip install -e .
Code structure:
---------------
The 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`.
To 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.
.. code:: python
import datetime
import numpy as np
import xarray as xr
from wavespectra.specarray import SpecArray
from wavespectra.specdataset import SpecDataset
coords = {'time': [datetime.datetime(2017,01,n+1) for n in range(2)],
'freq': [0.05,0.1],
'dir': np.arange(0,360,120)}
efth = xr.DataArray(data=np.random.rand(2,2,3),
coords=coords,
dims=('time','freq', 'dir'),
name='efth')
In [1]: efth
Out[1]:
<xarray.DataArray (time: 2, freq: 2, dir: 3)>
array([[[ 0.100607, 0.328229, 0.332708],
[ 0.532 , 0.665938, 0.177731]],
[[ 0.469371, 0.002963, 0.627179],
[ 0.004523, 0.682717, 0.09766 ]]])
Coordinates:
* freq (freq) float64 0.05 0.1
* dir (dir) int64 0 120 240
* time (time) datetime64[ns] 2017-01-01 2017-01-02
In [2]: efth.spec
Out[2]:
<SpecArray (time: 2, freq: 2, dir: 3)>
array([[[ 0.100607, 0.328229, 0.332708],
[ 0.532 , 0.665938, 0.177731]],
[[ 0.469371, 0.002963, 0.627179],
[ 0.004523, 0.682717, 0.09766 ]]])
Coordinates:
* freq (freq) float64 0.05 0.1
* dir (dir) int64 0 120 240
* time (time) datetime64[ns] 2017-01-01 2017-01-02
In [3]: efth.spec.hs()
Out[3]:
<xarray.DataArray 'hs' (time: 2)>
array([ 10.128485, 9.510618])
Coordinates:
* time (time) datetime64[ns] 2017-01-01 2017-01-02
Attributes:
standard_name: sea_surface_wave_significant_height
units: m
SpecDataset provides a wrapper around the methods in SpecArray. For instance, these produce same result:
.. code:: python
In [4]: dset = efth.to_dataset(name='efth')
In [5]: tm01 = dset.spec.tm01()
In [6]: tm01.identical(dset.efth.spec.tm01())
Out[6]: True
Data requirements:
------------------
SpecArray_ methods require DataArray_ to have the following attributes:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- wave frequency coordinate in `Hz` named as `freq` (required).
- wave frequency coordinate in `Hz` named as `freq` (required).
- wave direction coordinate in `degree` (coming from) named as `dir` (optional for 1D, required for 2D spectra).
- wave energy density data in `m2/Hz/degree` (2D) or `m2/Hz` (1D) named as `efth`
SpecDataset_ methods require xarray's Dataset_ to have the following attributes:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- spectra DataArray named as `efth`, complying with the above specifications
Examples:
---------
Define and plot spectra history from example SWAN_ spectra file:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code:: python
from wavespectra import read_swan
dset = read_swan('/source/wavespectra/tests/manus.spec')
spec_hist = dset.isel(lat=0, lon=0).sel(freq=slice(0.05,0.2)).spec.oned().T
spec_hist.plot.contourf(levels=10)
.. _SpecArray: https://github.com/wavespectra/wavespectra/blob/master/wavespectra/specarray.py
.. _SpecDataset: https://github.com/wavespectra/wavespectra/blob/master/wavespectra/specdataset.py
.. _DataArray: http://xarray.pydata.org/en/stable/generated/xarray.DataArray.html
.. _Dataset: http://xarray.pydata.org/en/stable/generated/xarray.Dataset.html
.. _readspec: https://github.com/wavespectra/wavespectra/blob/master/wavespectra/readspec.py
.. _xarray accessors: http://xarray.pydata.org/en/stable/internals.html?highlight=accessor
.. _SWAN: http://swanmodel.sourceforge.net/online_doc/swanuse/node50.html
.. _Python package index: https://pypi.python.org/pypi/wavespectra
.. _wavespectra: https://github.com/wavespectra/wavespectra
.. _development mode: https://pip.pypa.io/en/latest/reference/pip_install/#editable-installs
Raw data
{
"_id": null,
"home_page": null,
"name": "wavespectra",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "Rafael Guedes <r.guedes@oceanum.science>, Tom Durrant <t.durrant@oceanum.science>",
"keywords": "wave, spectra, ocean, xarray, statistics, analysis",
"author": null,
"author_email": "Wavespectra Developers <r.guedes@oceanum.science>",
"download_url": "https://files.pythonhosted.org/packages/d2/0f/9a888c0c8f6f2dd0e8ae4841ace709cd9dc1264b70092414dc9c0daa5d23/wavespectra-4.2.0.tar.gz",
"platform": null,
"description": "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 <xarray.DataArray (time: 2, freq: 2, dir: 3)>\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 <SpecArray (time: 2, freq: 2, dir: 3)>\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 <xarray.DataArray 'hs' (time: 2)>\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",
"bugtrack_url": null,
"license": "Copyright (c) 2018 MetOcean Solutions Ltd Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
"summary": "Library for ocean wave spectra",
"version": "4.2.0",
"project_urls": {
"Changelog": "https://github.com/wavespectra/wavespectra/blob/master/HISTORY.rst",
"Documentation": "https://wavespectra.readthedocs.io/en/latest/",
"Source": "https://github.com/wavespectra/wavespectra",
"Tracker": "https://github.com/wavespectra/wavespectra/issues"
},
"split_keywords": [
"wave",
" spectra",
" ocean",
" xarray",
" statistics",
" analysis"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d20f9a888c0c8f6f2dd0e8ae4841ace709cd9dc1264b70092414dc9c0daa5d23",
"md5": "c734ba4bc5bfa7cc5a7ffcd5f9129899",
"sha256": "1a84e77b4c8b8dc94bec74c237573a0d64a5d9014fa9eb683ffc0108ff1a9ecd"
},
"downloads": -1,
"filename": "wavespectra-4.2.0.tar.gz",
"has_sig": false,
"md5_digest": "c734ba4bc5bfa7cc5a7ffcd5f9129899",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 105120,
"upload_time": "2024-11-13T06:06:28",
"upload_time_iso_8601": "2024-11-13T06:06:28.088640Z",
"url": "https://files.pythonhosted.org/packages/d2/0f/9a888c0c8f6f2dd0e8ae4841ace709cd9dc1264b70092414dc9c0daa5d23/wavespectra-4.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-13 06:06:28",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "wavespectra",
"github_project": "wavespectra",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "wavespectra"
}