environmentaltools.processes.read_swan

environmentaltools.processes.read_swan(fname, grid=None, vars_=None)[source]

Load SWAN wave model output from MATLAB file.

Parameters:
  • fname (str) – Path to SWAN .mat output file

  • grid (dict, optional) – Existing grid dictionary to update. If None, creates new dictionary.

  • vars (list of str, optional) – Variable names for output. Default: [‘x’, ‘y’, ‘depth’, ‘Qb’, ‘L’, ‘Setup’, ‘Hs’, ‘DirM’]

Returns:

Grid dictionary containing: - ‘x’: X coordinates (m) - ‘y’: Y coordinates (m) - ‘depth’: Water depth (m) - ‘Qb’: Wave energy dissipation (W/m²) - ‘L’: Wavelength (m) - ‘Setup’: Wave setup (m) - ‘Hs’: Significant wave height (m) - ‘DirM’: Mean wave direction (degrees) - ‘kp’: Peak wave number (rad/m), computed as 2π/L

Return type:

dict

Notes

  • Reads MATLAB file with variables: Xp, Yp, Depth, Qb, Wlen, Setup, Hsig, Dir

  • NaN values replaced with 1e-6 for numerical stability

  • Wave number computed from wavelength: kp = 2π/L

Examples

>>> wave_grid = swan('swan_output.mat')
>>> print(f"Max Hs: {wave_grid['Hs'].max():.2f} m")
>>> print(f"Mean direction: {wave_grid['DirM'].mean():.1f}°")