diff --git a/.pylintrc b/.pylintrc index 97a3abeb1..2611847f2 100644 --- a/.pylintrc +++ b/.pylintrc @@ -435,6 +435,7 @@ disable=raw-checker-failed, use-implicit-booleaness-not-comparison-to-zero, no-else-return, inconsistent-return-statements, + unspecified-encoding, # Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fe9d9f7e..1ef7658a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ straightforward as possible. ### Fixed +- BUG: Parachute Pressures not being Set before All Info. [#534](https://github.com/RocketPy-Team/RocketPy/pull/534) - BUG: Invalid Arguments on Two Dimensional Discretize. [#521](https://github.com/RocketPy-Team/RocketPy/pull/521) ## [v1.1.4] - 2023-12-07 diff --git a/rocketpy/plots/flight_plots.py b/rocketpy/plots/flight_plots.py index 62c751a55..8871a7b4e 100644 --- a/rocketpy/plots/flight_plots.py +++ b/rocketpy/plots/flight_plots.py @@ -817,7 +817,6 @@ def pressure_signals(self): if len(self.flight.parachute_events) > 0: for parachute in self.flight.rocket.parachutes: print("\nParachute: ", parachute.name) - self.flight._calculate_pressure_signal() parachute.noise_signal_function() parachute.noisy_pressure_signal_function() parachute.clean_pressure_signal_function() diff --git a/rocketpy/simulation/flight.py b/rocketpy/simulation/flight.py index d843127ab..50ec95ca6 100644 --- a/rocketpy/simulation/flight.py +++ b/rocketpy/simulation/flight.py @@ -1065,6 +1065,7 @@ def __init__( ) self.t_final = self.t + self._calculate_pressure_signal() if verbose: print("Simulation Completed at Time: {:3.4f} s".format(self.t)) @@ -3089,8 +3090,8 @@ def export_pressures(self, file_name, time_step): else: for parachute in self.rocket.parachutes: for t in time_points: - p_cl = parachute.clean_pressure_signal(t) - p_ns = parachute.noisy_pressure_signal(t) + p_cl = parachute.clean_pressure_signal_function(t) + p_ns = parachute.noisy_pressure_signal_function(t) file.write(f"{t:f}, {p_cl:.5f}, {p_ns:.5f}\n") # We need to save only 1 parachute data break diff --git a/tests/test_flight.py b/tests/test_flight.py index f658acba1..90bad8942 100644 --- a/tests/test_flight.py +++ b/tests/test_flight.py @@ -949,3 +949,31 @@ def test_aerodynamic_moments(flight_calisto_custom_wind, flight_time, expected_v test.M2(t), test.M3(t), ), f"Assertion error for moment vector at {expected_attr}." + + +def test_export_pressures(flight_calisto_robust): + """Tests if the method Flight.export_pressures is working as intended. + + Parameters + ---------- + flight_calisto_robust : Flight + Flight object to be tested. See the conftest.py file for more info + regarding this pytest fixture. + """ + file_name = "pressures.csv" + time_step = 0.5 + parachute = flight_calisto_robust.rocket.parachutes[0] + + flight_calisto_robust.export_pressures(file_name, time_step) + + with open(file_name, "r") as file: + contents = file.read() + + expected_data = "" + for t in np.arange(0, flight_calisto_robust.t_final, time_step): + p_cl = parachute.clean_pressure_signal_function(t) + p_ns = parachute.noisy_pressure_signal_function(t) + expected_data += f"{t:f}, {p_cl:.5f}, {p_ns:.5f}\n" + + assert contents == expected_data + os.remove(file_name)