Skip to content

Commit

Permalink
consistent use xr.DataArray and xr.Dataset arguments (#248)
Browse files Browse the repository at this point in the history
* Change exc_coeff to a dataset

* Update core to keep exc_coeff as datarray

* Fix solve output docstring

* Specify impedance and excitation data to be DataArray Inputs
  • Loading branch information
jtgrasb authored Nov 3, 2023
1 parent 9c8466b commit 637cfa5
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions wecopttool/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,8 +477,8 @@ def from_floating_body(
@staticmethod
def from_impedance(
freqs: ArrayLike,
impedance: ArrayLike,
exc_coeff: ArrayLike,
impedance: DataArray,
exc_coeff: DataArray,
hydrostatic_stiffness: ndarray,
f_add: Optional[TIForceDict] = None,
constraints: Optional[Iterable[Mapping]] = None,
Expand Down Expand Up @@ -608,7 +608,7 @@ def solve(self,
bounds_wec: Optional[Bounds] = None,
bounds_opt: Optional[Bounds] = None,
callback: Optional[TStateFunction] = None,
) -> tuple[Dataset, Dataset, OptimizeResult]:
) -> OptimizeResult:
"""Simulate WEC dynamics using a pseudo-spectral solution
method and returns the raw results dictionary produced by
:py:func:`scipy.optimize.minimize`.
Expand Down Expand Up @@ -1470,7 +1470,7 @@ def derivative2_mat(


def mimo_transfer_mat(
transfer_mat: ArrayLike,
transfer_mat: DataArray,
zero_freq: Optional[bool] = True,
) -> ndarray:
"""Create a block matrix of the MIMO transfer function.
Expand Down Expand Up @@ -1883,7 +1883,7 @@ def check_linear_damping(


def check_impedance(
Zi: ArrayLike,
Zi: DataArray,
min_damping: Optional[float] = 1e-6,
) -> DataArray:
"""Ensure that the real part of the impedance (resistive) is positive.
Expand Down Expand Up @@ -1914,7 +1914,7 @@ def check_impedance(


def force_from_rao_transfer_function(
rao_transfer_mat: ArrayLike,
rao_transfer_mat: DataArray,
zero_freq: Optional[bool] = True,
) -> TStateFunction:
"""Create a force function from its position transfer matrix.
Expand Down Expand Up @@ -1946,7 +1946,7 @@ def force(wec, x_wec, x_opt, waves):

def force_from_impedance(
omega: ArrayLike,
impedance: ArrayLike,
impedance: DataArray,
) -> TStateFunction:
"""Create a force function from its impedance.
Expand All @@ -1964,7 +1964,7 @@ def force_from_impedance(
return force_from_rao_transfer_function(impedance*(1j*omega), False)


def force_from_waves(force_coeff: ArrayLike,
def force_from_waves(force_coeff: DataArray,
) -> TStateFunction:
"""Create a force function from waves excitation coefficients.
Expand Down Expand Up @@ -2199,7 +2199,7 @@ def add_linear_friction(
return hydro_data


def wave_excitation(exc_coeff: Dataset, waves: Dataset) -> ndarray:
def wave_excitation(exc_coeff: DataArray, waves: Dataset) -> ndarray:
"""Calculate the complex, frequency-domain, excitation force due to
waves.
Expand Down

0 comments on commit 637cfa5

Please sign in to comment.