Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Parachute Pressures not being Set before All Info. #534

Merged
merged 3 commits into from
Jan 21, 2024
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
1 change: 1 addition & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion rocketpy/plots/flight_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 3 additions & 2 deletions rocketpy/simulation/flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions tests/test_flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Loading