Input & Output#
Input#
Wavespectra provides several functions for reading datasets from different file formats
into SpecDataset
objects. The functions are defined
in submodules within wavespectra.input
. They can be imported from the main
module level for convenience, for instance:
In [1]: from wavespectra import read_swan
Note
The following conventions are expected for defining reading functions:
Funcions for different file types are defined in different modules within
wavespectra.input
subpackage.Modules are named as filetype.py, e.g.,
swan.py
.Functions are named as read_`filetype`, e.g.,
read_swan
.
Input functions can also be defined without following these conventions. However they are not accessible from the main module level and need to be imported from their full module path, e.g.
In [2]: from wavespectra.input.swan import read_hotswan
Note
Wavespectra currently supports data formats that include NetCDF
, ASCII
and JSON
type files. NetCDF type datasets, i.e. those that can be open with
xarray’s open_dataset and open_mfdataset functions, can also be prescribed in ZARR
format (wavespectra uses xarray’s open_zarr function behind the scenes to open
these files). Functions that support ZARR have a file_format
argument option.
Note
Files in ZARR
format can be open from both local and remote (bucket) stores.
These input functions are currently available from the main module level:
Format and attach SpecArray accessor to an existing xarray dataset. |
|
Read Spectra from ECMWF ERA5 netCDF format. |
|
Read Spectra in Funwave format. |
|
Read Spectra from json. |
|
Read Spectra from SWAN native netCDF format. |
|
Read Spectra from generic netCDF format. |
|
Read Spectra from NDBC netCDF format. |
|
Read spectra from NDBC wave buoy ASCII files. |
|
Read spectra from Octopus file format. |
|
Read Spectra from Spotter file. |
|
Read Spectra from SWAN ASCII file. |
|
Read spectra from TRIAXYS wave buoy ASCII files. |
|
Read Spectra from WWMII native netCDF format. |
|
Read Spectra from WAVEWATCHIII native netCDF format. |
These functions are not accessible from the main module level and need to be imported from their full module path:
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#
Wavespectra provides functions to write SpecDataset
objects into different file types. They are defined in module within wavespectra.output
.
They are attached as methods in the SpecDataset accessor.
Note
The following conventions are expected for defining output functions:
Funcions for different file types are defined in different modules within
wavespectra.output
subpackage.Modules are named as filetype.py, e.g.,
swan.py
.Functions are named as to_`filetype`, e.g.,
to_swan
.Function must accept
self
as the first input argument.
These output functions are currently available as methods of SpecDataset
:
Write spectra in Funwave format. |
|
Write spectra in json format. |
|
Write spectra in netCDF format using wavespectra conventions. |
|
Save spectra in Octopus format. |
|
Writes the spectrum to an Orcaflex model |
|
Write spectra in SWAN ASCII format. |
|
Save spectra in native WW3 netCDF format. |