From 5f18e45fe24398825bb18bde6c2becb59731cfa7 Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Wed, 15 May 2024 11:26:37 -0400 Subject: [PATCH 1/2] BUG: discretize source when plotting drag curves if needed --- rocketpy/plots/rocket_plots.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/rocketpy/plots/rocket_plots.py b/rocketpy/plots/rocket_plots.py index 2be7a4a73..012f025e7 100644 --- a/rocketpy/plots/rocket_plots.py +++ b/rocketpy/plots/rocket_plots.py @@ -134,10 +134,22 @@ def drag_curves(self): None """ - x_power_drag_off = self.rocket.power_off_drag.x_array - y_power_drag_off = self.rocket.power_off_drag.y_array - x_power_drag_on = self.rocket.power_on_drag.x_array - y_power_drag_on = self.rocket.power_on_drag.y_array + try: + x_power_drag_on = self.rocket.power_on_drag.x_array + y_power_drag_on = self.rocket.power_on_drag.y_array + except AttributeError: + x_power_drag_on = np.linspace(0, 2, 50) + y_power_drag_on = np.array( + [self.rocket.power_on_drag.source(x) for x in x_power_drag_on] + ) + try: + x_power_drag_off = self.rocket.power_off_drag.x_array + y_power_drag_off = self.rocket.power_off_drag.y_array + except AttributeError: + x_power_drag_off = np.linspace(0, 2, 50) + y_power_drag_off = np.array( + [self.rocket.power_off_drag.source(x) for x in x_power_drag_off] + ) fig, ax = plt.subplots() ax.plot(x_power_drag_on, y_power_drag_on, label="Power on Drag") From b0e34e978e327880c27529d96f941e5fb4ac1d93 Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Wed, 15 May 2024 11:33:01 -0400 Subject: [PATCH 2/2] DEV: adds #599 to the CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 426a4fa6f..0be3b62b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed +- BUG: plot drag curves when function source is callable [#599](https://github.com/RocketPy-Team/RocketPy/pull/599) - BUG: Fix minor type hinting problems [#598](https://github.com/RocketPy-Team/RocketPy/pull/598) - BUG: Optional Dependencies Naming in pyproject.toml. [#592](https://github.com/RocketPy-Team/RocketPy/pull/592) - BUG: Swap rocket.total_mass.differentiate for motor.total_mass_flow rate [#585](https://github.com/RocketPy-Team/RocketPy/pull/585)