Skip to content

Commit 033a62b

Browse files
committed
Wave: Use jonswap_spectrum with a gamma of 1 to calculate PM
1 parent 1e9498c commit 033a62b

1 file changed

Lines changed: 19 additions & 23 deletions

File tree

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,39 @@
11
function S = pierson_moskowitz_spectrum(frequency, Tp, Hs)
22

33
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4-
% Calculates Pierson-Moskowitz Spectrum from Tucker and Pitt (2001)
4+
% Calculates Pierson-Moskowitz Spectrum from IEC TS 62600-2 ED2 Annex C.2 (2019)
55
%
66
% Parameters
77
% ------------
8-
%
9-
% Frequency: float
10-
% Wave frequency (Hz)
8+
% frequency: vector
9+
% Wave frequency [Hz]
1110
%
1211
% Tp: float
13-
% Peak Period (s)
12+
% Peak period [s]
1413
%
1514
% Hs: float
16-
% Significant wave height (m)
17-
%
15+
% Significant wave height [m]
1816
%
1917
% Returns
2018
% ---------
21-
% S: structure
22-
%
23-
% S.spectrum=Spectral Density (m^2/Hz)
24-
%
25-
% S.type=String of the spectra type, i.e. (Pierson-Moskowitz 8.0s)
26-
%
27-
% S.frequency= frequency (Hz)
19+
% S: structure with fields
20+
% .spectrum = Spectral density [m^2/Hz]
21+
% .frequency = Frequency [Hz]
22+
% .type = 'Pierson-Moskowitz (Hs,Tp)'
2823
%
2924
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3025

31-
if (isa(frequency,'py.numpy.ndarray') ~= 1)
32-
frequency = py.numpy.array(frequency);
26+
arguments
27+
frequency {mustBeNumeric, mustBeFinite}
28+
Tp {mustBeNumeric, mustBeFinite, mustBePositive}
29+
Hs {mustBeNumeric, mustBeFinite, mustBePositive}
3330
end
3431

35-
S_py = py.mhkit.wave.resource.pierson_moskowitz_spectrum(frequency, Tp, Hs);
36-
37-
S_py = typecast_from_mhkit_python(S_py);
32+
% Use JONSWAP spectrum with gamma = 1 (equivalent to Pierson-Moskowitz)
33+
S_jonswap = jonswap_spectrum(frequency, Tp, Hs, 1);
3834

35+
% Create output structure with Pierson-Moskowitz naming for backward compatibility
3936
S = struct();
40-
41-
S.frequency = S_py.index.data;
42-
S.spectrum = S_py.data;
43-
S.type = S_py.columns{1};
37+
S.frequency = S_jonswap.frequency;
38+
S.spectrum = S_jonswap.spectrum;
39+
S.type = sprintf('Pierson-Moskowitz (%.1fm,%.1fs)', Hs, Tp);

0 commit comments

Comments
 (0)