Skip to content

Commit 1e9498c

Browse files
committed
Wave: Standardize docstring formatting
1 parent f4d41f1 commit 1e9498c

5 files changed

Lines changed: 61 additions & 52 deletions

File tree

mhkit/wave/resource/energy_period.m

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
function Te = energy_period(S, varargin)
22

33
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4-
% Calculate wave energy period Te from wave spectra
4+
%
5+
% Calculate wave energy period (Te) seconds from power spectral density (PSD)
56
%
67
% Parameters
78
% ------------
8-
% S: structure or numeric array
9-
% If structure:
10-
% S.spectrum - Spectral Density (m^2/Hz)
11-
% S.frequency - Frequency (Hz)
12-
% If numeric:
13-
% S is spectral density array (vector or matrix)
14-
% varargin{1} must contain frequency vector
9+
% S: structure or numeric array
10+
% If structure:
11+
% S.spectrum - Spectral density [m^2/Hz]
12+
% S.frequency - Frequency [Hz]
13+
% If numeric:
14+
% S is spectral density array (vector or matrix)
15+
% varargin{1} must contain frequency vector
1516
%
16-
% frequency_bins: vector (optional)
17-
% Frequency bin widths [Hz]. Required for unevenly spaced bins.
17+
% frequency_bins: vector (optional)
18+
% Bin widths for frequency of S. Required for unevenly sized bins
1819
%
1920
% Returns
2021
% ---------
21-
% Te: double
22-
% Wave energy period [s]
22+
% Te: double
23+
% Wave energy period [seconds] indexed by S.columns
24+
%
2325
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2426

2527
arguments

mhkit/wave/resource/frequency_moment.m

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,28 @@
22

33
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44
%
5-
% Calculates the Nth frequency moment of the spectrum
5+
% Calculates the Nth frequency moment of the spectrum
66
%
77
% Parameters
8-
% ------------
9-
% S: structure or numeric array
10-
% If structure:
11-
% S.spectrum - Spectral Density (m^2/Hz)
12-
% S.frequency - Frequency (Hz)
13-
% If numeric:
14-
% S is spectral density array (vector or matrix)
15-
% varargin{1} must contain frequency vector
8+
% -----------
9+
% S: structure or numeric array
10+
% If structure:
11+
% S.spectrum - Spectral density [m^2/Hz]
12+
% S.frequency - Frequency [Hz]
13+
% If numeric:
14+
% S is spectral density array (vector or matrix)
15+
% varargin{1} must contain frequency vector
1616
%
17-
% N: int
18-
% Moment (0 for 0th, 1 for 1st, -1 for -1st, etc.)
17+
% N: int
18+
% Moment (0 for 0th, 1 for 1st ....)
1919
%
20-
% frequency_bins: vector (optional)
21-
% Bin widths for frequency of S. Required for unevenly sized bins
20+
% frequency_bins: vector (optional)
21+
% Bin widths for frequency of S. Required for unevenly sized bins
2222
%
2323
% Returns
24-
% ---------
25-
% m: double
26-
% Nth frequency moment
24+
% -------
25+
% m: double
26+
% Nth Frequency Moment indexed by S.columns
2727
%
2828
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2929

mhkit/wave/resource/jonswap_spectrum.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,27 @@
22

33
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44
%
5-
% Calculates JONSWAP spectrum from IEC TS 62600-2 ED2 Annex C.2 (2019)
5+
% Calculates JONSWAP Spectrum from IEC TS 62600-2 ED2 Annex C.2 (2019)
66
%
77
% Parameters
88
% ------------
99
% frequency: vector
10-
% Wave frequency (Hz)
10+
% Frequency [Hz]
1111
%
1212
% Tp: float
13-
% Peak Period (s)
13+
% Peak period [s]
1414
%
1515
% Hs: float
16-
% Significant Wave Height (m)
16+
% Significant wave height [m]
1717
%
1818
% gamma: float (optional)
1919
% Peak enhancement factor
2020
%
2121
% Returns
2222
% ---------
2323
% S: structure with fields
24-
% .spectrum = Spectral Density (m^2/Hz)
25-
% .frequency = Frequency (Hz)
24+
% .spectrum = Spectral density [m^2/Hz]
25+
% .frequency = Frequency [Hz]
2626
% .type = 'JONSWAP (Hs,Tp)'
2727
%
2828
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mhkit/wave/resource/significant_wave_height.m

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
function Hm0 = significant_wave_height(S, varargin)
22

33
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4-
% Calculate significant wave height Hm0 from spectra
4+
%
5+
% Calculates significant wave height Hm0 from spectra
56
%
67
% Parameters
78
% ------------
89
% S: structure or numeric array
910
% If structure:
10-
% S.spectrum: Spectral Density (m^2/Hz)
11-
% S.frequency: frequency (Hz)
11+
% S.spectrum: Spectral density [m^2/Hz]
12+
% S.frequency: frequency [Hz]
1213
% If numeric:
1314
% S is assumed to be spectral density vector/matrix
1415
% varargin{1} must contain frequency vector
@@ -19,8 +20,9 @@
1920
% Returns
2021
% ---------
2122
% Hm0: double
22-
% Significant Wave Height (m)
23-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
23+
% Significant wave height [m] index by S.columns
24+
%
25+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2426

2527
arguments
2628
S

mhkit/wave/resource/surface_elevation.m

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,40 @@
11
function wave_elevation = surface_elevation(S, time_index, options)
22

33
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4-
%
5-
% Generate wave surface elevation from spectrum
4+
% Calculates wave elevation time-series from spectrum
65
%
76
% Parameters
87
% ------------
98
% S: structure
109
% Spectral data with fields:
11-
% S.spectrum: (n_freq x 1) spectral density values (m^2/Hz)
12-
% S.frequency: (n_freq x 1) frequency vector (Hz)
10+
% S.spectrum: (n_freq x 1) spectral density [m^2/Hz]
11+
% S.frequency: (n_freq x 1) frequency vector [Hz]
1312
%
1413
% time_index: vector
15-
% (n_time x 1) time vector (s)
14+
% Time used to create the wave elevation time-series [s],
15+
% for example, time = 0:0.01:100
1616
%
1717
% options: structure (optional)
1818
% Optional fields:
19-
% seed: random seed (default = 123)
20-
% frequency_bins: bin widths for each frequency
21-
% phases: explicit phases (radians)
22-
% method: 'ifft' (default) or 'sum_of_sines'
19+
% seed: Random seed (default = 123)
20+
% frequency_bins: Bin widths for frequency of S. Required for unevenly sized bins
21+
% phases: Explicit phases for frequency components (overrides seed)
22+
% for example, phases = rand(length(S.frequency),1) * 2 * pi
23+
% method: Method used to calculate the surface elevation. 'ifft'
24+
% (Inverse Fast Fourier Transform) used by default if the
25+
% given frequency_bins==[] or is evenly spaced.
26+
% 'sum_of_sines' explicitly sums each frequency component
27+
% and used by default if uneven frequency_bins are provided.
28+
% The 'ifft' method is significantly faster.
2329
%
2430
% Returns
2531
% ---------
2632
% wave_elevation: structure
2733
% Generated wave elevation with fields:
28-
% elevation: (n_time x 1) wave elevation (m)
29-
% time: time vector (s)
34+
% elevation: Wave surface elevation [m]
35+
% time: time vector [s]
3036
% type: description string
31-
%
32-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
37+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3338

3439
arguments
3540
S struct

0 commit comments

Comments
 (0)