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. |
|
Maximum wave height Hmax. |
|
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. |
|
Directional wave spreading Dspr. |
|
Spectral width parameter by Cartwright and Longuet-Higgins (1956). |
|
Spectral width parameter by Longuet-Higgins (1975). |
Spectral partitioning
Split spectra over freq and/or dir dims. |
|
Partition wave spectra using Hanson's watershed algorithm. |
Other methods
Calculate given frequency moment. |
|
Calculate given 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 from energy density (m2/Hz/degree) into wave energy spectra (m2). |
|
Interpolate onto new spectral basis. |
|
Interpolate onto coordinates from other 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
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. |
* 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 netCDF format. |
|
Read Spectra from json. |
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. |
Spectral reconstruction#
Spectral reconstruction functionality is under development. There are functions available to fit parametric spectrum shapes from wave partitions but the construct api is not properly established.
Constructs JONSWAP spectra. |
|
Construct OCHIHUBBLE spectra. |
|
Generic spreading function. |
|
Check all inputs are same shape and add frequency and direction dims. |
|
Package spectral matrix to xarray. |
|
Check coordinates are consistent with parameter. |
Internal core functions and objects#
watershed module
Watershed partitioning. |
|
Watershed partition on a numpy array. |
|
Significant wave height Hmo. |
|
Frequency resolution array. |
|
Points of inflection in smoothed frequency spectra. |
attributes module
Standarise CF attributes in specarray variables |
|
npstats
Significant wave height Hmo. |
|
dpm_gufunc(x1, x2, x3, /, out=None, *, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj, axes, axis]) |
|
dp_gufunc(x1, x2, /, out=None, *, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj, axes, axis]) |
|
tps_gufunc(x1, x2, x3, /, out=None, *, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj, axes, axis]) |
|
tp_gufunc(x1, x2, x3, /, out=None, *, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj, axes, axis]) |
xrstats
Peak wave direction Dp. |
|
Mean direction at the peak wave period Dpm. |
|
Smooth Peak wave period Tp. |
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 numeric date to datetime. |
|
Convert from cartesian to nautical angle. |
|
Remove duplicate indices from dataset. |
|
Remove duplicate times from dataset. |
|
Convert Datetime64 date to datatime. |
|
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. |