Skip to content

BUG: Add wraparound logic for wind direction in environment plots#939

Open
khushalkottaru wants to merge 8 commits intoRocketPy-Team:developfrom
khushalkottaru:daily-issue-scout-12924607668829467013
Open

BUG: Add wraparound logic for wind direction in environment plots#939
khushalkottaru wants to merge 8 commits intoRocketPy-Team:developfrom
khushalkottaru:daily-issue-scout-12924607668829467013

Conversation

@khushalkottaru
Copy link

Pull request type

  • Code changes (bugfix, features)

Checklist

  • Tests for the changes have been added (if needed)
  • Lint (black rocketpy/ tests/) has passed locally
  • All tests (pytest tests -m slow --runslow) have passed locally

Current behavior

When wind direction crosses the 0/360 boundary, matplotlib connects those two points with a straight line. This leads to cluttered and visually misleading graphs where the wind wrapped around.

New behavior

Now, before passing data to the plotting function, the code detects any consecutive pair of direction values that differ by more than 180 deg. If detected, a NaN is inserted at that position. This can be thought of as "lifting the pen" when drawing the graph. The actual data points are still plotted correctly, but the lines from before do not make an appearance.

Breaking change

  • Yes
  • No

@khushalkottaru khushalkottaru requested a review from a team as a code owner March 17, 2026 18:21
@Gui-FernandesBR Gui-FernandesBR changed the base branch from master to develop March 17, 2026 19:42
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates RocketPy’s environment wind-direction plotting to avoid misleading lines when the direction wraps at the 360°→0° boundary, and adds an integration test intended to cover this scenario.

Changes:

  • Insert NaNs into wind-direction plot data where direction jumps indicate 360°→0° wraparound, preventing matplotlib from drawing a connecting line.
  • Apply the same wraparound handling in ensemble member wind-direction comparison plots.
  • Add an integration test case that sets up a custom atmosphere with a direction wraparound and exercises plotting.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
rocketpy/plots/environment_plots.py Breaks wind-direction lines at wraparound points by inserting NaNs (single and ensemble plots).
tests/integration/environment/test_environment.py Adds a regression-style integration test that sets up a wraparound wind direction and calls plotting APIs.

You can also share your feedback on Copilot code review. Take the survey.

khushalkottaru and others added 3 commits March 17, 2026 18:53
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Member

@Gui-FernandesBR Gui-FernandesBR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changelog.md?

@Gui-FernandesBR
Copy link
Member

@khushalkottaru great fix, thanks.

Can you show us some plots of before and after implementation please? Just to make sure your PR descriptions matches the expected behavior.

Btw I believe this is a related issue: #253

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants