pbranson / wavespectra

Library for ocean wave spectra

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

wavespectra

Python library for ocean wave spectra.

image

image

image

image

image

PyPI - Downloads

image

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

Install from conda

Install from sources

Install requirements. Navigate to the base root of wavespectra and execute:

Then install wavespectra:

Alternatively, to install in development mode:

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.

SpecDataset provides a wrapper around the methods in SpecArray. For instance, these produce same result:

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:

About

Library for ocean wave spectra

License:MIT License


Languages

Language:Python 96.6%Language:Fortran 2.9%Language:Makefile 0.5%