MNT: Remove redundant wind_heading/wind_direction functions from EnvironmentAnalysis#1041
Draft
Gui-FernandesBR wants to merge 2 commits into
Draft
MNT: Remove redundant wind_heading/wind_direction functions from EnvironmentAnalysis#1041Gui-FernandesBR wants to merge 2 commits into
Gui-FernandesBR wants to merge 2 commits into
Conversation
…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>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Removes the per-date/hour
wind_headingandwind_directionFunctionobjects thatEnvironmentAnalysisstored insideoriginal_pressure_level_data(and converted intoconverted_pressure_level_data). They were dead and redundant, and they carried a latent bug.Motivation
While reviewing #974 (wind wraparound fix for the
Environmentclass), we checked whetherEnvironmentAnalysisneeded the same fix. It does not — every consumer derives heading/direction from the wind velocity components (u/v) viaarctan2, which is the correct circular method and immune to the 360°/0° seam:surface_wind_direction_by_hour→arctan2(vy, vx)average_wind_heading_profile/average_wind_heading_profile_by_hour→arctan2(mean_u, mean_v)wind_heading_profiles_list→arctan2(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 siblingswind_velocity_x/y,wind_speed,pressure,temperature. Because they linearly interpolated degrees, they reproduced the exact wraparound artifact that #974 fixes forEnvironment.Changes
wind_heading_function/wind_direction_functionconstructions and their dict assignments in the pressure-level data builder.current_unitsand theconverted_pressure_level_dataconversion_dict.Heading/direction remain fully derivable from the retained
wind_velocity_x/wind_velocity_yfunctions.Verification
ruff check/ruff formatclean;pylint10.00/10.tests/unit/environment/test_environment_analysis.py --runslow→ 5 passed (exercisesconverted_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_dataproperties, 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
Environmentclass.