Expand description
§ndspec
ndspec is a crate for working with energy density spectra with a focus on ocean waves, wind, and related response spectra.
The crate is organised into the following modules:
core- Core functionality for working with energy density spectra.waves- Functions for calculating energy density spectra for ocean waves.wind- Functions for calculating energy density spectra for wind.spectrum- provides the TypesSpectrum1and ‘Spectrum2’ for one-dimensional and two-dimensional spectra respectively.
All wave and wind spectra can be converted into either a Spectrum1 or
Spectrum2 Type. These types provide various traits for working
with and evaluating energy density spectra.
The crate is designed to be used in conjunction with the ndarray
crate. The ndarray::Array1 and ndarray::Array2 types are
underlying data structures adopted throughout.
The crate also provides a Python extension that can be compiled and installed seperately.
§Installation
Add the following to your Cargo.toml file:
[dependencies]
ndspec = "0.1.0"§Usage
The following example demonstrates how to calculate the energy density spectrum for a Bretschneider wave spectrum:
use ndspec::prelude::*;
let hs = 1.5;
let tp = 18.0;
let mut bretschneider = Bretschneider::new(hs, tp);
let omega = Array1::linspace(0.1, PI, 100);
let energy = bretschneider.set_omega(omega).energy();§Python Extension
The crate provides a Python extension that can be compiled and
installed seperately. To build the extension, maturin is
required and the python-extension feature must be enabled:
maturin build --release --features python-extensionand install with pip.
§Examples
Define a Jonswap energy density spectrum from only Hs and Tp,
convert to a Spectrum1D type, and then evaluate the most probable
maximum amplitude over a 3 hour (10,800 s) time window:
import ndspec
S = ndspec.Jonswap(hs=1.5, tp=10.0).to_spec1d()
print(S.Ampm(10_800))Print out the help for the Jonswap class in Python::
import ndspec
help(ndspec.Jonswap)![energy density data structure][label_matrix]