Fix latlon_to_xy longitude scaling bug and update scaling tests (Fixes #2614)#2700
Open
muien5080 wants to merge 1 commit intopvlib:mainfrom
Open
Fix latlon_to_xy longitude scaling bug and update scaling tests (Fixes #2614)#2700muien5080 wants to merge 1 commit intopvlib:mainfrom
muien5080 wants to merge 1 commit intopvlib:mainfrom
Conversation
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.
Fixes incorrect longitude scaling in latlon_to_xy where the NumPy array construction previously misapplied scaling factors, causing longitude to be multiplied by the latitude conversion factor.
This PR also updates the affected tests to reflect correct geodetic scaling.
Fixes #2614
Details
The previous implementation constructed the scaling vector incorrectly, which resulted in both latitude and longitude being scaled using the meters-per-degree latitude value.
This PR:
Corrects the scaling vector construction:
np.array([m_per_deg_lat, m_per_deg_lon])
Ensures longitude scaling properly depends on mean latitude.
Updates expected coordinate values in test_scaling.py.
Updates expected variability reduction (VR) values affected by corrected geometry.
Validation:
All test_scaling.py tests pass.
Full test suite passes locally:
1415 passed
111 skipped
2 xfailed
No new warnings introduced.
Notes:
latlon_to_xy is primarily a utility function for WVM-related workflows and is not used internally within pvlib, but correcting the geodetic scaling ensures accurate spatial modeling for users relying on this functionality.