Skip to content

MNT: Remove redundant wind_heading/wind_direction functions from EnvironmentAnalysis#1041

Draft
Gui-FernandesBR wants to merge 2 commits into
developfrom
MNT/envanalysis-drop-redundant-wind-functions
Draft

MNT: Remove redundant wind_heading/wind_direction functions from EnvironmentAnalysis#1041
Gui-FernandesBR wants to merge 2 commits into
developfrom
MNT/envanalysis-drop-redundant-wind-functions

Conversation

@Gui-FernandesBR

Copy link
Copy Markdown
Member

Summary

Removes the per-date/hour wind_heading and wind_direction Function objects that EnvironmentAnalysis stored inside original_pressure_level_data (and converted into converted_pressure_level_data). They were dead and redundant, and they carried a latent bug.

Motivation

While reviewing #974 (wind wraparound fix for the Environment class), we checked whether EnvironmentAnalysis needed the same fix. It does not — every consumer derives heading/direction from the wind velocity components (u/v) via arctan2, which is the correct circular method and immune to the 360°/0° seam:

  • surface_wind_direction_by_hourarctan2(vy, vx)
  • average_wind_heading_profile / average_wind_heading_profile_by_hourarctan2(mean_u, mean_v)
  • wind_heading_profiles_listarctan2(u(alt), v(alt))

The only code that interpolated raw degrees were these two stored Functions — and a usage audit shows they were never read anywhere (0 consumers), unlike their siblings wind_velocity_x/y, wind_speed, pressure, temperature. Because they linearly interpolated degrees, they reproduced the exact wraparound artifact that #974 fixes for Environment.

Changes

  • Drop the wind_heading_function / wind_direction_function constructions and their dict assignments in the pressure-level data builder.
  • Remove their now-unused entries from current_units and the converted_pressure_level_data conversion_dict.
  • Update the builder docstring accordingly.

Heading/direction remain fully derivable from the retained wind_velocity_x / wind_velocity_y functions.

Verification

  • ruff check / ruff format clean; pylint 10.00/10.
  • tests/unit/environment/test_environment_analysis.py --runslow5 passed (exercises converted_pressure_level_data, wind_heading_profile_grid, average_wind_heading_profile, animate_wind_heading_profile).

Note for reviewers — API surface

These functions were technically reachable via the public original_pressure_level_data / converted_pressure_level_data properties, so strictly this is a public-API removal. They appear unused and undocumented as an access pattern, so I went with outright removal per the cleanup intent — but if you'd prefer a deprecation cycle instead, say so and I'll switch to that.

Split out of the #974 review; #974 stays scoped to the Environment class.

…ronmentAnalysis

The per-date/hour wind_heading and wind_direction Function objects stored in
EnvironmentAnalysis.original_pressure_level_data were never read internally:
every consumer (surface_wind_direction_by_hour, average_wind_heading_profile
and _by_hour, wind_heading_profiles_list) recomputes heading/direction from the
wind velocity components (u/v) via arctan2 -- the correct circular method. The
stored functions linearly interpolated raw degrees, so they also carried the
360/0 wraparound artifact fixed for the Environment class in #974.

Removes the two Function constructions plus their now-unused current_units and
conversion_dict entries. Direction/heading remain fully derivable from the
retained wind_velocity_x / wind_velocity_y functions.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Gui-FernandesBR Gui-FernandesBR requested a review from a team as a code owner June 27, 2026 03:33
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.22%. Comparing base (9cf3dd4) to head (4548e51).
⚠️ Report is 84 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1041      +/-   ##
===========================================
+ Coverage    80.27%   81.22%   +0.94%     
===========================================
  Files          104      113       +9     
  Lines        12769    14681    +1912     
===========================================
+ Hits         10250    11924    +1674     
- Misses        2519     2757     +238     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Gui-FernandesBR Gui-FernandesBR marked this pull request as draft June 27, 2026 11:49
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.

1 participant