diff --git a/rocketpy/Parachute.py b/rocketpy/Parachute.py index cc45f0624..8e6ff9e80 100644 --- a/rocketpy/Parachute.py +++ b/rocketpy/Parachute.py @@ -1,4 +1,4 @@ -__author__ = "Giovani Hidalgo Ceotto, Franz Masatoshi Yuri" +__author__ = "Giovani Hidalgo Ceotto, Franz Masatoshi Yuri, Guilherme Fernandes Alves" __copyright__ = "Copyright 20XX, RocketPy Team" __license__ = "MIT" @@ -6,6 +6,8 @@ from .Function import Function +from .prints.parachute_prints import _ParachutePrints + class Parachute: """Keeps parachute information. @@ -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 diff --git a/rocketpy/prints/__init__.py b/rocketpy/prints/__init__.py index b8c1a820b..36dccc4e5 100644 --- a/rocketpy/prints/__init__.py +++ b/rocketpy/prints/__init__.py @@ -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 diff --git a/rocketpy/prints/parachute_prints.py b/rocketpy/prints/parachute_prints.py new file mode 100644 index 000000000..4c9c92a9e --- /dev/null +++ b/rocketpy/prints/parachute_prints.py @@ -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__ == "": + 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 diff --git a/rocketpy/prints/rocket_prints.py b/rocketpy/prints/rocket_prints.py index dd835820c..97df57795 100644 --- a/rocketpy/prints/rocket_prints.py +++ b/rocketpy/prints/rocket_prints.py @@ -1,4 +1,4 @@ -__author__ = " " +__author__ = "Mateus Stano Junqueira" __copyright__ = "Copyright 20XX, RocketPy Team" __license__ = "MIT" @@ -8,7 +8,7 @@ class _RocketPrints: Attributes ---------- - _RocketPrints.environment : rocket + _RocketPrints.rocket : rocket Rocket object that will be used for the prints. """ @@ -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 ------- @@ -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__ == "": - 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.