Skip to content

Commit 08004ef

Browse files
authored
Merge pull request #534 from RocketPy-Team/bug/export-flight-pressure
BUG: Parachute Pressures not being Set before All Info.
2 parents 4127313 + a3e49a2 commit 08004ef

File tree

5 files changed

+33
-3
lines changed

5 files changed

+33
-3
lines changed

.pylintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ disable=raw-checker-failed,
435435
use-implicit-booleaness-not-comparison-to-zero,
436436
no-else-return,
437437
inconsistent-return-statements,
438+
unspecified-encoding,
438439

439440
# Enable the message, report, category or checker with the given id(s). You can
440441
# either give multiple identifier separated by comma (,) or put this option

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ straightforward as possible.
4040

4141
### Fixed
4242

43+
- BUG: Parachute Pressures not being Set before All Info. [#534](https://github.com/RocketPy-Team/RocketPy/pull/534)
4344
- BUG: Invalid Arguments on Two Dimensional Discretize. [#521](https://github.com/RocketPy-Team/RocketPy/pull/521)
4445

4546
## [v1.1.4] - 2023-12-07

rocketpy/plots/flight_plots.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,6 @@ def pressure_signals(self):
817817
if len(self.flight.parachute_events) > 0:
818818
for parachute in self.flight.rocket.parachutes:
819819
print("\nParachute: ", parachute.name)
820-
self.flight._calculate_pressure_signal()
821820
parachute.noise_signal_function()
822821
parachute.noisy_pressure_signal_function()
823822
parachute.clean_pressure_signal_function()

rocketpy/simulation/flight.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,7 @@ def __init__(
10651065
)
10661066

10671067
self.t_final = self.t
1068+
self._calculate_pressure_signal()
10681069
if verbose:
10691070
print("Simulation Completed at Time: {:3.4f} s".format(self.t))
10701071

@@ -3089,8 +3090,8 @@ def export_pressures(self, file_name, time_step):
30893090
else:
30903091
for parachute in self.rocket.parachutes:
30913092
for t in time_points:
3092-
p_cl = parachute.clean_pressure_signal(t)
3093-
p_ns = parachute.noisy_pressure_signal(t)
3093+
p_cl = parachute.clean_pressure_signal_function(t)
3094+
p_ns = parachute.noisy_pressure_signal_function(t)
30943095
file.write(f"{t:f}, {p_cl:.5f}, {p_ns:.5f}\n")
30953096
# We need to save only 1 parachute data
30963097
break

tests/test_flight.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -949,3 +949,31 @@ def test_aerodynamic_moments(flight_calisto_custom_wind, flight_time, expected_v
949949
test.M2(t),
950950
test.M3(t),
951951
), f"Assertion error for moment vector at {expected_attr}."
952+
953+
954+
def test_export_pressures(flight_calisto_robust):
955+
"""Tests if the method Flight.export_pressures is working as intended.
956+
957+
Parameters
958+
----------
959+
flight_calisto_robust : Flight
960+
Flight object to be tested. See the conftest.py file for more info
961+
regarding this pytest fixture.
962+
"""
963+
file_name = "pressures.csv"
964+
time_step = 0.5
965+
parachute = flight_calisto_robust.rocket.parachutes[0]
966+
967+
flight_calisto_robust.export_pressures(file_name, time_step)
968+
969+
with open(file_name, "r") as file:
970+
contents = file.read()
971+
972+
expected_data = ""
973+
for t in np.arange(0, flight_calisto_robust.t_final, time_step):
974+
p_cl = parachute.clean_pressure_signal_function(t)
975+
p_ns = parachute.noisy_pressure_signal_function(t)
976+
expected_data += f"{t:f}, {p_cl:.5f}, {p_ns:.5f}\n"
977+
978+
assert contents == expected_data
979+
os.remove(file_name)

0 commit comments

Comments
 (0)