From 00ec66f2af557a486feb0c533ee117cc95d0bbb3 Mon Sep 17 00:00:00 2001 From: Chris McComb Date: Sat, 24 Oct 2026 18:37:32 -0400 Subject: [PATCH] Batch passive-yaw frequency interpolation with SciPy --- wecsim/hydrodynamics/passiveYaw.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/wecsim/hydrodynamics/passiveYaw.py b/wecsim/hydrodynamics/passiveYaw.py index fa31a23b..09c787af 100644 --- a/wecsim/hydrodynamics/passiveYaw.py +++ b/wecsim/hydrodynamics/passiveYaw.py @@ -3,7 +3,7 @@ from dataclasses import dataclass import numpy as np -from scipy.interpolate import CubicSpline +from scipy.interpolate import CubicSpline, make_interp_spline from wecsim.environment.irregularWave import IrregularComponents @@ -56,14 +56,10 @@ def from_hydro_data(cls, hydro_data, *, omega, incident_direction, real = CubicSpline(frequency, real, axis=2)(omega) * rho * g imaginary = CubicSpline(frequency, imaginary, axis=2)(omega) * rho * g else: - real = np.array([ - [np.interp(omega, frequency, row) for row in dof] - for dof in real - ]) * rho * g - imaginary = np.array([ - [np.interp(omega, frequency, row) for row in dof] - for dof in imaginary - ]) * rho * g + real = make_interp_spline(frequency, real, k=1, axis=2)(omega) * rho * g + imaginary = make_interp_spline( + frequency, imaginary, k=1, axis=2, + )(omega) * rho * g return cls(headings, real, imaginary, incident_direction, omega, amplitude, ramp_time)