From 194ec459e46db3397f2464d9454c2a1c9a1839f4 Mon Sep 17 00:00:00 2001 From: jtgrasb Date: Fri, 5 Jan 2024 08:14:17 -0700 Subject: [PATCH 1/2] Update waves.py for nfreq=1 --- wecopttool/waves.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wecopttool/waves.py b/wecopttool/waves.py index 97ddc1a2..898ee7bf 100644 --- a/wecopttool/waves.py +++ b/wecopttool/waves.py @@ -116,7 +116,7 @@ def elevation_fd( if phases is None: phases = random_phase([nfreq, ndirections, nrealizations], seed) else: - phases = degrees_to_radians(phases, False) + phases = np.atleast_3d(degrees_to_radians(phases, False)) assert phases.shape == (nfreq, ndirections, nrealizations) camplitude = amplitudes * np.exp(1j*phases) From 9dcace61ded1bbaf18918527c68feaa356ff8738 Mon Sep 17 00:00:00 2001 From: jtgrasb Date: Thu, 11 Jan 2024 11:05:25 -0700 Subject: [PATCH 2/2] update degrees_to_radians Remove line that selects item() of degrees_to_radians --- wecopttool/core.py | 4 +--- wecopttool/waves.py | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/wecopttool/core.py b/wecopttool/core.py index 890bcb5f..96cf32a4 100644 --- a/wecopttool/core.py +++ b/wecopttool/core.py @@ -2309,9 +2309,7 @@ def degrees_to_radians( """ radians = np.asarray(np.remainder(np.deg2rad(degrees), 2*np.pi)) radians[radians > np.pi] -= 2*np.pi - if radians.size == 1: - radians = radians.item() - elif sort: + if radians.size > 1 and sort: radians = np.sort(radians) return radians diff --git a/wecopttool/waves.py b/wecopttool/waves.py index 898ee7bf..97ddc1a2 100644 --- a/wecopttool/waves.py +++ b/wecopttool/waves.py @@ -116,7 +116,7 @@ def elevation_fd( if phases is None: phases = random_phase([nfreq, ndirections, nrealizations], seed) else: - phases = np.atleast_3d(degrees_to_radians(phases, False)) + phases = degrees_to_radians(phases, False) assert phases.shape == (nfreq, ndirections, nrealizations) camplitude = amplitudes * np.exp(1j*phases)