From e81970b8893d17b4ee7ab25276e8e46099274c75 Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR <63590233+Gui-FernandesBR@users.noreply.github.com> Date: Sun, 18 Aug 2024 10:07:20 -0300 Subject: [PATCH] BUG: fix the Frequency Response plot of Flight class (#653) * BUG: fix the Frequency Response plot of Flight class * DEV: adds #653 to CHANGELOG * ENH: improves max_omega3 calculation --- CHANGELOG.md | 2 +- rocketpy/plots/flight_plots.py | 25 +++++++++++++------------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f1828872..d600e391f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,7 +43,7 @@ Attention: The newest changes should be on top --> ### Fixed - +- BUG: fix the Frequency Response plot of Flight class [#653](https://github.com/RocketPy-Team/RocketPy/pull/653) ## [v1.4.2] - 2024-08-03 diff --git a/rocketpy/plots/flight_plots.py b/rocketpy/plots/flight_plots.py index 74caaeb33..1e5c53449 100644 --- a/rocketpy/plots/flight_plots.py +++ b/rocketpy/plots/flight_plots.py @@ -731,32 +731,33 @@ def stability_and_control_data(self): # pylint: disable=too-many-statements ax1.grid() ax2 = plt.subplot(212) - max_attitude = max(self.flight.attitude_frequency_response[:, 1]) + x_axis = np.arange(0, 5, 0.01) + max_attitude = self.flight.attitude_frequency_response.max max_attitude = max_attitude if max_attitude != 0 else 1 ax2.plot( - self.flight.attitude_frequency_response[:, 0], - self.flight.attitude_frequency_response[:, 1] / max_attitude, + x_axis, + self.flight.attitude_frequency_response(x_axis) / max_attitude, label="Attitude Angle", ) - max_omega1 = max(self.flight.omega1_frequency_response[:, 1]) + max_omega1 = self.flight.omega1_frequency_response.max max_omega1 = max_omega1 if max_omega1 != 0 else 1 ax2.plot( - self.flight.omega1_frequency_response[:, 0], - self.flight.omega1_frequency_response[:, 1] / max_omega1, + x_axis, + self.flight.omega1_frequency_response(x_axis) / max_omega1, label=r"$\omega_1$", ) - max_omega2 = max(self.flight.omega2_frequency_response[:, 1]) + max_omega2 = self.flight.omega2_frequency_response.max max_omega2 = max_omega2 if max_omega2 != 0 else 1 ax2.plot( - self.flight.omega2_frequency_response[:, 0], - self.flight.omega2_frequency_response[:, 1] / max_omega2, + x_axis, + self.flight.omega2_frequency_response(x_axis) / max_omega2, label=r"$\omega_2$", ) - max_omega3 = max(self.flight.omega3_frequency_response[:, 1]) + max_omega3 = self.flight.omega3_frequency_response.max max_omega3 = max_omega3 if max_omega3 != 0 else 1 ax2.plot( - self.flight.omega3_frequency_response[:, 0], - self.flight.omega3_frequency_response[:, 1] / max_omega3, + x_axis, + self.flight.omega3_frequency_response(x_axis) / max_omega3, label=r"$\omega_3$", ) ax2.set_title("Frequency Response")