API documentation#
General description of modules, objects and functions in wavespectra.
Wavespectra accessors#
Extends DataArray with methods to deal with wave spectra. |
|
Extends xarray's Dataset to deal with wave spectra datasets. |
* The two accessors are attached to the respective xarray objects via the spec namespace.
SpecArray#
All methods in SpecArray accessor are also available from SpecDataset.
Integrated spectral parameters
Spectral significant wave height Hm0. |
|
Root mean square wave height Hrms. |
|
Maximum wave height Hmax. |
|
Peak wave frequency Fp. |
|
Peak wave period Tp. |
|
Mean absolute wave period Tm01. |
|
Mean absolute wave period Tm02. |
|
Peak wave direction Dpm. |
|
Peak wave direction Dp. |
|
Mean wave direction from the 1st spectral moment Dm. |
|
Mean directional wave spread Dspr. |
|
Peak directional wave spread Dpspr. |
|
Spectral width parameter by Cartwright and Longuet-Higgins (1956). |
|
Spectral width parameter by Longuet-Higgins (1975). |
|
Gaussian frequency spread by Bunney et al. (2014). |
|
Jonswap peak enhancement factor gamma. |
|
Jonswap fetch dependant scaling coefficient alpha. |
|
Goda peakedness parameter. |
|
Nonlinear fit Jonswap spectra. |
|
Nonlinear fit Gaussian width. |
|
Root-Mean-Square Error among spectral bins. |
Spectral partitioning
Split spectra over freq and/or dir dims. |
|
PTM1 watershed partitioning. |
|
PTM2 watershed partitioning with secondary wind-sea. |
|
PTM3 watershed partitioning with no wind-sea or swell classification. |
|
PTM4 WAM partitioning of sea and swell based on wave age criterion.. |
|
PTM5 SWAN partitioning of sea and swell based on user-defined threshold. |
|
Hanson and Phillips 2001 spectra partitioning and swell merging. |
|
Partition based on user-defined bounding boxes in frequency-direction space. |
|
Partition and combine spectra from the same wave system over time. |
Other methods
Frequency moment. |
|
Directional moment. |
|
Wavelength L from frequency coords. |
|
Wave celerity C from frequency coords. |
|
Calculate multiple spectral stats into a Dataset. |
|
Plot spectra in polar axis. |
|
Scale spectra using expression based on Significant Wave Height hs. |
|
Returns the one-dimensional frequency spectra. |
|
Convert spectra from energy density (m2/Hz/degree) into wave energy (m2). |
|
Interpolate onto new spectral basis. |
|
Interpolate onto coordinates from other spectra. |
|
Rotate spectra. |
SpecDataset#
Select stations near or at locations defined by (lons, lats) vector. |
Output methods described in the Output functions section:
to_swan
to_netcdf
to_octopus
to_ww3
to_json
to_funwave
to_orcaflex
Input functions#
NetCDF-based input functions
Read Spectra from WAVEWATCHIII native netCDF format. |
|
Read Spectra from SWAN native netCDF format. |
|
Read Spectra from WWMII native netCDF format. |
|
Read Spectra from generic netCDF format. |
|
Read Spectra from ECMWF ERA5 netCDF format. |
|
Read Spectra from NDBC netCDF format. |
* These functions also support Zarr files
Other input functions
Read Spectra from SWAN ASCII file. |
|
Read spectra from TRIAXYS wave buoy ASCII files. |
|
Read Spectra from Spotter file. |
|
Read spectra from Octopus file format. |
|
Format and attach SpecArray accessor to an existing xarray dataset. |
|
Read spectra from NDBC wave buoy ASCII files. |
|
Read Spectra from json. |
|
Read Spectra in Funwave format. |
|
Read Spectra from XWaves MAT format. |
|
Format and attach SpecArray accessor to an existing xarray dataset. |
|
Read Spectra from from netCDF or ZARR format in Wavespectra convention. |
|
Read directional spectra from WW3 station output file. |
Convenience SWAN ASCII input functions
Read multiple SWAN ASCII files into single Dataset. |
|
Read partial SWAN hotfiles into single gridded hotfile Dataset. |
|
Read SWAN nowcast from fileglob, keep overlapping dates from most recent files. |
Output functions#
Write spectra in SWAN ASCII format. |
|
Write spectra in netCDF format using wavespectra conventions. |
|
Save spectra in Octopus format. |
|
Save spectra in native WW3 netCDF format. |
|
Write spectra in json format. |
|
Write spectra in Funwave format. |
|
Writes the spectrum to an Orcaflex model |
Construct#
Pierson and Moskowitz spectrum for fully developed seas (Pierson and Moskowitz, 1964). |
|
Jonswap frequency spectrum for developing seas (Hasselmann et al., 1973). |
|
TMA frequency spectrum for seas in water of finite depth (Bouws et al., 1985). |
|
Gaussian frequency spectrum (Bunney et al., 2014). |
|
Cosine-squared directional spreading of Cartwright (1963). |
|
Asymmetric directional spreading of Bunney et al. (2014). |
|
Fit frequency-direction E(f, d) parametric spectrum for a partition. |
|
Partition and reconstruct existing spectra to evaluate. |
Internal core functions and objects#
Partition subpackage
Spectra partition methods. |
|
PTM1 watershed partitioning. |
|
PTM1 spectra partitioning on numpy arrays. |
|
PTM2 spectra partitioning on numpy arrays. |
|
PTM3 spectra partitioning on numpy arrays. |
|
Hanson and Phillips 2001 spectra partitioning on numpy arrays. |
|
Rate of change of the wind-sea peak wave frequency. |
|
Rate of change of the swell peak wave frequency. |
|
Match partitions of consecutive spectra based on evolution of peak frequency and peak direction. |
|
Track partitions at a site in a series of consecutive spectra based on the evolution of peak frequency and peak direction. |
|
Track partitions in a series of consecutive spectra based on the evolution of peak frequency and peak direction. |
|
Wave stats from partition. |
|
Check if 1d partitions overlap in frequency space. |
|
Frequency resolution. |
|
Spread parameter of Hanson and Phillips (2001). |
|
Combine, update and reorder parts and stats. |
|
Combine swell partitions according Hanson and Phillips (2001). |
attributes module
Standarise CF attributes in specarray variables |
|
npstats
Significant wave height Hmo. |
|
Mean direction at the peak wave period Dpm. |
|
Peak wave direction Dp. |
|
Mean wave direction Dm. |
|
Smooth peak wave period Tp. |
|
Peak wave period Tp. |
|
Peak directional wave spread Dpspr. |
|
First directional moment. |
|
Jonswap frequency spectrum for developing seas (Hasselmann et al., 1973). |
|
Gaussian frequency spectrum (Bunney et al., 2014). |
xrstats
Peak wave direction Dp. |
|
Mean direction at the peak wave period Dpm. |
|
Smooth Peak wave period Tp. |
|
Wave spreading at the peak wave frequency Dpspr. |
select module
Select sites from nearest distance. |
|
Select sites within bbox. |
|
Select sites from inverse distance weighting. |
|
Distance between each station in (dset_lons, dset_lats) and site (lon, lat). |
|
Nearer stations in (dset_lons, dset_lats) to site (lon, lat). |
|
Nearest station in (dset_lons, dset_lats) to site (lon, lat). |
utils module
Wavelength L. |
|
Chen and Thomson wavenumber approximation. |
|
Wave celerity C. |
|
Convert from cartesian to nautical angle. |
|
Remove duplicate indices from dataset. |
|
Remove duplicate times from dataset. |
|
Converts (spd, dir) to (u, v). |
|
Converts (u, v) to (spd, dir). |
|
Interpolate onto new spectral basis. |
|
Flatten list of lists |
|
Regrid spectra onto new spectral basis. |
swan module
Read swan table file. |
|
Read spectra in SWAN ASCII format. |