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

ENH: Plotting both power on and off drag curves in a single plot. #547

Merged
merged 5 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ straightforward as possible.
- ENH Precalculate Barometric Height [#511](https://github.com/RocketPy-Team/RocketPy/pull/511)
- MNT: Encapsulate quaternion conversions [#537](https://github.com/RocketPy-Team/RocketPy/pull/537)
- MNT: improve the low pass filter and document an example [#538](https://github.com/RocketPy-Team/RocketPy/pull/538)

- ENH: Plotting both power on and off drag curves in a single plot [#547](https://github.com/RocketPy-Team/RocketPy/pull/547)

### Fixed

- ENH: Parachute trigger doesn't work if "Apogee" is used instead of "apogee" [#489](https://github.com/RocketPy-Team/RocketPy/pull/489)
- BUG: fin_flutter_analysis doesn't find any fin set [#510](https://github.com/RocketPy-Team/RocketPy/pull/510)
- FIX: EmptyMotor is breaking the Rocket.draw() method [#516](https://github.com/RocketPy-Team/RocketPy/pull/516)
- BUG: 3D trajectory plot not labeling axes [#533](https://github.com/RocketPy-Team/RocketPy/pull/533)
-


## [v1.1.5] - 2024-01-21

Expand Down
37 changes: 20 additions & 17 deletions rocketpy/plots/rocket_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,27 +86,31 @@ def stability_margin(self):

return None

def power_on_drag(self):
"""Plots power on drag of the rocket as a function of time.

Returns
-------
None
"""

self.rocket.power_on_drag()

return None

def power_off_drag(self):
Gui-FernandesBR marked this conversation as resolved.
Show resolved Hide resolved
"""Plots power off drag of the rocket as a function of time.
def power_on_and_off_drag(self):
Gui-FernandesBR marked this conversation as resolved.
Show resolved Hide resolved
"""Plots power off and on drag curve of the rocket as a function of time.

Returns
-------
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

fig, ax = plt.subplots()
ax.plot(x_power_drag_on, y_power_drag_on, label="Power on Drag")
ax.plot(
x_power_drag_off, y_power_drag_off, label="Power off Drag", linestyle="--"
)

self.rocket.power_off_drag()
ax.set_title("Power on and off Drag")
Gui-FernandesBR marked this conversation as resolved.
Show resolved Hide resolved
ax.set_ylabel("Drag Coefficient")
ax.set_xlabel("Mach")
ax.axvspan(0.8, 1.2, alpha=0.3, color="gray", label="Transonic Region")
ax.legend(loc="best", shadow=True)
plt.grid(True)
plt.show()

return None
juliomachad0 marked this conversation as resolved.
Show resolved Hide resolved

Expand Down Expand Up @@ -524,8 +528,7 @@ def all(self):
# Drag Plots
print("Drag Plots")
print("-" * 20) # Separator for Drag Plots
self.power_on_drag()
self.power_off_drag()
self.power_on_and_off_drag()

# Stability Plots
print("\nStability Plots")
Expand Down
Loading