Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only use waves frequency vector in post-processing #294

Merged
merged 2 commits into from
Nov 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions wecopttool/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,9 @@ def post_process(self,
"""
create_time = f"{datetime.utcnow()}"

omega_vals = np.concatenate([[0], waves.omega.values])
freq_vals = np.concatenate([[0], waves.freq.values])
period_vals = np.concatenate([[np.inf], 1/waves.freq.values])
pos_attr = {'long_name': 'Position', 'units': 'm or rad'}
vel_attr = {'long_name': 'Velocity', 'units': 'm/s or rad/s'}
acc_attr = {'long_name': 'Acceleration', 'units': 'm/s^2 or rad/s^2'}
Expand All @@ -879,9 +882,9 @@ def post_process(self,
force_attr = {'long_name': 'Force or moment', 'units': 'N or Nm'}
wave_elev_attr = {'long_name': 'Wave elevation', 'units': 'm'}
x_wec, x_opt = self.decompose_state(res.x)
omega_coord = ("omega", self.omega, omega_attr)
freq_coord = ("omega", self.frequency, freq_attr)
period_coord = ("omega", self.period, period_attr)
omega_coord = ("omega", omega_vals, omega_attr)
freq_coord = ("omega", freq_vals, freq_attr)
period_coord = ("omega", period_vals, period_attr)
dof_coord = ("influenced_dof", self.dof_names, dof_attr)

# frequency domain
Expand Down Expand Up @@ -1292,7 +1295,6 @@ def frequency(
f1: float,
nfreq: int,
zero_freq: Optional[bool] = True,
precision: Optional[int] = 10,
) -> ndarray:
"""Construct equally spaced frequency array.

Expand All @@ -1313,11 +1315,7 @@ def frequency(
Number of frequencies.
zero_freq
Whether to include the zero-frequency.
precision
Controls rounding of fundamental frequency.
"""
if precision is not None:
f1 = np.floor(f1*10**precision) / 10**precision
freq = np.arange(0, nfreq+1)*f1
freq = freq[1:] if not zero_freq else freq
return freq
Expand Down
Loading