Skip to content

Commit

Permalink
Merge pull request #599 from RocketPy-Team/bug/plot-drag-curves-calla…
Browse files Browse the repository at this point in the history
…ble-function-source

BUG: plot drag curves when function source is callable
  • Loading branch information
Gui-FernandesBR authored May 16, 2024
2 parents f9df056 + 757223b commit 63ef48d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,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)
Expand Down
20 changes: 16 additions & 4 deletions rocketpy/plots/rocket_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 63ef48d

Please sign in to comment.