Skip to content

Commit d8523a4

Browse files
jtgrasbmichaelcdevin
authored andcommitted
Update to Wavespectra 4.3.0 (sandialabs#386)
* compare waves from wavespectra * Remove extra wave functions and update tutorials * Update test waves * Revert nrealizations * Require wavespectra 4.0+ * Update to new version of mambaforge * Revert mambaforge * Use wavespectra for tests * Fix variable input * Remove direction message
1 parent 09cbf93 commit d8523a4

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

examples/tutorial_4_Pioneer.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"from scipy.linalg import block_diag\n",
4242
"import xarray as xr\n",
4343
"from math import comb\n",
44+
"from wavespectra.construct.frequency import pierson_moskowitz\n",
4445
"\n",
4546
"import wecopttool as wot\n",
4647
"\n",
@@ -75,9 +76,11 @@
7576
"fend = 1.875\n",
7677
"nfreq_irreg = 150\n",
7778
"f1_irreg = fend / nfreq_irreg\n",
79+
"freq_irreg = wot.frequency(f1_irreg, nfreq_irreg, False) # False -> no zero frequency\n",
7880
"\n",
7981
"f1_reg = .325/2\n",
80-
"nfreq_reg = 12"
82+
"nfreq_reg = 12\n",
83+
"freq_reg = wot.frequency(f1_reg, nfreq_reg, False) # False -> no zero frequency"
8184
]
8285
},
8386
{
@@ -97,8 +100,7 @@
97100
"nrealizations = 2\n",
98101
"\n",
99102
"fp = 1/Tp\n",
100-
"spectrum = lambda f: wot.waves.pierson_moskowitz_spectrum(f, fp, Hs)\n",
101-
"efth = wot.waves.omnidirectional_spectrum(f1_irreg, nfreq_irreg, spectrum, \"Pierson-Moskowitz\")\n",
103+
"efth = pierson_moskowitz(freq=freq_irreg, hs=Hs, fp=fp)\n",
102104
"waves_irregular = wot.waves.long_crested_wave(efth, nrealizations=nrealizations)"
103105
]
104106
},
@@ -278,11 +280,9 @@
278280
"outputs": [],
279281
"source": [
280282
"rho = 1025. # kg/m^3\n",
281-
"freq_reg = wot.frequency(f1_reg, nfreq_reg, False) # False -> no zero frequency\n",
282283
"bem_data_reg = wot.run_bem(pnr_fb, freq_reg)\n",
283284
"omega_reg = bem_data_reg.omega.values\n",
284285
"\n",
285-
"freq_irreg = wot.frequency(f1_irreg, nfreq_irreg, False) # False -> no zero frequency\n",
286286
"bem_data_irreg = wot.run_bem(pnr_fb, freq_irreg)\n",
287287
"omega_irreg = bem_data_irreg.omega.values\n",
288288
"\n",

tests/test_waves.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,4 +344,4 @@ def test_float(self,):
344344
matrix.
345345
"""
346346
phase = wot.waves.random_phase()
347-
assert (phase < np.pi) and (phase >= -np.pi)
347+
assert (phase < np.pi) and (phase >= -np.pi)

wecopttool/waves.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,13 +247,11 @@ def irregular_wave(efth: DataArray,
247247
seed: Optional[float] = None,) -> DataArray:
248248
"""Create a complex frequency-domain wave elevation from a spectrum.
249249
250-
The spectrum is a :py:class:`xarray.DataArray` in the format used
251-
by :py:class:`wavespectra.SpecArray`.
252250
The spectrum is a :py:class:`xarray.DataArray` in the format used
253251
by :py:class:`wavespectra.SpecArray`. For generating wave spectra
254252
with directional spreading, see
255253
:py:class:`wavespectra.construction.direction`.
256-
254+
257255
.. note:: The frequencies must be evenly-spaced with spacing equal
258256
to the first frequency. This is not always the case when
259257
e.g. reading from buoy data. Use interpolation as

0 commit comments

Comments
 (0)