Skip to content

Commit

Permalink
eliminating multiple plots for inertia tensors
Browse files Browse the repository at this point in the history
  • Loading branch information
dipesh2212 committed Feb 29, 2024
1 parent 31fb869 commit e6a26e9
Showing 1 changed file with 18 additions and 92 deletions.
110 changes: 18 additions & 92 deletions rocketpy/plots/motor_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,113 +135,39 @@ def exhaust_velocity(self, lower_limit=None, upper_limit=None):
"""
self.motor.exhaust_velocity.plot(lower=lower_limit, upper=upper_limit)

def I_11(self, lower_limit=None, upper_limit=None):
"""Plots I_11 of the motor as a function of time.
def inertia_tensors(self, lower_limit=None, upper_limit=None):
"""Plots all inertia tensors (I_11, I_22, I_33, I_12, I_13, I_23)
of the motor as a function of time in a single chart.
Parameters
----------
lower_limit : float
Lower limit of the plot. Default is none, which means that the plot
limits will be automatically calculated.
upper_limit : float
Upper limit of the plot. Default is none, which means that the plot
limits will be automatically calculated.
Return
------
None
"""
self.motor.I_11.plot(lower=lower_limit, upper=upper_limit)

def I_22(self, lower_limit=None, upper_limit=None):
"""Plots I_22 of the motor as a function of time.
Parameters
----------
lower_limit : float
Lower limit of the plot. Default is none, which means that the plot
limits will be automatically calculated.
upper_limit : float
Upper limit of the plot. Default is none, which means that the plot
limits will be automatically calculated.
Return
------
None
"""
self.motor.I_22.plot(lower=lower_limit, upper=upper_limit)

def I_33(self, lower_limit=None, upper_limit=None):
"""Plots I_33 of the motor as a function of time.
Parameters
----------
lower_limit : float
Lower limit of the plot. Default is none, which means that the plot
limits will be automatically calculated.
upper_limit : float
Upper limit of the plot. Default is none, which means that the plot
limits will be automatically calculated.
Return
------
None
"""
self.motor.I_33.plot(lower=lower_limit, upper=upper_limit)

def I_12(self, lower_limit=None, upper_limit=None):
"""Plots I_12 of the motor as a function of time.
Parameters
----------
lower_limit : float
Lower limit of the plot. Default is none, which means that the plot
Lower limit of the plot. Default is None, which means that the plot
limits will be automatically calculated.
upper_limit : float
Upper limit of the plot. Default is none, which means that the plot
Upper limit of the plot. Default is None, which means that the plot
limits will be automatically calculated.
Return
------
None
fig : matplotlib.figure.Figure
The matplotlib figure containing the inertia tensors plot.
"""
self.motor.I_12.plot(lower=lower_limit, upper=upper_limit)

def I_13(self, lower_limit=None, upper_limit=None):
"""Plots I_13 of the motor as a function of time.
Parameters
----------
lower_limit : float
Lower limit of the plot. Default is none, which means that the plot
limits will be automatically calculated.
upper_limit : float
Upper limit of the plot. Default is none, which means that the plot
limits will be automatically calculated.
labels = ["I_11", "I_22", "I_33", "I_12", "I_13", "I_23"]

Return
------
None
"""
self.motor.I_13.plot(lower=lower_limit, upper=upper_limit)
fig, ax = plt.subplots(figsize=(12, 8))

def I_23(self, lower_limit=None, upper_limit=None):
"""Plots I_23 of the motor as a function of time.
for label in labels:
getattr(self.motor, label).plot(lower=lower_limit, upper=upper_limit, label=label)

Parameters
----------
lower_limit : float
Lower limit of the plot. Default is None, which means that the plot
limits will be automatically calculated.
upper_limit : float
Upper limit of the plot. Default is None, which means that the plot
limits will be automatically calculated.
ax.legend()
ax.set_xlabel("Time (s)")
ax.set_ylabel("Inertia Tensor Values")
ax.set_title("Inertia Tensors Over Time")
ax.grid(True)
plt.tight_layout()

Return
------
None
"""
self.motor.I_23.plot(lower=lower_limit, upper=upper_limit)
return fig

def _generate_nozzle(self, translate=(0, 0), csys=1):
"""Generates a patch that represents the nozzle of the motor. It is
Expand Down

0 comments on commit e6a26e9

Please sign in to comment.