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
7 changes: 4 additions & 3 deletions rocketpy/plots/flight_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -1265,9 +1265,10 @@ def animate_trajectory( # pylint: disable=too-many-statements,too-many-locals
Ground texture. A mapping may define ``image``, ``bounds``,
``coordinates`` (``"enu"`` or ``"latlon"``), and ``flip_y`` for
geographic placement. Default is None.
color_by : {"speed", "mach", "dynamic_pressure", "acceleration",
"altitude", False, None}, optional
Trajectory point scalar. Default is "speed".
color_by : str | bool | None, optional
Trajectory point scalar, one of ``"speed"``, ``"mach"``,
``"dynamic_pressure"``, ``"acceleration"``, ``"altitude"``,
``False`` or ``None``. Default is "speed".
show_kinematic_plots : bool, optional
Show altitude, speed and acceleration histories. Default is False.
camera_mode : {"static", "follow", "ground", "body"}, optional
Expand Down
58 changes: 58 additions & 0 deletions tests/integration/test_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,64 @@ def test_flight_animations_run_off_screen(flight_calisto):
assert rotation_result is None


def test_flight_animations_render_all_scene_options(flight_calisto):
"""Exercise the animation scene builders with the full set of overlays.

Rendering off screen with playback controls, charts, camera tracking and
stability markers enabled covers the scene-construction branches of both
``animate_trajectory`` and ``animate_rotate`` (and the playback-control
setup in ``_run_animation``) that the minimal smoke test does not reach.
"""
pytest.importorskip("pyvista")
shared_options = {
"start": 0,
"stop": None, # spans the whole flight, hitting every event marker
"time_step": 2.0,
"backend": "none",
"off_screen": True,
"window_size": (240, 180),
"playback_controls": True,
}

trajectory_result = flight_calisto.plots.animate_trajectory(
**shared_options,
color_by="mach",
show_kinematic_plots=True,
show_subrocket_point=True,
camera_mode="follow",
)
rotation_result = flight_calisto.plots.animate_rotate(
**shared_options,
show_attitude_plots=True,
show_cp_cm=True,
camera_mode="body",
)

assert trajectory_result is None
assert rotation_result is None


def test_flight_animation_export_gif(flight_calisto, tmp_path):
"""Cover the deterministic GIF export path of ``_run_animation``."""
pytest.importorskip("pyvista")
pytest.importorskip("imageio")
export_file = tmp_path / "trajectory.gif"

result = flight_calisto.plots.animate_trajectory(
start=0,
stop=0.3,
time_step=0.1,
backend="none",
window_size=(240, 180),
color_by="speed",
export_file=str(export_file),
)

assert result == str(export_file)
assert export_file.is_file()
assert export_file.stat().st_size > 0


@patch("matplotlib.pyplot.show")
def test_compare(mock_show, flight_calisto):
"""Here we want to test the 'x_attributes' argument, which is the only one
Expand Down
Loading
Loading