Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
36 changes: 35 additions & 1 deletion rocketpy/Parachute.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
__author__ = "Giovani Hidalgo Ceotto, Franz Masatoshi Yuri"
__author__ = "Giovani Hidalgo Ceotto, Franz Masatoshi Yuri, Guilherme Fernandes Alves"
__copyright__ = "Copyright 20XX, RocketPy Team"
__license__ = "MIT"

import numpy as np

from .Function import Function

from .prints.parachute_prints import _ParachutePrints


class Parachute:
"""Keeps parachute information.
Expand Down Expand Up @@ -117,4 +119,36 @@ def __init__(
self.noiseFunction = lambda: alpha * self.noiseSignal[-1][
1
] + beta * np.random.normal(noise[0], noise[1])

self.prints = _ParachutePrints(self)

return None

def __str__(self):
"""Returns a string representation of the Parachute class.
Parameters
----------
None

Returns
-------
string
String representation of Parachute class. It is human readable.
"""
return "Parachute {} with a CdS of {:.4f} m2".format(
self.name.title(),
self.CdS,
)

def info(self):

self.prints.all()

return None

def allInfo(self):

self.info()
# self.plots.all() # Parachutes still doesn't have plots

return None
5 changes: 3 additions & 2 deletions rocketpy/prints/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .flight_prints import _FlightPrints
from .compare_prints import _ComparePrints
from .environment_prints import _EnvironmentPrints
from .flight_prints import _FlightPrints
from .parachute_prints import _ParachutePrints
from .rocket_prints import _RocketPrints
from .compare_prints import _ComparePrints
81 changes: 81 additions & 0 deletions rocketpy/prints/parachute_prints.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
__author__ = "Guilherme Fernandes Alves"
__copyright__ = "Copyright 20XX, RocketPy Team"
__license__ = "MIT"


class _ParachutePrints:
"""Class that holds prints methods for Parachute class.

Attributes
----------
_ParachutePrints.parachute : rocketpy.Parachute
Parachute object that will be used for the prints.

"""

def __init__(self, parachute) -> None:
"""Initializes _ParachutePrints class

Parameters
----------
parachute: rocketpy.Parachute
Instance of the Parachute class.

Returns
-------
None
"""
self.parachute = parachute

return None

def trigger(self):
"""Prints trigger information.

Parameters
----------
None

Return
------
None
"""

if self.parachute.trigger.__name__ == "<lambda>":
line = self.rocket.getsourcelines(self.parachute.trigger)[0][0]
print(
"Ejection signal trigger: "
+ line.split("lambda ")[1].split(",")[0].split("\n")[0]
)
else:
print("Ejection signal trigger: " + self.parachute.trigger.__name__)

print(f"Ejection system refresh rate: {self.parachute.samplingRate:.3f} Hz")
print(
f"Time between ejection signal is triggered and the parachute is fully opened: {self.parachute.lag:.1f} s\n"
)

return None

def noise(self):
# Not implemented yet
pass

def all(self):
"""Prints all information about the parachute.

Parameters
----------
None

Return
------
None
"""

print("\nParachute Details\n")
print(self.parachute.__str__())
self.trigger()
self.noise()

return None
26 changes: 6 additions & 20 deletions rocketpy/prints/rocket_prints.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__author__ = " "
__author__ = "Mateus Stano Junqueira"
__copyright__ = "Copyright 20XX, RocketPy Team"
__license__ = "MIT"

Expand All @@ -8,7 +8,7 @@ class _RocketPrints:

Attributes
----------
_RocketPrints.environment : rocket
_RocketPrints.rocket : rocket
Rocket object that will be used for the prints.

"""
Expand All @@ -18,8 +18,8 @@ def __init__(self, rocket) -> None:

Parameters
----------
environment: Environment
Instance of the Environment class.
rocket: rocketpy.rocket
Instance of the rocket class.

Returns
-------
Expand Down Expand Up @@ -158,22 +158,8 @@ def parachute_data(self):
None
"""
for chute in self.rocket.parachutes:
print("\n" + chute.name.title() + " Parachute\n")
print("CdS Coefficient: " + str(chute.CdS) + " m2")
if chute.trigger.__name__ == "<lambda>":
line = self.rocket.getsourcelines(chute.trigger)[0][0]
print(
"Ejection signal trigger: "
+ line.split("lambda ")[1].split(",")[0].split("\n")[0]
)
else:
print("Ejection signal trigger: " + chute.trigger.__name__)
print("Ejection system refresh rate: " + str(chute.samplingRate) + " Hz.")
print(
"Time between ejection signal is triggered and the "
"parachute is fully opened: " + str(chute.lag) + " s"
)
return None
chute.allInfo()
return None

def all(self):
"""Prints all print methods about the Environment.
Expand Down